2019-11-23 16:33:25 +03:00
|
|
|
module main
|
2020-10-26 14:14:21 +03:00
|
|
|
|
2019-06-24 15:58:47 +03:00
|
|
|
import time
|
2019-11-23 16:33:25 +03:00
|
|
|
import automaton
|
2019-06-24 15:58:47 +03:00
|
|
|
|
2020-10-26 14:14:21 +03:00
|
|
|
fn print_automaton(a &automaton.Automaton) {
|
|
|
|
for y := 1; y < a.field.maxy; y++ {
|
2019-06-24 15:58:47 +03:00
|
|
|
mut s := ' '
|
2020-10-26 14:14:21 +03:00
|
|
|
for x := 1; x < a.field.maxx; x++ {
|
|
|
|
cell := a.field.get(x, y)
|
2019-11-23 16:33:25 +03:00
|
|
|
s += if cell == 1 { '@' } else { '.' }
|
2019-06-24 15:58:47 +03:00
|
|
|
}
|
|
|
|
println(s)
|
|
|
|
}
|
|
|
|
println('')
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2019-11-23 16:33:25 +03:00
|
|
|
mut a := automaton.gun()
|
2019-06-24 15:58:47 +03:00
|
|
|
for {
|
2019-11-23 16:33:25 +03:00
|
|
|
a.update()
|
|
|
|
print_automaton(a)
|
2021-02-21 18:05:03 +03:00
|
|
|
time.wait(100 * time.millisecond)
|
2019-06-24 15:58:47 +03:00
|
|
|
}
|
|
|
|
}
|