June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,56 +1,104 @@
|
|||
10 PAPER 6: CLS
|
||||
20 DIM n$(20,30)
|
||||
30 LET init=.5
|
||||
40 LET f=.02
|
||||
50 LET p=.05
|
||||
60 PAPER 0
|
||||
70 FOR i=0 TO 31
|
||||
80 PRINT AT 0,i;" "
|
||||
90 PRINT AT 21,i;" "
|
||||
100 NEXT i
|
||||
110 FOR i=0 TO 21
|
||||
120 PRINT AT i,0;" "
|
||||
130 PRINT AT i,31;" "
|
||||
140 NEXT i
|
||||
150 INK 7
|
||||
160 PRINT AT 0,1;"FOREST FIRE for Rosetta Code"
|
||||
170 LET generation=0
|
||||
180 PRINT AT 21,1;"Generation 0"
|
||||
190 LET trees=0
|
||||
200 PRINT AT 21,22;"Cover"
|
||||
210 FOR i=1 TO 20
|
||||
220 FOR j=1 TO 30
|
||||
230 IF RND<init THEN PAPER 4: INK 7: PRINT AT i,j;"T": LET trees=trees+1
|
||||
240 NEXT j
|
||||
250 NEXT i
|
||||
260 LET generation=generation+1
|
||||
270 INK 7
|
||||
280 PAPER 0
|
||||
290 PRINT AT 21,12;generation
|
||||
300 PRINT AT 21,28;" "
|
||||
310 PRINT AT 21,28;INT (trees/6+.5);"%"
|
||||
320 FOR i=1 TO 20
|
||||
330 FOR j=1 TO 30
|
||||
340 LET n$(i,j)=SCREEN$ (i,j)
|
||||
350 IF SCREEN$ (i,j)="B" THEN LET n$(i,j)=" ": GO TO 450
|
||||
360 IF SCREEN$ (i,j)="T" THEN GO TO 390
|
||||
370 IF RND<=p THEN LET n$(i,j)="T"
|
||||
380 GO TO 450
|
||||
390 FOR k=i-1 TO i+1
|
||||
400 FOR l=j-1 TO j+1
|
||||
410 IF SCREEN$ (k,l)="B" THEN LET n$(i,j)="B": LET k=i+2: LET l=j+2
|
||||
420 NEXT l
|
||||
430 NEXT k
|
||||
440 IF RND<=f THEN LET n$(i,j)="B"
|
||||
450 NEXT j
|
||||
460 NEXT i
|
||||
470 LET trees=0
|
||||
480 FOR i=1 TO 20
|
||||
490 FOR j=1 TO 30
|
||||
500 IF n$(i,j)="T" THEN INK 7: PAPER 4: PRINT AT i,j;"T": LET trees=trees+1: GO TO 540
|
||||
510 IF n$(i,j)="B" THEN INK 6: PAPER 2: PRINT AT i,j;"B": GO TO 540
|
||||
520 PAPER 6
|
||||
530 PRINT AT i,j;" "
|
||||
540 NEXT j
|
||||
550 NEXT i
|
||||
560 GO TO 260
|
||||
Public Class ForestFire
|
||||
Private _forest(,) As ForestState
|
||||
Private _isBuilding As Boolean
|
||||
Private _bm As Bitmap
|
||||
Private _gen As Integer
|
||||
Private _sw As Stopwatch
|
||||
|
||||
Private Const _treeStart As Double = 0.5
|
||||
Private Const _f As Double = 0.00001
|
||||
Private Const _p As Double = 0.001
|
||||
|
||||
Private Const _winWidth As Integer = 300
|
||||
Private Const _winHeight As Integer = 300
|
||||
|
||||
Private Enum ForestState
|
||||
Empty
|
||||
Burning
|
||||
Tree
|
||||
End Enum
|
||||
|
||||
Private Sub ForestFire_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
||||
Me.ClientSize = New Size(_winWidth, _winHeight)
|
||||
ReDim _forest(_winWidth, _winHeight)
|
||||
|
||||
Dim rnd As New Random()
|
||||
For i As Integer = 0 To _winHeight - 1
|
||||
For j As Integer = 0 To _winWidth - 1
|
||||
_forest(j, i) = IIf(rnd.NextDouble <= _treeStart, ForestState.Tree, ForestState.Empty)
|
||||
Next
|
||||
Next
|
||||
|
||||
_sw = New Stopwatch
|
||||
_sw.Start()
|
||||
DrawForest()
|
||||
Timer1.Start()
|
||||
End Sub
|
||||
|
||||
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
|
||||
If _isBuilding Then Exit Sub
|
||||
|
||||
_isBuilding = True
|
||||
GetNextGeneration()
|
||||
|
||||
DrawForest()
|
||||
_isBuilding = False
|
||||
End Sub
|
||||
|
||||
Private Sub GetNextGeneration()
|
||||
Dim forestCache(_winWidth, _winHeight) As ForestState
|
||||
Dim rnd As New Random()
|
||||
|
||||
For i As Integer = 0 To _winHeight - 1
|
||||
For j As Integer = 0 To _winWidth - 1
|
||||
Select Case _forest(j, i)
|
||||
Case ForestState.Tree
|
||||
If forestCache(j, i) <> ForestState.Burning Then
|
||||
forestCache(j, i) = IIf(rnd.NextDouble <= _f, ForestState.Burning, ForestState.Tree)
|
||||
End If
|
||||
|
||||
Case ForestState.Burning
|
||||
For i2 As Integer = i - 1 To i + 1
|
||||
If i2 = -1 OrElse i2 >= _winHeight Then Continue For
|
||||
For j2 As Integer = j - 1 To j + 1
|
||||
If j2 = -1 OrElse i2 >= _winWidth Then Continue For
|
||||
If _forest(j2, i2) = ForestState.Tree Then forestCache(j2, i2) = ForestState.Burning
|
||||
Next
|
||||
Next
|
||||
forestCache(j, i) = ForestState.Empty
|
||||
|
||||
Case Else
|
||||
forestCache(j, i) = IIf(rnd.NextDouble <= _p, ForestState.Tree, ForestState.Empty)
|
||||
End Select
|
||||
Next
|
||||
Next
|
||||
|
||||
_forest = forestCache
|
||||
_gen += 1
|
||||
End Sub
|
||||
|
||||
Private Sub DrawForest()
|
||||
Dim bmCache As New Bitmap(_winWidth, _winHeight)
|
||||
|
||||
For i As Integer = 0 To _winHeight - 1
|
||||
For j As Integer = 0 To _winWidth - 1
|
||||
Select Case _forest(j, i)
|
||||
Case ForestState.Tree
|
||||
bmCache.SetPixel(j, i, Color.Green)
|
||||
|
||||
Case ForestState.Burning
|
||||
bmCache.SetPixel(j, i, Color.Red)
|
||||
End Select
|
||||
Next
|
||||
Next
|
||||
|
||||
_bm = bmCache
|
||||
Me.Refresh()
|
||||
End Sub
|
||||
|
||||
Private Sub ForestFire_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
|
||||
e.Graphics.DrawImage(_bm, 0, 0)
|
||||
|
||||
Me.Text = "Gen " & _gen.ToString() & " @ " & (_gen / (_sw.ElapsedMilliseconds / 1000)).ToString("F02") & " FPS: Forest Fire"
|
||||
End Sub
|
||||
End Class
|
||||
|
|
|
|||
56
Task/Forest-fire/BASIC/forest-fire-11.basic
Normal file
56
Task/Forest-fire/BASIC/forest-fire-11.basic
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
10 PAPER 6: CLS
|
||||
20 DIM n$(20,30)
|
||||
30 LET init=.5
|
||||
40 LET f=.02
|
||||
50 LET p=.05
|
||||
60 PAPER 0
|
||||
70 FOR i=0 TO 31
|
||||
80 PRINT AT 0,i;" "
|
||||
90 PRINT AT 21,i;" "
|
||||
100 NEXT i
|
||||
110 FOR i=0 TO 21
|
||||
120 PRINT AT i,0;" "
|
||||
130 PRINT AT i,31;" "
|
||||
140 NEXT i
|
||||
150 INK 7
|
||||
160 PRINT AT 0,1;"FOREST FIRE for Rosetta Code"
|
||||
170 LET generation=0
|
||||
180 PRINT AT 21,1;"Generation 0"
|
||||
190 LET trees=0
|
||||
200 PRINT AT 21,22;"Cover"
|
||||
210 FOR i=1 TO 20
|
||||
220 FOR j=1 TO 30
|
||||
230 IF RND<init THEN PAPER 4: INK 7: PRINT AT i,j;"T": LET trees=trees+1
|
||||
240 NEXT j
|
||||
250 NEXT i
|
||||
260 LET generation=generation+1
|
||||
270 INK 7
|
||||
280 PAPER 0
|
||||
290 PRINT AT 21,12;generation
|
||||
300 PRINT AT 21,28;" "
|
||||
310 PRINT AT 21,28;INT (trees/6+.5);"%"
|
||||
320 FOR i=1 TO 20
|
||||
330 FOR j=1 TO 30
|
||||
340 LET n$(i,j)=SCREEN$ (i,j)
|
||||
350 IF SCREEN$ (i,j)="B" THEN LET n$(i,j)=" ": GO TO 450
|
||||
360 IF SCREEN$ (i,j)="T" THEN GO TO 390
|
||||
370 IF RND<=p THEN LET n$(i,j)="T"
|
||||
380 GO TO 450
|
||||
390 FOR k=i-1 TO i+1
|
||||
400 FOR l=j-1 TO j+1
|
||||
410 IF SCREEN$ (k,l)="B" THEN LET n$(i,j)="B": LET k=i+2: LET l=j+2
|
||||
420 NEXT l
|
||||
430 NEXT k
|
||||
440 IF RND<=f THEN LET n$(i,j)="B"
|
||||
450 NEXT j
|
||||
460 NEXT i
|
||||
470 LET trees=0
|
||||
480 FOR i=1 TO 20
|
||||
490 FOR j=1 TO 30
|
||||
500 IF n$(i,j)="T" THEN INK 7: PAPER 4: PRINT AT i,j;"T": LET trees=trees+1: GO TO 540
|
||||
510 IF n$(i,j)="B" THEN INK 6: PAPER 2: PRINT AT i,j;"B": GO TO 540
|
||||
520 PAPER 6
|
||||
530 PRINT AT i,j;" "
|
||||
540 NEXT j
|
||||
550 NEXT i
|
||||
560 GO TO 260
|
||||
|
|
@ -1,104 +1,72 @@
|
|||
Public Class ForestFire
|
||||
Private _forest(,) As ForestState
|
||||
Private _isBuilding As Boolean
|
||||
Private _bm As Bitmap
|
||||
Private _gen As Integer
|
||||
Private _sw As Stopwatch
|
||||
|
||||
Private Const _treeStart As Double = 0.5
|
||||
Private Const _f As Double = 0.00001
|
||||
Private Const _p As Double = 0.001
|
||||
|
||||
Private Const _winWidth As Integer = 300
|
||||
Private Const _winHeight As Integer = 300
|
||||
|
||||
Private Enum ForestState
|
||||
Empty
|
||||
Burning
|
||||
Tree
|
||||
End Enum
|
||||
|
||||
Private Sub ForestFire_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
||||
Me.ClientSize = New Size(_winWidth, _winHeight)
|
||||
ReDim _forest(_winWidth, _winHeight)
|
||||
|
||||
Dim rnd As New Random()
|
||||
For i As Integer = 0 To _winHeight - 1
|
||||
For j As Integer = 0 To _winWidth - 1
|
||||
_forest(j, i) = IIf(rnd.NextDouble <= _treeStart, ForestState.Tree, ForestState.Empty)
|
||||
Next
|
||||
Next
|
||||
|
||||
_sw = New Stopwatch
|
||||
_sw.Start()
|
||||
DrawForest()
|
||||
Timer1.Start()
|
||||
End Sub
|
||||
|
||||
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
|
||||
If _isBuilding Then Exit Sub
|
||||
|
||||
_isBuilding = True
|
||||
GetNextGeneration()
|
||||
|
||||
DrawForest()
|
||||
_isBuilding = False
|
||||
End Sub
|
||||
|
||||
Private Sub GetNextGeneration()
|
||||
Dim forestCache(_winWidth, _winHeight) As ForestState
|
||||
Dim rnd As New Random()
|
||||
|
||||
For i As Integer = 0 To _winHeight - 1
|
||||
For j As Integer = 0 To _winWidth - 1
|
||||
Select Case _forest(j, i)
|
||||
Case ForestState.Tree
|
||||
If forestCache(j, i) <> ForestState.Burning Then
|
||||
forestCache(j, i) = IIf(rnd.NextDouble <= _f, ForestState.Burning, ForestState.Tree)
|
||||
End If
|
||||
|
||||
Case ForestState.Burning
|
||||
For i2 As Integer = i - 1 To i + 1
|
||||
If i2 = -1 OrElse i2 >= _winHeight Then Continue For
|
||||
For j2 As Integer = j - 1 To j + 1
|
||||
If j2 = -1 OrElse i2 >= _winWidth Then Continue For
|
||||
If _forest(j2, i2) = ForestState.Tree Then forestCache(j2, i2) = ForestState.Burning
|
||||
Next
|
||||
Next
|
||||
forestCache(j, i) = ForestState.Empty
|
||||
|
||||
Case Else
|
||||
forestCache(j, i) = IIf(rnd.NextDouble <= _p, ForestState.Tree, ForestState.Empty)
|
||||
End Select
|
||||
Next
|
||||
Next
|
||||
|
||||
_forest = forestCache
|
||||
_gen += 1
|
||||
End Sub
|
||||
|
||||
Private Sub DrawForest()
|
||||
Dim bmCache As New Bitmap(_winWidth, _winHeight)
|
||||
|
||||
For i As Integer = 0 To _winHeight - 1
|
||||
For j As Integer = 0 To _winWidth - 1
|
||||
Select Case _forest(j, i)
|
||||
Case ForestState.Tree
|
||||
bmCache.SetPixel(j, i, Color.Green)
|
||||
|
||||
Case ForestState.Burning
|
||||
bmCache.SetPixel(j, i, Color.Red)
|
||||
End Select
|
||||
Next
|
||||
Next
|
||||
|
||||
_bm = bmCache
|
||||
Me.Refresh()
|
||||
End Sub
|
||||
|
||||
Private Sub ForestFire_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
|
||||
e.Graphics.DrawImage(_bm, 0, 0)
|
||||
|
||||
Me.Text = "Gen " & _gen.ToString() & " @ " & (_gen / (_sw.ElapsedMilliseconds / 1000)).ToString("F02") & " FPS: Forest Fire"
|
||||
End Sub
|
||||
End Class
|
||||
10 DIM F$(20,30)
|
||||
20 DIM N$(20,30)
|
||||
30 LET INIT=.5
|
||||
40 LET F=.02
|
||||
50 LET P=.05
|
||||
60 PRINT AT 0,1;"[FOREST FIRE FOR ROSETTA CODE]"
|
||||
70 FOR I=0 TO 21
|
||||
80 PRINT AT I,0;"[ ]"
|
||||
90 PRINT AT I,31;"[ ]"
|
||||
100 NEXT I
|
||||
110 FOR I=1 TO 30
|
||||
120 PRINT AT 21,I;"[ ]"
|
||||
130 NEXT I
|
||||
140 LET G=0
|
||||
150 LET T=0
|
||||
160 PRINT AT 21,1;"[GENERATION 0]"
|
||||
170 PRINT AT 21,20;"[COVER]"
|
||||
180 FOR I=1 TO 20
|
||||
190 FOR J=1 TO 30
|
||||
200 IF RND>=INIT THEN GOTO 240
|
||||
210 PRINT AT I,J;"0"
|
||||
220 LET F$(I,J)="0"
|
||||
230 LET T=T+1
|
||||
240 NEXT J
|
||||
250 NEXT I
|
||||
300 PRINT AT 21,26;"[ ]"
|
||||
310 LET N=INT (.5+T/6)
|
||||
320 GOSUB 1000
|
||||
330 PRINT AT 21,26;I$;"[ PC]"
|
||||
340 FOR I=1 TO 20
|
||||
350 PRINT AT I,0;"[>]"
|
||||
360 FOR J=1 TO 30
|
||||
380 IF F$(I,J)<>"[a]" THEN GOTO 410
|
||||
390 LET N$(I,J)=" "
|
||||
400 GOTO 530
|
||||
410 IF F$(I,J)<>" " THEN GOTO 433
|
||||
420 IF RND<=P THEN LET N$(I,J)="0"
|
||||
430 GOTO 530
|
||||
433 LET N$(I,J)=CHR$ (1+CODE F$(I,J))
|
||||
437 IF N$(I,J)>"Z" THEN LET N$(I,J)="£"
|
||||
440 FOR K=I-1 TO I+1
|
||||
450 FOR L=J-1 TO J+1
|
||||
460 IF K=0 OR L=0 OR K=21 OR L=21 THEN GOTO 480
|
||||
470 IF F$(K,L)="[a]" THEN GOTO 510
|
||||
480 NEXT L
|
||||
490 NEXT K
|
||||
500 GOTO 520
|
||||
510 LET N$(I,J)="[a]"
|
||||
520 IF RND<=F THEN LET N$(I,J)="[a]"
|
||||
530 NEXT J
|
||||
540 PRINT AT I,0;"[ ]"
|
||||
550 NEXT I
|
||||
552 LET G=G+1
|
||||
554 LET N=G
|
||||
556 GOSUB 1000
|
||||
558 PRINT AT 21,12;I$
|
||||
560 LET T=0
|
||||
570 FOR I=1 TO 20
|
||||
575 PRINT AT I,31;"[<]"
|
||||
580 FOR J=1 TO 30
|
||||
590 IF N$(I,J)<>"[a]" AND N$(I,J)<>" " THEN LET T=T+1
|
||||
600 NEXT J
|
||||
610 LET F$(I)=N$(I)
|
||||
620 PRINT AT I,1;F$(I)
|
||||
625 PRINT AT I,31;"[ ]"
|
||||
630 GOTO 300
|
||||
1000 LET S$=STR$ N
|
||||
1010 LET I$=""
|
||||
1020 FOR K=1 TO LEN S$
|
||||
1030 LET I$=I$+CHR$ (128+CODE S$(K))
|
||||
1040 NEXT K
|
||||
1050 RETURN
|
||||
|
|
|
|||
64
Task/Forest-fire/Forth/forest-fire.fth
Normal file
64
Task/Forest-fire/Forth/forest-fire.fth
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
30 CONSTANT WIDTH
|
||||
30 CONSTANT HEIGHT
|
||||
WIDTH HEIGHT * CONSTANT SIZE
|
||||
|
||||
1 VALUE SEED
|
||||
: (RAND) ( -- u) \ xorshift generator
|
||||
SEED DUP 13 LSHIFT XOR
|
||||
DUP 17 RSHIFT XOR
|
||||
DUP 5 LSHIFT XOR
|
||||
DUP TO SEED ;
|
||||
10000 CONSTANT RANGE
|
||||
100 CONSTANT GROW
|
||||
1 CONSTANT BURN
|
||||
: RAND ( -- u) (RAND) RANGE MOD ;
|
||||
|
||||
\ Create buffers for world state
|
||||
CREATE A SIZE ALLOT A SIZE ERASE
|
||||
CREATE B SIZE ALLOT B SIZE ERASE
|
||||
|
||||
0 CONSTANT NONE 1 CONSTANT TREE 2 CONSTANT FIRE
|
||||
: NEARBY-FIRE? ( addr u -- t|f)
|
||||
2 -1 DO
|
||||
2 -1 DO
|
||||
J WIDTH * I + OVER + \ calculate an offset
|
||||
DUP 0> OVER SIZE < AND IF
|
||||
>R OVER R> + C@ \ fetch state of the offset cell
|
||||
FIRE = IF UNLOOP UNLOOP DROP DROP TRUE EXIT THEN
|
||||
ELSE DROP THEN
|
||||
LOOP
|
||||
LOOP DROP DROP FALSE ;
|
||||
: GROW? RAND GROW <= ; \ spontaneously sprout?
|
||||
: BURN? RAND BURN <= ; \ spontaneously combust?
|
||||
: STEP ( prev next --) \ Given state in PREV, put next in NEXT
|
||||
>R 0 BEGIN DUP SIZE <
|
||||
WHILE
|
||||
2DUP + C@ CASE
|
||||
FIRE OF NONE ENDOF
|
||||
TREE OF 2DUP NEARBY-FIRE? BURN? OR IF FIRE ELSE TREE THEN ENDOF
|
||||
NONE OF GROW? IF TREE ELSE NONE THEN ENDOF
|
||||
ENDCASE
|
||||
( i next-cell-state) OVER R@ + C! \ commit to next
|
||||
1+ REPEAT R> DROP DROP DROP ;
|
||||
|
||||
: (ESCAPE) 27 EMIT [CHAR] [ EMIT ;
|
||||
: ESCAPE" POSTPONE (ESCAPE) POSTPONE S" POSTPONE TYPE ; IMMEDIATE
|
||||
: CLEAR ESCAPE" H" ;
|
||||
: RETURN ESCAPE" E" ;
|
||||
: RESET ESCAPE" m" ;
|
||||
: .FOREST ( addr --) CLEAR
|
||||
HEIGHT 0 DO
|
||||
WIDTH 0 DO
|
||||
DUP C@ CASE
|
||||
NONE OF SPACE ENDOF
|
||||
TREE OF ESCAPE" 32m" [CHAR] T EMIT RESET ENDOF
|
||||
FIRE OF ESCAPE" 31m" [CHAR] # EMIT RESET ENDOF
|
||||
ENDCASE 1+
|
||||
LOOP RETURN
|
||||
LOOP RESET DROP ;
|
||||
|
||||
: (GO) ( buffer buffer' -- buffer' buffer)
|
||||
2DUP STEP \ step the simulation
|
||||
DUP .FOREST \ print the current state
|
||||
SWAP ; \ prepare for next iteration
|
||||
: GO A B BEGIN (GO) AGAIN ;
|
||||
88
Task/Forest-fire/Ring/forest-fire.ring
Normal file
88
Task/Forest-fire/Ring/forest-fire.ring
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
# Project : Forest fire
|
||||
# Date : 2018/01/13
|
||||
# Author : Gal Zsolt (~ CalmoSoft ~)
|
||||
# Email : <calmosoft@gmail.com>
|
||||
|
||||
|
||||
load "guilib.ring"
|
||||
load "stdlib.ring"
|
||||
|
||||
paint = null
|
||||
|
||||
new qapp
|
||||
{
|
||||
win1 = new qwidget() {
|
||||
setwindowtitle("Forest fire")
|
||||
setgeometry(100,100,500,600)
|
||||
label1 = new qlabel(win1) {
|
||||
setgeometry(10,10,400,400)
|
||||
settext("")
|
||||
}
|
||||
new qpushbutton(win1) {
|
||||
setgeometry(150,500,100,30)
|
||||
settext("draw")
|
||||
setclickevent("draw()")
|
||||
}
|
||||
show()
|
||||
}
|
||||
exec()
|
||||
}
|
||||
|
||||
func draw
|
||||
p1 = new qpicture()
|
||||
color = new qcolor() {
|
||||
setrgb(0,0,255,255)
|
||||
}
|
||||
pen = new qpen() {
|
||||
setcolor(color)
|
||||
setwidth(1)
|
||||
}
|
||||
paint = new qpainter() {
|
||||
begin(p1)
|
||||
setpen(pen)
|
||||
|
||||
pregen = newlist(200,200)
|
||||
newgen = newlist(200,200)
|
||||
|
||||
for gen = 1 to 20
|
||||
see "gen = " + gen + nl
|
||||
for x = 1 to 199
|
||||
for y = 1 to 199
|
||||
switch pregen[x][y]
|
||||
on 0
|
||||
if random(9)/10 > 0.099
|
||||
newgen[x][y] = 1
|
||||
color = new qcolor()
|
||||
color.setrgb(0,128,0,255)
|
||||
pen.setcolor(color)
|
||||
setpen(pen)
|
||||
drawpoint(x,y)
|
||||
ok
|
||||
on 2
|
||||
newgen[x][y] = 0
|
||||
color = new qcolor()
|
||||
color.setrgb(165,42,42,255)
|
||||
pen.setcolor(color)
|
||||
setpen(pen)
|
||||
drawpoint(x,y)
|
||||
on 1
|
||||
if pregen[x][y] = 2 or pregen[x][y] = 2 or pregen[x][y+1] = 2 or
|
||||
pregen[x][y] = 2 or pregen[x][y+1] = 2 or pregen[x+1][y] = 2 or
|
||||
pregen[x+1][y] = 2 or pregen[x+1][y+1] = 2 or random(9)/10 > 0.0999
|
||||
color = new qcolor()
|
||||
color.setrgb(255,0,0,255)
|
||||
pen.setcolor(color)
|
||||
setpen(pen)
|
||||
drawpoint(x,y)
|
||||
newgen[x][y] = 2
|
||||
ok
|
||||
off
|
||||
pregen[x][y] = newgen[x][y]
|
||||
next
|
||||
next
|
||||
next
|
||||
|
||||
endpaint()
|
||||
}
|
||||
label1 { setpicture(p1) show() }
|
||||
return
|
||||
Loading…
Add table
Add a link
Reference in a new issue