You are not logged in. login register
Game four_way_battle
name four_way_battle
creator admin
number of roles 4
stylesheet battle/four_way_battle.xsl
GDL v1
enabled
matches show matches
statistics show game statistics
description

Game Description

; A synthetic game of survival.

; Roles
(role north)
(role south)
(role east)
(role west)

; Initial state
(init (step 0))
(init (capture_count north 0))
(init (capture_count south 0))
(init (capture_count east 0))
(init (capture_count west 0))

(init (cell 2 1 sp))
(init (cell 3 1 sk))
(init (cell 4 1 sk))
(init (cell 5 1 sp))
(init (cell 3 2 sp))
(init (cell 4 2 sp))

(init (cell 2 6 np))
(init (cell 3 6 nk))
(init (cell 4 6 nk))
(init (cell 5 6 np))
(init (cell 3 5 np))
(init (cell 4 5 np))

(init (cell 1 2 wp))
(init (cell 1 3 wk))
(init (cell 1 4 wk))
(init (cell 1 5 wp))
(init (cell 2 3 wp))
(init (cell 2 4 wp))

(init (cell 6 2 ep))
(init (cell 6 3 ek))
(init (cell 6 4 ek))
(init (cell 6 5 ep))
(init (cell 5 3 ep))
(init (cell 5 4 ep))

; Legal moves
(<= (legal ?role (move ?x ?y ?u ?v))
    (role ?role)
    (coordinate ?u)
    (coordinate ?v)
    (owns ?role ?piece)
    (true (cell ?x ?y ?piece))
    (are_distinct ?x ?y ?u ?v)
    (valid_move ?piece ?x ?y ?u ?v)
    (not (cell_owned_by ?u ?v ?role)))

(<= (cell_owned_by ?u ?v ?role)
    (true (cell ?u ?v ?p))
    (owns ?role ?p))

(<= (legal ?role (defend ?x ?y))
    (true (cell ?x ?y ?piece))
    (owns ?role ?piece))

; Transition rules
(<= (next (cell ?x ?y ?piece))
    (true (cell ?x ?y ?piece))
    (not (someone_moves_from ?x ?y))
    (not (someone_moves_to ?x ?y)))

(<= (someone_moves_from ?x ?y)
    (does ?r (move ?x ?y ?u ?v)))

(<= (someone_moves_to ?u ?v)
    (does ?r (move ?x ?y ?u ?v)))

(<= (next (cell ?x ?y ?piece))
    (true (cell ?x ?y ?piece))
    (does ?role (defend ?x ?y)))
(<= (next (cell ?x ?y ?piece))
    (does ?role (move ?x0 ?y0 ?x ?y))
    (true (cell ?x0 ?y0 ?piece))
    (not (someone_defends ?x ?y))
    (not (someone_different_moves_to ?role ?x ?y)))

(<= (someone_defends ?x ?y)
    (does ?owner (defend ?x ?y)))

(<= (next (step ?b))
    (true (step ?a))
    (succ ?a ?b))
(<= (next (capture_count ?role ?new_count))
    (true (capture_count ?role ?old_count))
    (did_capture ?role)
    (succ ?old_count ?new_count))
(<= (next (capture_count ?role ?count))
    (true (capture_count ?role ?count))
    (not (did_capture ?role)))

; Termination
(<= terminal
    (true (step 40)))
(<= terminal
    (role ?role)
    (not (any_cell_owned_by ?role)))

(<= (any_cell_owned_by ?role)
    (cell_owned_by ?x ?y ?role))

(<= terminal
    (role ?role)
    (goal ?role 100))

; Payoffs
(<= (goal ?role ?payoff)
    (true (capture_count ?role ?count))
    (payoff ?count ?payoff))

; Domain knowledge
(owns south sp)
(owns north np)
(owns west wp)
(owns east ep)

(owns south sk)
(owns north nk)
(owns west wk)
(owns east ek)

(pawn sp)
(pawn np)
(pawn ep)
(pawn wp)

(king sk)
(king nk)
(king ek)
(king wk)

(payoff 0 0)
(payoff 1 10)
(payoff 2 20)
(payoff 3 30)
(payoff 4 40)
(payoff 5 50)
(payoff 6 60)
(payoff 7 70)
(payoff 8 80)
(payoff 9 90)
(payoff 10 100)

