2019-11-23 14:33:25 +01:00
|
|
|
module main
|
2019-06-24 14:58:47 +02:00
|
|
|
import time
|
2019-11-23 14:33:25 +01:00
|
|
|
import automaton
|
2019-06-24 14:58:47 +02:00
|
|
|
|
2019-11-23 14:33:25 +01:00
|
|
|
fn print_automaton(a &automaton.Automaton){
|
|
|
|
for y := 1; y<a.field.maxy; y++ {
|
2019-06-24 14:58:47 +02:00
|
|
|
mut s := ' '
|
2019-11-23 14:33:25 +01:00
|
|
|
for x := 1; x<a.field.maxx; x++ {
|
|
|
|
cell := a.field.get(x,y)
|
|
|
|
s += if cell == 1 { '@' } else { '.' }
|
2019-06-24 14:58:47 +02:00
|
|
|
}
|
|
|
|
println(s)
|
|
|
|
}
|
|
|
|
println('')
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2019-11-23 14:33:25 +01:00
|
|
|
mut a := automaton.gun()
|
2019-06-24 14:58:47 +02:00
|
|
|
for {
|
2019-11-23 14:33:25 +01:00
|
|
|
a.update()
|
|
|
|
print_automaton(a)
|
2019-06-27 19:02:47 +02:00
|
|
|
time.sleep_ms(100)
|
2019-06-24 14:58:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|