Not entirely tested but I assume this is working... need tests lol
This commit is contained in:
parent
a3e2c45861
commit
d39811d38e
1 changed files with 19 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
#:use-module (goblins actor-lib sealers)
|
||||
#:use-module (goblins actor-lib selfish-spawn)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (ice-9 rdelim)
|
||||
#:export (^ggg-controller))
|
||||
|
||||
|
@ -62,3 +63,21 @@
|
|||
(array->list x))
|
||||
(format #t "\n"))
|
||||
board))
|
||||
|
||||
(define (board-winner? board mark)
|
||||
(define idxs (iota ggg-size))
|
||||
(define (row-winner? y)
|
||||
(apply eq? mark (map (lambda (x) (board-ref board (list x y))) idxs)))
|
||||
(define (col-winner? x)
|
||||
(apply eq? mark (map (lambda (y) (board-ref board (list x y))) idxs)))
|
||||
(define (diag-winner?)
|
||||
(or
|
||||
(apply eq? mark (map (lambda (x) (board-ref board (list x x))) idxs))
|
||||
(apply eq? mark (map (lambda (x) (board-ref board (list x x))) idxs))))
|
||||
|
||||
(any (lambda (x) (eq? #t x))
|
||||
(cons
|
||||
(diag-winner?)
|
||||
(append
|
||||
(map row-winner? idxs)
|
||||
(map col-winner? idxs)))))
|
||||
|
|
Loading…
Reference in a new issue