Patches, patches, patches...

This commit is contained in:
sachy 2011-12-03 20:13:08 +01:00
parent 7e994ba763
commit 2ca7f88721

View file

@ -1,10 +1,11 @@
globals [w h] globals [w h symbol herbs]
to init to init
clear-all; clear-all;
file-close-all; file-close-all;
set w 0; set w 0;
set h 0; set h 0;
set herbs 0;
set symbol "";
file-open "rawio_cfg"; file-open "rawio_cfg";
resize-world 0 ((read-from-string file-read-line) - 1) (1 - (read-from-string file-read-line)) 0; resize-world 0 ((read-from-string file-read-line) - 1) (1 - (read-from-string file-read-line)) 0;
file-close-all file-close-all
@ -14,7 +15,7 @@ to go
file-open "rawio_map"; file-open "rawio_map";
while [file-at-end? = false] while [file-at-end? = false]
[ [
let symbol file-read-characters 1; set symbol file-read-characters 1;
if (symbol = "\n" or symbol = "\r") and file-at-end? = false if (symbol = "\n" or symbol = "\r") and file-at-end? = false
[ [
set symbol file-read-characters 1; set symbol file-read-characters 1;
@ -24,20 +25,29 @@ to go
if symbol = "x" if symbol = "x"
[ [
ask patch w h [set pcolor green ]; ask patch w h [set pcolor green ];
set herbs herbs + 1
] ]
if symbol = "." if symbol = "."
[ [
ask patch w h [set pcolor black ] ask patch w h [set pcolor black ];
]
if member? symbol ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9"]
[
ask patch w h [set pcolor red ];
] ]
set w w + 1; set w w + 1;
] ]
file-close-all; file-close-all;
set-current-plot "herbs";
set-current-plot-pen "herbs";
plot count patches with [pcolor = green];
tick; tick;
set w 0; set w 0;
set h 0; set h 0;
wait 1; wait 1;
end end
@#$#@#$#@ @#$#@#$#@
GRAPHICS-WINDOW GRAPHICS-WINDOW
111 111
@ -97,6 +107,34 @@ NIL
NIL NIL
NIL NIL
PLOT
91
332
291
482
herbs
NIL
NIL
0.0
10.0
0.0
10.0
true
false
PENS
"herbs" 1.0 0 -16777216 true
MONITOR
17
411
74
456
herbs
count patches with [pcolor = green]
17
1
11
@#$#@#$#@ @#$#@#$#@
WHAT IS IT? WHAT IS IT?
----------- -----------