; Valid moves
; Kings can move vertically, horizontally, or diagonally.
(<= (valid_move ?piece ?x ?y ?u ?v)
    (king ?piece)
    (within_one ?x ?u)
    (within_one ?y ?v))
; Pawns can move vertically or horizontally.
(<= (valid_move ?piece ?x ?y ?u ?y)
    (pawn ?piece)
    (within_one ?x ?u)
    (coordinate ?y))
(<= (valid_move ?piece ?x ?y ?x ?v)
    (pawn ?piece)
    (coordinate ?x)
    (within_one ?y ?v))

(<= (within_one ?x ?x)
    (number ?x))
(<= (within_one ?x ?u)
    (succ ?x ?u))
(<= (within_one ?x ?u)
    (succ ?u ?x))

(<= (are_distinct ?x1 ?y1 ?x2 ?y2)
    (coordinate ?x1)
    (coordinate ?x2)
    (coordinate ?y1)
    (coordinate ?y2)
    (distinct ?x1 ?x2))

(<= (are_distinct ?x1 ?y1 ?x2 ?y2)
    (coordinate ?x1)
    (coordinate ?x2)
    (coordinate ?y1)
    (coordinate ?y2)
    (distinct ?y1 ?y2))

(<= (did_capture ?role)
    (does ?role (move ?x ?y ?u ?v))
    (true (cell ?u ?v ?piece))
    (owns ?opponent ?piece)
    (not (does ?opponent (defend ?u ?v)))
    (not (move_from ?opponent ?u ?v))
    (not (someone_different_moves_to ?role ?u ?v)))
(<= (did_capture ?defender)
    (does ?attacker (move ?x ?y ?u ?v))
    (does ?defender (defend ?u ?v)))

(<= (move_from ?role ?u ?v)
    (does ?role (move ?u ?v ?u2 ?v2)))

(<= (someone_different_moves_to ?role ?u ?v)
    (role ?role)
    (role ?op2)
    (distinct ?role ?op2)
    (does ?op2 (move ?xx ?yy ?u ?v)))

(<= (sum ?x 0 ?x)
    (number ?x))
(<= (sum ?a 1 ?b)
    (succ ?a ?b))
(<= (sum ?a 2 ?c)
    (succ ?a ?b)
    (succ ?b ?c))
(<= (sum ?a 3 ?d)
    (succ ?a ?b)
    (succ ?b ?c)
    (succ ?c ?d))

(coordinate 1)
(coordinate 2)
(coordinate 3)
(coordinate 4)
(coordinate 5)
(coordinate 6)

(succ 0 1)
(succ 1 2)
(succ 2 3)
(succ 3 4)
(succ 4 5)
(succ 5 6)
(succ 6 7)
(succ 7 8)
(succ 8 9)
(succ 9 10)
(succ 10 11)
(succ 11 12)
(succ 12 13)
(succ 13 14)
(succ 14 15)
(succ 15 16)
(succ 16 17)
(succ 17 18)
(succ 18 19)
(succ 19 20)
(succ 20 21)
(succ 21 22)
(succ 22 23)
(succ 23 24)
(succ 24 25)
(succ 25 26)
(succ 26 27)
(succ 27 28)
(succ 28 29)
(succ 29 30)
(succ 30 31)
(succ 31 32)
(succ 32 33)
(succ 33 34)
(succ 34 35)
(succ 35 36)
(succ 36 37)
(succ 37 38)
(succ 38 39)
(succ 39 40)

(number 0)
(number 1)
(number 2)
(number 3)
(number 4)
(number 5)
(number 6)
(number 7)
(number 8)
(number 9)
(number 10)
(number 11)
(number 12)
(number 13)
(number 14)
(number 15)
(number 16)
(number 17)
(number 18)
(number 19)
(number 20)
(number 21)
(number 22)
(number 23)
(number 24)
(number 25)
(number 26)
(number 27)
(number 28)
(number 29)
(number 30)
(number 31)
(number 32)
(number 33)
(number 34)
(number 35)
(number 36)
(number 37)
(number 38)
(number 39)
(number 40)

sees_XML(...) rules

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