aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/old/examples/game_of_life/life.v
blob: 0f3b7c7ef0a7e1caca4fed5a4dcfd3a2d03b6b29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module main

import time
import automaton

fn print_automaton(a &automaton.Automaton) {
	for y := 1; y < a.field.maxy; y++ {
		mut s := '    '
		for x := 1; x < a.field.maxx; x++ {
			cell := a.field.get(x, y)
			s += if cell == 1 { '@' } else { '.' }
		}
		println(s)
	}
	println('')
}

fn main() {
	mut a := automaton.gun()
	for {
		a.update()
		print_automaton(a)
		time.sleep(100 * time.millisecond)
	}
}