You are not logged in. login register
Game amazons
name amazons
creator stephan
number of roles 2
stylesheet chess_like/chess_like_10x10.xsl
GDL v1
enabled
matches show matches
statistics show game statistics
description The amazons board game
see Game_of_the_Amazons @ Wikipedia

Game Description

; amazons (originally from http://games.stanford.edu:4441/spectator/Showallrules?Match=AMAZONS)
; - goal rules slightly changed to make it valid GDL
; - legal rules fixed so queens don't just move in one direction

(role white)
(role black)
(init (cellholds 4 1 white))
(init (cellholds 7 1 white))
(init (cellholds 1 4 white))
(init (cellholds 10 4 white))
(init (cellholds 1 7 black))
(init (cellholds 10 7 black))
(init (cellholds 4 10 black))
(init (cellholds 7 10 black))
(init (control white))

(<= (legal ?player noop)
    (role ?player)
    (not (true (control ?player))))

(<= (legal ?player ?move)
	(true (control ?player))
    (legalmove ?player ?move))

(<= (next (control white))
    (true (control black)))
(<= (next (control black))
    (true (control white)))

(<= (next (cellholds ?x3 ?y3 arrow))
    (role ?player)
    (does ?player (play ?x1 ?y1 ?x2 ?y2 ?x3 ?y3)))
(<= (next (cellholds ?x2 ?y2 ?player))
    (role ?player)
    (does ?player (play ?x1 ?y1 ?x2 ?y2 ?x3 ?y3)))
(<= (next (cellholds ?xs ?ys ?state))
    (true (cellholds ?xs ?ys ?state))
    (does ?player (play ?x1 ?y1 ?x2 ?y2 ?x3 ?y3))
    (distinctcell ?xs ?ys ?x1 ?y1))

(<= terminal
	(cannot_move ?r)
)

(<= (goal ?r 100)
	(role ?r)
	(cannot_move ?r2)
	(distinct ?r ?r2)
)
(<= (goal ?r 0)
    (cannot_move ?r)
)

(<= (cannot_move ?r)
	(true (control ?r))
    (not (haslegalmove ?r))
)

(<= (haslegalmove ?player)
    (legalmove ?player ?move))

(<= (legalmove ?player (play ?x1 ?y1 ?x2 ?y2 ?x3 ?y3))
    (role ?player)
    (true (cellholds ?x1 ?y1 ?player))
    (queenmove ?x1 ?y1 ?x2 ?y2)
    (queenmove ?x2 ?y2 ?x3 ?y3))

(<= (legalmove ?player (play ?x1 ?y1 ?x2 ?y2 ?x1 ?y1))
    (role ?player)
    (true (cellholds ?x1 ?y1 ?player))
    (queenmove ?x1 ?y1 ?x2 ?y2))

(<= (queenmove ?x1 ?y1 ?x2 ?y2)
	(direction ?dir)
	(directionmove ?dir ?x1 ?y1 ?x2 ?y2))

(<= (directionmove ?dir ?x1 ?y1 ?x2 ?y2)
	(directionstep ?dir ?x1 ?y1 ?x2 ?y2)
	(emptycell ?x2 ?y2))
(<= (directionmove ?dir ?x1 ?y1 ?x3 ?y3)
	(directionstep ?dir ?x1 ?y1 ?x2 ?y2)
	(emptycell ?x2 ?y2)
	(directionmove ?dir ?x2 ?y2 ?x3 ?y3))

(<= (directionstep n ?x ?y1 ?x ?y2)
	(index ?x)
    (++ ?y1 ?y2))
(<= (directionstep s ?x ?y1 ?x ?y2)
	(index ?x)
    (++ ?y2 ?y1))
(<= (directionstep e ?x1 ?y ?x2 ?y)
	(++ ?x1 ?x2)
	(index ?y))
(<= (directionstep w ?x1 ?y ?x2 ?y)
	(++ ?x2 ?x1)
	(index ?y))
(<= (directionstep ne ?x1 ?y1 ?x2 ?y2)
	(++ ?x1 ?x2)
	(++ ?y1 ?y2))
(<= (directionstep sw ?x1 ?y1 ?x2 ?y2)
	(++ ?x2 ?x1)
	(++ ?y2 ?y1))
(<= (directionstep se ?x1 ?y1 ?x2 ?y2)
	(++ ?x1 ?x2)
	(++ ?y2 ?y1))
(<= (directionstep nw ?x1 ?y1 ?x2 ?y2)
	(++ ?x2 ?x1)
	(++ ?y1 ?y2))

(<= (emptycell ?x ?y)
    (cell ?x ?y)
    (not (true (cellholds ?x ?y arrow)))
    (not (true (cellholds ?x ?y white)))
    (not (true (cellholds ?x ?y black))))

(<= (distinctcell ?x1 ?y1 ?x2 ?y2)
    (cell ?x1 ?y1)
    (cell ?x2 ?y2)
    (distinct ?x1 ?x2))
(<= (distinctcell ?x1 ?y1 ?x2 ?y2)
    (cell ?x1 ?y1)
    (cell ?x2 ?y2)
    (distinct ?y1 ?y2))

(<= (cell ?x ?y)
    (index ?x)
    (index ?y))

(direction n)
(direction ne)
(direction e)
(direction se)
(direction s)
(direction sw)
(direction w)
(direction nw)

(index 1)
(index 2)
(index 3)
(index 4)
(index 5)
(index 6)
(index 7)
(index 8)
(index 9)
(index 10)

(++ 1 2)
(++ 2 3)
(++ 3 4)
(++ 4 5)
(++ 5 6)
(++ 6 7)
(++ 7 8)
(++ 8 9)
(++ 9 10)

sees_XML(...) rules

(<= (translate_fluent (cellholds ?x ?y white) (cellholds ?x ?y whitequeen))
    (cell ?x ?y)
)
(<= (translate_fluent (cellholds ?x ?y black) (cellholds ?x ?y blackqueen))
    (cell ?x ?y)
)
(<= (translate_fluent (cellholds ?x ?y arrow) (cellholds ?x ?y redsquare))
    (cell ?x ?y)
)
(<= (translate_fluent (control ?r) (control ?r))
    (role ?r)
)

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