Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,69 +0,0 @@
|
|||
with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random;
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Forest_Fire is
|
||||
type Cell is (Empty, Tree, Fire);
|
||||
type Board is array (Positive range <>, Positive range <>) of Cell;
|
||||
procedure Step (S : in out Board; P, F : Float; Dice : Generator) is
|
||||
function "+" (Left : Boolean; Right : Cell) return Boolean is
|
||||
begin
|
||||
return Left or else Right = Fire;
|
||||
end "+";
|
||||
function "+" (Left, Right : Cell) return Boolean is
|
||||
begin
|
||||
return Left = Fire or else Right = Fire;
|
||||
end "+";
|
||||
Above : array (S'Range (2)) of Cell := (others => Empty);
|
||||
Left_Up, Up, Left : Cell;
|
||||
begin
|
||||
for Row in S'First (1) + 1..S'Last (1) - 1 loop
|
||||
Left_Up := Empty;
|
||||
Up := Empty;
|
||||
Left := Empty;
|
||||
for Column in S'First (2) + 1..S'Last (2) - 1 loop
|
||||
Left_Up := Up;
|
||||
Up := Above (Column);
|
||||
Above (Column) := S (Row, Column);
|
||||
case S (Row, Column) is
|
||||
when Empty =>
|
||||
if Random (Dice) < P then
|
||||
S (Row, Column) := Tree;
|
||||
end if;
|
||||
when Tree =>
|
||||
if Left_Up + Up + Above (Column + 1) +
|
||||
Left + S (Row, Column) + S (Row, Column + 1) +
|
||||
S (Row + 1, Column - 1) + S (Row + 1, Column) + S (Row + 1, Column + 1)
|
||||
or else Random (Dice) < F then
|
||||
S (Row, Column) := Fire;
|
||||
end if;
|
||||
when Fire =>
|
||||
S (Row, Column) := Empty;
|
||||
end case;
|
||||
Left := Above (Column);
|
||||
end loop;
|
||||
end loop;
|
||||
end Step;
|
||||
procedure Put (S : Board) is
|
||||
begin
|
||||
for Row in S'First (1) + 1..S'Last (1) - 1 loop
|
||||
for Column in S'First (2) + 1..S'Last (2) - 1 loop
|
||||
case S (Row, Column) is
|
||||
when Empty => Put (' ');
|
||||
when Tree => Put ('Y');
|
||||
when Fire => Put ('#');
|
||||
end case;
|
||||
end loop;
|
||||
New_Line;
|
||||
end loop;
|
||||
end Put;
|
||||
|
||||
Dice : Generator;
|
||||
Forest : Board := (1..10 => (1..40 => Empty));
|
||||
begin
|
||||
Reset (Dice);
|
||||
for I in 1..10 loop
|
||||
Step (Forest, 0.3, 0.1, Dice);
|
||||
Put_Line ("-------------" & Integer'Image (I) & " -------------");
|
||||
Put (Forest);
|
||||
end loop;
|
||||
end Forest_Fire;
|
||||
|
|
@ -1,19 +1,34 @@
|
|||
100 FOR I = 17239 TO 17493
|
||||
110 READ B
|
||||
120 POKE I,B
|
||||
130 NEXT
|
||||
140 CALL 17239
|
||||
150 END
|
||||
160 DATA162,23,138,32,71,248,165,38,157,60,3,165,39,157,84,3,202,16,239,162,96
|
||||
170 DATA134,249,134,1,160,0,132,0,152,145,0,200,208,251,232,134,1,224,128,208
|
||||
180 DATA244,44,86,192,44,82,192,44,84,192,44,80,192,32,50,248,162,0,134,0,169
|
||||
190 DATA41,133,2,133,254,169,83,133,4,165,249,133,1,133,3,133,5,73,16,133,255
|
||||
200 DATA133,249,138,134,45,74,168,169,15,144,2,105,224,133,46,185,60,3,133,38
|
||||
210 DATA185,84,3,133,39,160,1,132,44,177,2,145,254,240,79,16,93,169,0,164,44
|
||||
220 DATA145,254,136,81,38,37,46,81,38,145,38,164,44,200,192,41,208,224,165,2
|
||||
230 DATA133,0,165,3,133,1,165,4,133,2,133,254,24,105,42,133,4,165,5,73,16
|
||||
240 DATA133,255,73,16,133,3,105,0,133,5,166,45,232,224,48,208,159,44,0,192
|
||||
250 DATA48,3,76,144,67,44,16,192,44,81,192,96,198,8,208,190,169,101,133,8,169
|
||||
260 DATA68,208,169,169,153,208,165,198,6,208,14,198,7,208,10,169,23,133,6,169
|
||||
270 DATA39,133,7,208,234,177,0,17,4,136,17,0,17,2,17,4,200,200,17,0,17,2,17,4
|
||||
280 DATA48,213,16,137,41
|
||||
100 FOR I = 17239 TO 17812
|
||||
110 READ B
|
||||
120 POKE I,B
|
||||
130 NEXT
|
||||
140 CALL 17239
|
||||
150 END
|
||||
160DATA32,166,68,133,44,169,76,133,40,162,0,138,32,40,0,165,38,157,0,80,165,39
|
||||
170DATA157,25,80,160,0,152,145,38,200,192,40,208,249,232,228,44,208,227,32,82
|
||||
180DATA68,32,91,68,162,96,134,47,134,49,160,0,132,48,152,145,48,200,208,251,232
|
||||
190DATA134,49,224,128,208,244,162,0,134,48,169,41,133,50,133,54,169,83,133,52
|
||||
200DATA165,47,133,49,133,51,133,53,73,16,133,55,133,47,138,134,44,74,168,169,15
|
||||
210DATA144,2,105,224,133,45,185,0,80,133,38,185,25,80,133,39,160,1,132,43,177
|
||||
220DATA50,145,54,240,70,16,83,169,0,164,43,145,54,136,81,38,37,45,81,38,145,38
|
||||
230DATA164,43,200,192,41,208,224,165,50,133,48,165,51,133,49,165,52,133,50,133
|
||||
240DATA54,24,105,42,133,52,165,53,73,16,133,55,73,16,133,51,105,0,133,53,166,44
|
||||
250DATA232,224,48,208,159,32,133,68,76,156,67,198,40,208,199,32,91,68,169,68
|
||||
260DATA208,179,169,153,208,175,198,41,208,9,198,42,208,5,32,82,68,208,239,177
|
||||
270DATA48,17,52,136,17,48,17,50,17,52,200,200,17,48,17,50,17,52,48,218,16,152
|
||||
280DATA169,23,133,41,169,39,133,42,96,169,101,133,40,96,169,107,133,41,169,68
|
||||
290DATA133,42,169,25,96,160,0,132,39,10,10,10,133,38,10,38,39,10,38,39,101,38
|
||||
300DATA133,38,165,39,105,4,133,39,96,173,0,224,201,76,208,68,44,0,192,16,20,44
|
||||
310DATA16,192,44,81,192,104,104,162,38,189,0,81,149,0,232,224,56,208,246,96,162
|
||||
320DATA38,181,0,157,0,81,232,224,56,208,246,173,0,224,201,76,208,50,44,86,192
|
||||
330DATA44,82,192,44,84,192,44,80,192,169,71,133,41,169,248,133,42,169,24,96,201
|
||||
340DATA133,208,209,165,198,240,205,169,0,133,198,173,22,208,41,239,141,22,208
|
||||
350DATA169,21,141,24,208,208,172,201,133,240,3,76,96,68,169,0,141,32,208,169,0
|
||||
360DATA141,33,208,169,5,141,34,208,169,8,141,35,208,173,22,208,9,16,141,22,208
|
||||
370DATA169,48,133,55,74,74,133,45,173,24,208,41,240,5,45,141,24,208,169,0,133
|
||||
380DATA54,170,32,131,69,169,32,133,54,169,85,32,131,69,169,72,133,54,169,170,32
|
||||
390DATA131,69,165,55,24,105,2,133,55,162,0,134,54,169,0,162,85,32,131,69,169,32
|
||||
400DATA133,54,138,32,131,69,169,72,133,54,169,170,32,131,69,165,55,24,105,2,133
|
||||
410DATA55,169,128,133,54,169,0,162,170,32,131,69,169,160,133,54,169,85,32,131
|
||||
420DATA69,169,200,133,54,138,32,131,69,76,96,68,160,0,145,54,200,192,4,208,249
|
||||
430DATA138,145,54,200,192,8,208,249,96
|
||||
|
|
|
|||
|
|
@ -1,168 +0,0 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. forest-fire.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
*> Probability represents a fraction of 10000.
|
||||
*> For instance, IGNITE-PROB means a tree has a 1 in 10000 chance
|
||||
*> of igniting.
|
||||
78 IGNITE-PROB VALUE 1.
|
||||
78 NEW-TREE-PROB VALUE 100.
|
||||
|
||||
78 EMPTY-PROB VALUE 3333.
|
||||
|
||||
78 AREA-SIZE VALUE 40.
|
||||
|
||||
01 sim-table.
|
||||
03 sim-row OCCURS AREA-SIZE TIMES INDEXED BY row-index.
|
||||
05 sim-area OCCURS AREA-SIZE TIMES
|
||||
INDEXED BY col-index.
|
||||
07 current-status PIC 9.
|
||||
*> The flags correspond to the colours they will
|
||||
*> be displayed as.
|
||||
88 empty VALUE 0. *> Black
|
||||
88 tree VALUE 2. *> Green
|
||||
88 burning VALUE 4. *> Red
|
||||
|
||||
07 next-status PIC 9.
|
||||
88 empty VALUE 0.
|
||||
88 tree VALUE 2.
|
||||
88 burning VALUE 4.
|
||||
|
||||
01 rand-num PIC 9999.
|
||||
|
||||
01 next-row PIC 9(4).
|
||||
01 next-col PIC 9(4).
|
||||
|
||||
01 neighbours-row PIC 9(4).
|
||||
01 neighbours-col PIC 9(4).
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
main-line.
|
||||
*> Seed RANDOM with current time.
|
||||
MOVE FUNCTION RANDOM(FUNCTION CURRENT-DATE (9:8)) TO rand-num
|
||||
|
||||
PERFORM initialise-table
|
||||
PERFORM FOREVER
|
||||
PERFORM show-simulation
|
||||
PERFORM step-simulation
|
||||
END-PERFORM
|
||||
|
||||
GOBACK
|
||||
.
|
||||
|
||||
initialise-table.
|
||||
PERFORM VARYING row-index FROM 1 BY 1
|
||||
UNTIL AREA-SIZE < row-index
|
||||
AFTER col-index FROM 1 BY 1
|
||||
UNTIL AREA-SIZE < col-index
|
||||
PERFORM get-rand-num
|
||||
IF rand-num <= EMPTY-PROB
|
||||
SET empty OF current-status (row-index, col-index)
|
||||
TO TRUE
|
||||
SET empty OF next-status (row-index, col-index)
|
||||
TO TRUE
|
||||
ELSE
|
||||
SET tree OF current-status (row-index, col-index)
|
||||
TO TRUE
|
||||
SET tree OF next-status (row-index, col-index)
|
||||
TO TRUE
|
||||
END-IF
|
||||
END-PERFORM
|
||||
.
|
||||
|
||||
show-simulation.
|
||||
PERFORM VARYING row-index FROM 1 BY 1
|
||||
UNTIL AREA-SIZE < row-index
|
||||
AFTER col-index FROM 1 BY 1
|
||||
UNTIL AREA-SIZE < col-index
|
||||
DISPLAY SPACE AT LINE row-index COLUMN col-index
|
||||
WITH BACKGROUND-COLOR
|
||||
current-status (row-index, col-index)
|
||||
END-PERFORM
|
||||
.
|
||||
|
||||
*> Updates the simulation.
|
||||
step-simulation.
|
||||
PERFORM VARYING row-index FROM 1 BY 1
|
||||
UNTIL AREA-SIZE < row-index
|
||||
AFTER col-index FROM 1 BY 1
|
||||
UNTIL AREA-SIZE < col-index
|
||||
EVALUATE TRUE
|
||||
WHEN empty OF current-status (row-index, col-index)
|
||||
PERFORM get-rand-num
|
||||
IF rand-num <= NEW-TREE-PROB
|
||||
SET tree OF next-status
|
||||
(row-index, col-index) TO TRUE
|
||||
END-IF
|
||||
|
||||
WHEN tree OF current-status (row-index, col-index)
|
||||
PERFORM simulate-tree
|
||||
|
||||
WHEN burning OF current-status
|
||||
(row-index, col-index)
|
||||
SET empty OF next-status (row-index, col-index)
|
||||
TO TRUE
|
||||
END-EVALUATE
|
||||
END-PERFORM
|
||||
|
||||
PERFORM update-statuses.
|
||||
.
|
||||
|
||||
*> Updates a tree tile, assuming row-index and col-index are at
|
||||
*> a tree area.
|
||||
simulate-tree.
|
||||
*> Find the row and column of the bottom-right neighbour.
|
||||
COMPUTE next-row = FUNCTION MIN(row-index + 1, AREA-SIZE)
|
||||
COMPUTE next-col = FUNCTION MIN(col-index + 1, AREA-SIZE)
|
||||
|
||||
COMPUTE neighbours-row = FUNCTION MAX(row-index - 1, 1)
|
||||
COMPUTE neighbours-col = FUNCTION MAX(col-index - 1, 1)
|
||||
|
||||
*> If a neighbour is burning, catch fire.
|
||||
PERFORM VARYING neighbours-row FROM neighbours-row BY 1
|
||||
UNTIL next-row < neighbours-row
|
||||
*> Check if neighbours in a row are on fire.
|
||||
PERFORM VARYING neighbours-col FROM neighbours-col BY 1
|
||||
UNTIL next-col < neighbours-col
|
||||
IF neighbours-row = row-index
|
||||
AND neighbours-col = col-index
|
||||
EXIT PERFORM CYCLE
|
||||
END-IF
|
||||
|
||||
IF burning OF current-status
|
||||
(neighbours-row, neighbours-col)
|
||||
SET burning OF next-status (row-index, col-index)
|
||||
TO TRUE
|
||||
EXIT PARAGRAPH
|
||||
END-IF
|
||||
END-PERFORM
|
||||
|
||||
*> Move neighbours-col back to starting position
|
||||
COMPUTE neighbours-col =
|
||||
FUNCTION MAX(neighbours-col - 3, 1)
|
||||
END-PERFORM
|
||||
|
||||
*> Otherwise, there is a random chance of
|
||||
*> catching fire.
|
||||
PERFORM get-rand-num
|
||||
IF rand-num <= IGNITE-PROB
|
||||
SET burning OF next-status (row-index, col-index) TO TRUE
|
||||
END-IF
|
||||
.
|
||||
|
||||
update-statuses.
|
||||
PERFORM VARYING row-index FROM 1 BY 1
|
||||
UNTIL AREA-SIZE < row-index
|
||||
AFTER col-index FROM 1 BY 1
|
||||
UNTIL AREA-SIZE < col-index
|
||||
MOVE next-status (row-index, col-index)
|
||||
TO current-status (row-index, col-index)
|
||||
END-PERFORM
|
||||
.
|
||||
|
||||
*> Puts a random value between 0 and 9999 in rand-num.
|
||||
get-rand-num.
|
||||
COMPUTE rand-num =
|
||||
FUNCTION MOD(FUNCTION RANDOM * 100000, 10000)
|
||||
.
|
||||
|
|
@ -1,19 +1,34 @@
|
|||
100 FOR I = 17239 TO 17493
|
||||
110 READ B
|
||||
120 POKE I,B
|
||||
130 NEXT
|
||||
140 SYS 17239
|
||||
150 END
|
||||
160 DATA162,23,138,32,71,248,165,38,157,60,3,165,39,157,84,3,202,16,239,162,96
|
||||
170 DATA134,249,134,1,160,0,132,0,152,145,0,200,208,251,232,134,1,224,128,208
|
||||
180 DATA244,44,86,192,44,82,192,44,84,192,44,80,192,32,50,248,162,0,134,0,169
|
||||
190 DATA41,133,2,133,254,169,83,133,4,165,249,133,1,133,3,133,5,73,16,133,255
|
||||
200 DATA133,249,138,134,45,74,168,169,15,144,2,105,224,133,46,185,60,3,133,38
|
||||
210 DATA185,84,3,133,39,160,1,132,44,177,2,145,254,240,79,16,93,169,0,164,44
|
||||
220 DATA145,254,136,81,38,37,46,81,38,145,38,164,44,200,192,41,208,224,165,2
|
||||
230 DATA133,0,165,3,133,1,165,4,133,2,133,254,24,105,42,133,4,165,5,73,16
|
||||
240 DATA133,255,73,16,133,3,105,0,133,5,166,45,232,224,48,208,159,44,0,192
|
||||
250 DATA48,3,76,144,67,44,16,192,44,81,192,96,198,8,208,190,169,101,133,8,169
|
||||
260 DATA68,208,169,169,153,208,165,198,6,208,14,198,7,208,10,169,23,133,6,169
|
||||
270 DATA39,133,7,208,234,177,0,17,4,136,17,0,17,2,17,4,200,200,17,0,17,2,17,4
|
||||
280 DATA48,213,16,137,41
|
||||
100 for i = 17239 to 17812
|
||||
110 read b
|
||||
120 poke i,b
|
||||
130 next
|
||||
140 sys 17239
|
||||
150 end
|
||||
160data32,166,68,133,44,169,76,133,40,162,0,138,32,40,0,165,38,157,0,80,165,39
|
||||
170data157,25,80,160,0,152,145,38,200,192,40,208,249,232,228,44,208,227,32,82
|
||||
180data68,32,91,68,162,96,134,47,134,49,160,0,132,48,152,145,48,200,208,251,232
|
||||
190data134,49,224,128,208,244,162,0,134,48,169,41,133,50,133,54,169,83,133,52
|
||||
200data165,47,133,49,133,51,133,53,73,16,133,55,133,47,138,134,44,74,168,169,15
|
||||
210data144,2,105,224,133,45,185,0,80,133,38,185,25,80,133,39,160,1,132,43,177
|
||||
220data50,145,54,240,70,16,83,169,0,164,43,145,54,136,81,38,37,45,81,38,145,38
|
||||
230data164,43,200,192,41,208,224,165,50,133,48,165,51,133,49,165,52,133,50,133
|
||||
240data54,24,105,42,133,52,165,53,73,16,133,55,73,16,133,51,105,0,133,53,166,44
|
||||
250data232,224,48,208,159,32,133,68,76,156,67,198,40,208,199,32,91,68,169,68
|
||||
260data208,179,169,153,208,175,198,41,208,9,198,42,208,5,32,82,68,208,239,177
|
||||
270data48,17,52,136,17,48,17,50,17,52,200,200,17,48,17,50,17,52,48,218,16,152
|
||||
280data169,23,133,41,169,39,133,42,96,169,101,133,40,96,169,107,133,41,169,68
|
||||
290data133,42,169,25,96,160,0,132,39,10,10,10,133,38,10,38,39,10,38,39,101,38
|
||||
300data133,38,165,39,105,4,133,39,96,173,0,224,201,76,208,68,44,0,192,16,20,44
|
||||
310data16,192,44,81,192,104,104,162,38,189,0,81,149,0,232,224,56,208,246,96,162
|
||||
320data38,181,0,157,0,81,232,224,56,208,246,173,0,224,201,76,208,50,44,86,192
|
||||
330data44,82,192,44,84,192,44,80,192,169,71,133,41,169,248,133,42,169,24,96,201
|
||||
340data133,208,209,165,198,240,205,169,0,133,198,173,22,208,41,239,141,22,208
|
||||
350data169,21,141,24,208,208,172,201,133,240,3,76,96,68,169,0,141,32,208,169,0
|
||||
360data141,33,208,169,5,141,34,208,169,8,141,35,208,173,22,208,9,16,141,22,208
|
||||
370data169,48,133,55,74,74,133,45,173,24,208,41,240,5,45,141,24,208,169,0,133
|
||||
380data54,170,32,131,69,169,32,133,54,169,85,32,131,69,169,72,133,54,169,170,32
|
||||
390data131,69,165,55,24,105,2,133,55,162,0,134,54,169,0,162,85,32,131,69,169,32
|
||||
400data133,54,138,32,131,69,169,72,133,54,169,170,32,131,69,165,55,24,105,2,133
|
||||
410data55,169,128,133,54,169,0,162,170,32,131,69,169,160,133,54,169,85,32,131
|
||||
420data69,169,200,133,54,138,32,131,69,76,96,68,160,0,145,54,200,192,4,208,249
|
||||
430data138,145,54,200,192,8,208,249,96
|
||||
|
|
|
|||
|
|
@ -1,97 +0,0 @@
|
|||
#!/usr/bin/env emacs -script
|
||||
;; -*- lexical-binding: t -*-
|
||||
;; run: ./forest-fire forest-fire.config
|
||||
(require 'cl-lib)
|
||||
;; (setq debug-on-error t)
|
||||
|
||||
(defmacro swap (a b)
|
||||
`(setq ,b (prog1 ,a (setq ,a ,b))))
|
||||
|
||||
(defconst burning ?B)
|
||||
(defconst tree ?t)
|
||||
|
||||
(cl-defstruct world rows cols data)
|
||||
|
||||
(defun new-world (rows cols)
|
||||
;; When allocating the vector add padding so the border will always be empty.
|
||||
(make-world :rows rows :cols cols :data (make-vector (* (1+ rows) (1+ cols)) nil)))
|
||||
|
||||
(defmacro world--rows (w)
|
||||
`(1+ (world-rows ,w)))
|
||||
|
||||
(defmacro world--cols (w)
|
||||
`(1+ (world-cols ,w)))
|
||||
|
||||
(defmacro world-pt (w r c)
|
||||
`(+ (* (mod ,r (world--rows ,w)) (world--cols ,w))
|
||||
(mod ,c (world--cols ,w))))
|
||||
|
||||
(defmacro world-ref (w r c)
|
||||
`(aref (world-data ,w) (world-pt ,w ,r ,c)))
|
||||
|
||||
(defun print-world (world)
|
||||
(dotimes (r (world-rows world))
|
||||
(dotimes (c (world-cols world))
|
||||
(let ((cell (world-ref world r c)))
|
||||
(princ (format "%c" (if (not (null cell))
|
||||
cell
|
||||
?.)))))
|
||||
(terpri)))
|
||||
|
||||
(defun random-probability ()
|
||||
(/ (float (random 1000000)) 1000000))
|
||||
|
||||
(defun initialize-world (world p)
|
||||
(dotimes (r (world-rows world))
|
||||
(dotimes (c (world-cols world))
|
||||
(setf (world-ref world r c) (if (<= (random-probability) p) tree nil)))))
|
||||
|
||||
(defun neighbors-burning (world row col)
|
||||
(let ((n 0))
|
||||
(dolist (offset '((1 . 1) (1 . 0) (1 . -1) (0 . 1) (0 . -1) (-1 . 1) (-1 . 0) (-1 . -1)))
|
||||
(when (eq (world-ref world (+ row (car offset)) (+ col (cdr offset))) burning)
|
||||
(setq n (1+ n))))
|
||||
(> n 0)))
|
||||
|
||||
(defun advance (old new p f)
|
||||
(dotimes (r (world-rows old))
|
||||
(dotimes (c (world-cols old))
|
||||
(cond
|
||||
((eq (world-ref old r c) burning)
|
||||
(setf (world-ref new r c) nil))
|
||||
((null (world-ref old r c))
|
||||
(setf (world-ref new r c) (if (<= (random-probability) p) tree nil)))
|
||||
((eq (world-ref old r c) tree)
|
||||
(setf (world-ref new r c) (if (or (neighbors-burning old r c)
|
||||
(<= (random-probability) f))
|
||||
burning
|
||||
tree)))))))
|
||||
|
||||
(defun read-config (file-name)
|
||||
(with-temp-buffer
|
||||
(insert-file-contents-literally file-name)
|
||||
(read (current-buffer))))
|
||||
|
||||
(defun get-config (key config)
|
||||
(let ((val (assoc key config)))
|
||||
(if (null val)
|
||||
(error (format "missing value for %s" key))
|
||||
(cdr val))))
|
||||
|
||||
(defun simulate-forest (file-name)
|
||||
(let* ((config (read-config file-name))
|
||||
(rows (get-config 'rows config))
|
||||
(cols (get-config 'cols config))
|
||||
(skip (get-config 'skip config))
|
||||
(a (new-world rows cols))
|
||||
(b (new-world rows cols)))
|
||||
(initialize-world a (get-config 'tree config))
|
||||
(dotimes (time (get-config 'time config))
|
||||
(when (or (and (> skip 0) (= (mod time skip) 0))
|
||||
(<= skip 0))
|
||||
(princ (format "* time %d\n" time))
|
||||
(print-world a))
|
||||
(advance a b (get-config 'p config) (get-config 'f config))
|
||||
(swap a b))))
|
||||
|
||||
(simulate-forest (elt command-line-args-left 0))
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
((rows . 10)
|
||||
(cols . 45)
|
||||
(time . 100)
|
||||
(skip . 10)
|
||||
(f . 0.001) ;; probability tree ignites
|
||||
(p . 0.01) ;; probability empty space fills with a tree
|
||||
(tree . 0.5)) ;; initial probability of tree in a new world
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
S ← 60
|
||||
S ← 60
|
||||
Pt ← 0.01
|
||||
Pf ← 0.00005
|
||||
⊞(<Pt ⚂◌◌).⇡S
|
||||
Ns ← [¯1_¯1 ¯1_0 ¯1_1 0_¯1 0_1 1_¯1 1_0 1_1]
|
||||
NsOnFire ← ↯S_S≡(/+=2⬚0⊡+Ns¤)⊙¤☇1⊞⊟.⇡S
|
||||
[⍥(∵⨬(<Pt⚂◌|⨬(+1<Pf⚂|2)>0|⋅0)⟜NsOnFire.)200]
|
||||
⇌≡∵⨬(0_0_0|0_1_0|1_0_0)
|
||||
≡(▽⟜≡▽2) # Upscale
|
||||
Pf ← 0.0005
|
||||
˙⊞(<Pt⋅⋅⚂)⇡S
|
||||
Ns ← [¯1_¯1 ¯1_0 ¯1_1 0_¯1 0_1 1_¯1 1_0 1_1]
|
||||
NsOnFire ← ↯∞_S≡(/+=2⬚0⊡+Ns¤)⊙¤♭₂˙⊞⊟⇡S
|
||||
[⍥(≡₀⨬(<Pt⋅⚂|⨬(+1<Pf⚂|2)>0|⋅0)⟜⊸NsOnFire)200]
|
||||
⊢≡₁⨬(0_0_0|0_1_0|1_0_0)
|
||||
≡(▽⟜≡▽3) # Upscale
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue