You are not logged in. login register
Game battle
name battle
creator admin
number of roles 2
stylesheet battle/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)

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

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

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

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

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

; 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 30)))
(<= 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)
(coordinate 7)
(coordinate 8)

(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)
(succ 40 41)
(succ 41 42)
(succ 42 43)
(succ 43 44)
(succ 44 45)
(succ 45 46)
(succ 46 47)
(succ 47 48)
(succ 48 49)
(succ 49 50)

(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)
(number 41)
(number 42)
(number 43)
(number 44)
(number 45)
(number 46)
(number 47)
(number 48)
(number 49)
(number 50)

sees_XML(...) rules

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