2019-11-23 16:33:25 +03:00
|
|
|
module main
|
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
|
|
|
|
2019-11-23 16:33:25 +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 := ' '
|
2019-11-23 16:33:25 +03:00
|
|
|
for x := 1; x<a.field.maxx; x++ {
|
|
|
|
cell := a.field.get(x,y)
|
|
|
|
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)
|
2019-06-27 20:02:47 +03:00
|
|
|
time.sleep_ms(100)
|
2019-06-24 15:58:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|