;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Nine Board Tic Tac Toe ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Components ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (role xplayer) (role oplayer) (<= (base (mark ?i ?j ?k ?l x)) (index ?i) (index ?j) (index ?k) (index ?l)) (<= (base (mark ?i ?j ?k ?l o)) (index ?i) (index ?j) (index ?k) (index ?l)) (<= (base (currentboard ?i ?j)) (index ?i) (index ?j)) (<= (base (control ?r)) (role ?r)) (<= (input xplayer (play ?i ?j ?k ?l x)) (index ?i) (index ?j) (index ?k) (index ?l)) (<= (input oplayer (play ?i ?j ?k ?l o)) (index ?i) (index ?j) (index ?k) (index ?l)) (<= (input ?r noop) (role ?r)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; init ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (init (control xplayer)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; legal ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (<= (legal xplayer noop) (true (control oplayer))) (<= (legal xplayer (play ?i ?j ?k ?l x)) (true (control xplayer)) firstmove (emptycell ?i ?j ?k ?l)) (<= (legal xplayer (play ?i ?j ?k ?l x)) (true (control xplayer)) (true (currentboard ?i ?j)) (emptycell ?i ?j ?k ?l)) (<= (legal xplayer (play ?i ?j ?k ?l x)) (true (control xplayer)) currentboardclosed (emptycell ?i ?j ?k ?l)) (<= (legal oplayer noop) (true (control xplayer))) (<= (legal oplayer (play ?i ?j ?k ?l o)) (true (control oplayer)) firstmove (emptycell ?i ?j ?k ?l)) (<= (legal oplayer (play ?i ?j ?k ?l o)) (true (control oplayer)) (true (currentboard ?i ?j)) (emptycell ?i ?j ?k ?l)) (<= (legal oplayer (play ?i ?j ?k ?l o)) (true (control oplayer)) currentboardclosed (emptycell ?i ?j ?k ?l)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; next ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (<= (next (mark ?i ?j ?k ?l ?mark)) (does ?player (play ?i ?j ?k ?l ?mark))) (<= (next (mark ?i ?j ?k ?l ?mark)) (true (mark ?i ?j ?k ?l ?mark))) (<= (next (currentboard ?k ?l)) (does ?player (play ?i ?j ?k ?l ?mark))) (<= (next (control xplayer)) (true (control oplayer))) (<= (next (control oplayer)) (true (control xplayer))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; goal ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (<= (goal xplayer 0) (not (line x)) (not (line o)) open) (<= (goal xplayer 100) (line x)) (<= (goal xplayer 50) (not (line x)) (not (line o)) (not open)) (<= (goal xplayer 0) (line o)) (<= (goal oplayer 0) (not (line x)) (not (line o)) open) (<= (goal oplayer 100) (line o)) (<= (goal oplayer 50) (not (line x)) (not (line o)) (not open)) (<= (goal oplayer 0) (line x)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; terminal ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (<= terminal (line x)) (<= terminal (line o)) (<= terminal (not open)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Views ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (<= (row ?i ?j ?k ?mark) (true (mark ?i ?j ?k 1 ?mark)) (true (mark ?i ?j ?k 2 ?mark)) (true (mark ?i ?j ?k 3 ?mark))) (<= (col ?i ?j ?k ?mark) (true (mark ?i ?j 1 ?k ?mark)) (true (mark ?i ?j 2 ?k ?mark)) (true (mark ?i ?j 3 ?k ?mark))) (<= (diag ?i ?j ?mark) (true (mark ?i ?j 1 1 ?mark)) (true (mark ?i ?j 2 2 ?mark)) (true (mark ?i ?j 3 3 ?mark))) (<= (diag ?i ?j ?mark) (true (mark ?i ?j 1 3 ?mark)) (true (mark ?i ?j 2 2 ?mark)) (true (mark ?i ?j 3 1 ?mark))) (<= (line ?mark) (index ?i) (index ?j) (index ?k) (row ?i ?j ?k ?mark)) (<= (line ?mark) (index ?i) (index ?j) (index ?k) (col ?i ?j ?k ?mark)) (<= (line ?mark) (index ?i) (index ?j) (diag ?i ?j ?mark)) (<= (emptycell ?i ?j ?k ?l) (index ?i) (index ?j) (index ?k) (index ?l) (not (true (mark ?i ?j ?k ?l x))) (not (true (mark ?i ?j ?k ?l o)))) (<= open (emptycell ?i ?j ?k ?l)) (<= currentboardclosed (true (currentboard ?i ?j)) (not (emptycell ?i ?j 1 1)) (not (emptycell ?i ?j 1 2)) (not (emptycell ?i ?j 1 3)) (not (emptycell ?i ?j 2 1)) (not (emptycell ?i ?j 2 2)) (not (emptycell ?i ?j 2 3)) (not (emptycell ?i ?j 3 1)) (not (emptycell ?i ?j 3 2)) (not (emptycell ?i ?j 3 3))) (<= firstmove (not (true (currentboard 1 1))) (not (true (currentboard 1 2))) (not (true (currentboard 1 3))) (not (true (currentboard 2 1))) (not (true (currentboard 2 2))) (not (true (currentboard 2 3))) (not (true (currentboard 3 1))) (not (true (currentboard 3 2))) (not (true (currentboard 3 3)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (index 1) (index 2) (index 3) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;