You are not logged in. login register
Game conn4
name conn4
creator admin
number of roles 2
stylesheet chess_like/chess_like_automatic.xsl
GDL v1
enabled
matches show matches
statistics show game statistics
description

Game Description

; Connect 4
;; The Pirates 
;;  Joseph Baker-Malone
;;  Yi Lang Mok
;;  Adam Reichert
;;
;; Below is an implementation of the game
;; Connect 4.
;;


;; Init two players
(role white) ;; Marks with x
(role black) ;; Marks with o

;; Setup empty board. (cell x y mark) 6 is top
(init (cell 1 1 b))
(init (cell 1 2 b))
(init (cell 1 3 b))
(init (cell 1 4 b))
(init (cell 1 5 b))
(init (cell 1 6 b))
(init (cell 2 1 b))
(init (cell 2 2 b))
(init (cell 2 3 b))
(init (cell 2 4 b))
(init (cell 2 5 b))
(init (cell 2 6 b))
(init (cell 3 1 b))
(init (cell 3 2 b))
(init (cell 3 3 b))
(init (cell 3 4 b))
(init (cell 3 5 b))
(init (cell 3 6 b))
(init (cell 4 1 b))
(init (cell 4 2 b))
(init (cell 4 3 b))
(init (cell 4 4 b))
(init (cell 4 5 b))
(init (cell 4 6 b))
(init (cell 5 1 b))
(init (cell 5 2 b))
(init (cell 5 3 b))
(init (cell 5 4 b))
(init (cell 5 5 b))
(init (cell 5 6 b))
(init (cell 6 1 b))
(init (cell 6 2 b))
(init (cell 6 3 b))
(init (cell 6 4 b))
(init (cell 6 5 b))
(init (cell 6 6 b))
(init (cell 7 1 b))
(init (cell 7 2 b))
(init (cell 7 3 b))
(init (cell 7 4 b))
(init (cell 7 5 b))
(init (cell 7 6 b))

;; Choose white to lead
(init (control white))

;; Set up math.
(succ 1 2)
(succ 2 3)
(succ 3 4)
(succ 4 5)
(succ 5 6)
(succ 6 7)

;; Cell Marked -- not empty
(<= (cm ?c ?r)
    (or (true (cell ?c ?r x))
	(true (cell ?c ?r o))))

;; Useful test for rows and columns
(<= (sequential ?a ?b ?c ?d)
    (succ ?a ?b)
    (succ ?b ?c)
    (succ ?c ?d))

;; Is r the top unused of column c
(<= (top-unused ?c ?r)
    (true (cell ?c ?r b))
    (cm ?c ?s)
    (succ ?s ?r))
    
(<= (top-unused ?c 1)
	(true (cell ?c 1 b)))

;; Link drop and plays
(<= (plays-on ?c ?r)
    (does ?x (drop ?c))
    (top-unused ?c ?r))

;; Frame Axioms -- cells stay marked
(<= (next (cell ?c ?r ?x))
    (true (cell ?c ?r ?x))
    (not (plays-on ?c ?r)))

;; Change Hands
(<= (next (control white))
    (true (control black)))
(<= (next (control black))
    (true (control white)))

;; Moves
(<= (legal ?x (drop ?c))
    (true (cell ?c 6 b))
    (true (control ?x)))
(<= (legal white noop)
	(true (control black)))
(<= (legal black noop)
    (true (control white)))

;; Frame Axioms for moves.
(<= (next (cell ?c ?r x))
    (does white (drop ?c))
    (top-unused ?c ?r))
(<= (next (cell ?c ?r o))
    (does black (drop ?c))
    (top-unused ?c ?r))

;; Winning
(<= (row ?x)
    (sequential ?a ?b ?c ?d)
    (true (cell ?a ?r ?x))
    (true (cell ?b ?r ?x))
    (true (cell ?c ?r ?x))
    (true (cell ?d ?r ?x)))
(<= (col  ?x)
    (sequential ?a ?b ?c ?d)
    (true (cell ?e ?a ?x))
    (true (cell ?e ?b ?x))
    (true (cell ?e ?c ?x))
    (true (cell ?e ?d ?x)))
(<= (diag1 ?x)
    (sequential ?a ?b ?c ?d)
    (sequential ?e ?f ?g ?h)
    (true (cell ?a ?e ?x))
    (true (cell ?b ?f ?x))
    (true (cell ?c ?g ?x))
    (true (cell ?d ?h ?x)))
(<= (diag2 ?x)
    (sequential ?a ?b ?c ?d)
    (sequential ?e ?f ?g ?h)
    (true (cell ?a ?h ?x))
    (true (cell ?b ?g ?x))
    (true (cell ?c ?f ?x))
    (true (cell ?d ?e ?x)))
(<= (connfour ?x)
    (or (col ?x)
	(row ?x)
	(diag1 ?x)
	(diag2 ?x)))

;; Goals
(<= (goal ?x 50)
    (not (connfour x))
    (not (connfour o))
    (role ?x))
(<= (goal white 100)
    (connfour x))
(<= (goal black 0)
    (connfour x))
(<= (goal white 0)
    (connfour o))
(<= (goal black 100)
    (connfour o))

;; End
(<= terminal
    (or (connfour x)
	(connfour o)))
(<= (not-filled)
    (true (cell ?c 6 b)))
(<= terminal
    (not (not-filled)))

sees_XML(...) rules

(<= (sees_xml random ?t) (true ?t))
(<= (sees_xml ?p ?t) (role ?p) (distinct ?p random) (true ?t))