Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grid = 10
- values = 3 '2 - 10.
- RETINA off
- ' The "ant" moves up-down, left-right.
- ' If any of a cell's adjacent neighbors are the same value as that cell, both cells are randomized with another value.
- BCOLOR 75,75,75
- grid=grid+2
- IF values<2 THEN
- values=2
- ENDIF
- IF values>10 THEN
- values=10
- ENDIF
- IF grid<3 THEN
- grid=3
- ENDIF
- DIM gr(grid,grid),r(10),g(10),b(10)
- SLEEP 0.01 'Let the CPU catch up.
- r(1)=255
- g(1)=0
- b(1)=0
- r(2)=0
- g(2)=255
- b(2)=0
- r(3)=0
- g(3)=0
- b(3)=255
- r(4)=0
- g(4)=255
- b(4)=255
- r(5)=255
- g(5)=0
- b(5)=255
- r(6)=255
- g(6)=255
- b(6)=0
- r(7)=125
- g(7)=125
- b(7)=125
- r(8)=150
- g(8)=0
- b(8)=255
- r(9)=255
- g(9)=150
- b(9)=0
- r(10)=255
- g(10)=255
- b(10)=255
- SLEEP 0.01
- TEXTFONT "Arial Rounded","Bold",10
- FOR i=2 TO grid-1
- FOR j=2 TO grid-1
- gr(i,j)=INT(1+(RND*values))
- COLOR r(gr(i,j)),g(gr(i,j)),b(gr(i,j))
- RECT (i*(ScreenWidth/grid))-(ScreenWidth/grid),(j*(ScreenHeight/grid))-(ScreenHeight/grid),i*(ScreenWidth/grid),j*(ScreenHeight/grid)
- COLOR 0,0,0
- DRAWTEXT STR$(gr(i,j)),(i*(ScreenWidth/grid))-(ScreenWidth/grid),(j*(ScreenHeight/grid))-(ScreenHeight/grid)
- NEXT
- NEXT
- loopA:
- BEGINDRAW
- SLEEP 0.001
- a=0
- FOR i=2 TO grid-1
- FOR j=2 TO grid-1
- ' BEGINDRAW
- IF gr(i+1,j)=gr(i,j) THEN
- a=a+1
- gr(i,j)=INT(1+(RND*values))
- gr(i+1,j)=INT(1+(RND*values))
- COLOR r(gr(i+1,j)),g(gr(i+1,j)),b(gr(i+1,j))
- RECT ((i+1)*(ScreenWidth/grid))-(ScreenWidth/grid),(j*(ScreenHeight/grid))-(ScreenHeight/grid),(i+1)*(ScreenWidth/grid),j*(ScreenHeight/grid)
- COLOR 0,0,0
- DRAWTEXT STR$(gr(i+1,j)),((i+1)*(ScreenWidth/grid))-(ScreenWidth/grid),(j*(ScreenHeight/grid))-(ScreenHeight/grid)
- ENDIF
- IF gr(i,j-1)=gr(i,j) THEN
- a=a+1
- gr(i,j)=INT(1+(RND*values))
- gr(i,j-1)=INT(1+(RND*values))
- COLOR r(gr(i,j-1)),g(gr(i,j-1)),b(gr(i,j-1))
- RECT (i*(ScreenWidth/grid))-(ScreenWidth/grid),((j-1)*(ScreenHeight/grid))-(ScreenHeight/grid),i*(ScreenWidth/grid),(j-1)*(ScreenHeight/grid)
- COLOR 0,0,0
- DRAWTEXT STR$(gr(i,j-1)),(i*(ScreenWidth/grid))-(ScreenWidth/grid),((j-1)*(ScreenHeight/grid))-(ScreenHeight/grid)
- ENDIF
- IF gr(i,j+1)=gr(i,j) THEN
- a=a+1
- gr(i,j)=INT(1+(RND*values))
- gr(i,j+1)=INT(1+(RND*values))
- COLOR r(gr(i,j+1)),g(gr(i,j+1)),b(gr(i,j+1))
- RECT (i*(ScreenWidth/grid))-(ScreenWidth/grid),((j+1)*(ScreenHeight/grid))-(ScreenHeight/grid),i*(ScreenWidth/grid),(j+1)*(ScreenHeight/grid)
- COLOR 0,0,0
- DRAWTEXT STR$(gr(i,j+1)),(i*(ScreenWidth/grid))-(ScreenWidth/grid),((j+1)*(ScreenHeight/grid))-(ScreenHeight/grid)
- ENDIF
- IF gr(i-1,j)=gr(i,j) THEN
- a=a+1
- gr(i,j)=INT(1+(RND*values))
- gr(i-1,j)=INT(1+(RND*values))
- COLOR r(gr(i-1,j)),g(gr(i-1,j)),b(gr(i-1,j))
- RECT ((i-1)*(ScreenWidth/grid))-(ScreenWidth/grid),(j*(ScreenHeight/grid))-(ScreenHeight/grid),(i-1)*(ScreenWidth/grid),j*(ScreenHeight/grid)
- COLOR 0,0,0
- DRAWTEXT STR$(gr(i-1,j)),((i-1)*(ScreenWidth/grid))-(ScreenWidth/grid),(j*(ScreenHeight/grid))-(ScreenHeight/grid)
- ENDIF
- COLOR r(gr(i,j)),g(gr(i,j)),b(gr(i,j))
- RECT (i*(ScreenWidth/grid))-(ScreenWidth/grid),(j*(ScreenHeight/grid))-(ScreenHeight/grid),i*(ScreenWidth/grid),j*(ScreenHeight/grid)
- COLOR 0,0,0
- DRAWTEXT STR$(gr(i,j)),(i*(ScreenWidth/grid))-(ScreenWidth/grid),(j*(ScreenHeight/grid))-(ScreenHeight/grid)
- ' ENDDRAW
- NEXT
- NEXT
- SLEEP 0.001
- ENDDRAW
- IF a<>0 THEN
- GOTO loopA
- ENDIF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement