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

Game Description

;;;;;;;;;;;;;;;;;;;;;;;;;
;; BattleSnakes
;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;
;; Roles
;;;;;;;;;;;;;;;;;;;;;;;;;

(role red)
(role blue)

;;;;;;;;;;;;;;;;;;;;;;;;;
;; Initial State
;;;;;;;;;;;;;;;;;;;;;;;;;

(init (snake 2 2 red 1))
(init (snake 1 2 red 2))
(init (snake 1 3 red 3))
(init (snake 1 4 red 4))
(init (snake 1 5 red 5))
(init (snake 1 6 red 6))
(init (snake 1 7 red 7))
(init (snake 1 8 red 8))

(init (snake 7 7 blue 1))
(init (snake 8 1 blue 2))
(init (snake 8 2 blue 3))
(init (snake 8 3 blue 4))
(init (snake 8 4 blue 5))
(init (snake 8 5 blue 6))
(init (snake 8 6 blue 7))
(init (snake 8 7 blue 8))

(init (step 0))

(init (size red 8))
(init (size blue 8))

;;;;;;;;;;;;;;;;;;;;;;;;;
;; Legal
;;;;;;;;;;;;;;;;;;;;;;;;;

(<= (legal ?player (move ?x ?y ?x1 ?y))
	(role ?player)
	(true (snake ?x ?y ?player 1))
	(adjacent ?x ?x1)
)

(<= (legal ?player (move ?x ?y ?x ?y1))
	(role ?player)
	(true (snake ?x ?y ?player 1))
	(adjacent ?y ?y1)
)

(<= (adjacent ?x1 ?x2)
	(boardSucc ?x1 ?x2)
)

(<= (adjacent ?x1 ?x2)
	(boardSucc ?x2 ?x1)
)

;;;;;;;;;;;;;;;;;;;;;;;;;
;; Next
;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;
;; Stepper
(<= (next (step ?y))
	(true (step ?x))
	(succ ?x ?y)
)


;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Moves

;; Move Head ;;
(<= (next (snake ?x1 ?y1 ?player 1))
	(does ?player (move ?x ?y ?x1 ?y1))
)

;; Move Tail ;;
;; No collision
(<= (next (snake ?x ?y ?player ?newTail))
	(true (snake ?x ?y ?player ?currTail))
	(not (true (size ?player ?currTail)))
	(succ ?currTail ?newTail)
	(role ?player2)
	(distinct ?player ?player2)
	(not (collision ?player))
	(not (collision ?player2))
)

;; Both collide
(<= (next (snake ?x ?y ?player ?newTail))
	(true (snake ?x ?y ?player ?currTail))
	(not (true (size ?player ?currTail)))
	(succ ?currTail ?newTail)
	(role ?player2)
	(distinct ?player ?player2)
	(collision ?player)
	(collision ?player2)
)

;; Player crashes
(<= (next (snake ?x ?y ?player ?newTail))
	(true (snake ?x ?y ?player ?currTail))
	(true (size ?player ?size))
	(succ ?newsize ?size)
	(distinct ?currTail ?size)
	(distinct ?currTail ?newsize)
	(succ ?currTail ?newTail)
	(role ?player2)
	(distinct ?player ?player2)
	(collision ?player)
	(not (collision ?player2))
)

;; Player gets crashed into
(<= (next (snake ?x ?y ?player ?newTail))
	(true (snake ?x ?y ?player ?currTail))
	(true (size ?player ?size))
	(succ ?size ?newsize)
	(distinct ?currTail ?newsize)
	(succ ?currTail ?newTail)
	(role ?player2)
	(distinct ?player ?player2)
	(collision ?player2)
	(not (collision ?player))
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Size

;; No collision
(<= (next (size ?player ?size))
	(true (size ?player ?size))
	(role ?player2)
	(distinct ?player ?player2)
	(not (collision ?player))
	(not (collision ?player2))
)

;; Both collide
(<= (next (size ?player ?size))
	(true (size ?player ?size))
	(role ?player2)
	(distinct ?player ?player2)
	(collision ?player)
	(collision ?player2)
)

;; Player crashes
(<= (next (size ?player ?newsize))
	(true (size ?player ?size))
	(role ?player2)
	(distinct ?player ?player2)
	(collision ?player)
	(not (collision ?player2))
	(succ ?newsize ?size)
)

;; Player gets crashed into
(<= (next (size ?player ?newsize))
	(true (size ?player ?size))
	(role ?player2)
	(distinct ?player ?player2)
	(collision ?player2)
	(not (collision ?player))
	(succ ?size ?newsize)
)

(<= (collision ?player)
	(does ?player (move ?a ?b ?c ?d))
	(true (snake ?c ?d ?anyplayer ?body))
	(true (size ?anyplayer ?size))
	(distinct ?size ?body)
)


;;;;;;;;;;;;;;;;;;;;;;;;;
;; Terminal States
;;;;;;;;;;;;;;;;;;;;;;;;;

(score 1 100)
(score 2 93)
(score 3 86)
(score 4 79)
(score 5 72)
(score 6 65)
(score 7 58)
(score 8 50)
(score 9 42)
(score 10 35)
(score 11 28)
(score 12 21)
(score 13 14)
(score 14 7)
(score 15 0)

(<= (goal ?player ?score)
	(role ?player)
	(true (size ?player ?size))
	(score ?size ?score)
)

(<= (goal ?player1 100)
	(role ?player1)
	(role ?player2)
	(true (size ?player2 15))
	(true (size ?player1 1))
)

(<= (goal ?player2 0)
	(role ?player1)
	(role ?player2)
	(true (size ?player2 15))
	(true (size ?player1 1))
)

(<= terminal
	(true (step 100))
)

(<= terminal
	(true (size ?player1 1))
	(true (size ?player2 15))
	(distinct ?player1 ?player2)
)



;;;;;;;;;;;;;;;;;;;;;;;;;
;; Successors
;;;;;;;;;;;;;;;;;;;;;;;;;

(boardSucc 1 2)
(boardSucc 2 3)
(boardSucc 3 4)
(boardSucc 4 5)
(boardSucc 5 6)
(boardSucc 6 7)
(boardSucc 7 8)
(boardSucc 8 0)

(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)
(succ 50 51)
(succ 51 52)
(succ 52 53)
(succ 53 54)
(succ 54 55)
(succ 55 56)
(succ 56 57)
(succ 57 58)
(succ 58 59)
(succ 59 60)
(succ 60 61)
(succ 61 62)
(succ 62 63)
(succ 63 64)
(succ 64 65)
(succ 65 66)
(succ 66 67)
(succ 67 68)
(succ 68 69)
(succ 69 70)
(succ 70 71)
(succ 71 72)
(succ 72 73)
(succ 73 74)
(succ 74 75)
(succ 75 76)
(succ 76 77)
(succ 77 78)
(succ 78 79)
(succ 79 80)
(succ 80 81)
(succ 81 82)
(succ 82 83)
(succ 83 84)
(succ 84 85)
(succ 85 86)
(succ 86 87)
(succ 87 88)
(succ 88 89)
(succ 89 90)
(succ 90 91)
(succ 91 92)
(succ 92 93)
(succ 93 94)
(succ 94 95)
(succ 95 96)
(succ 96 97)
(succ 97 98)
(succ 98 99)
(succ 99 100)

sees_XML(...) rules

(<= (sees_xml random ?term)
   (sees_xml1 ?term)
)
(<= (sees_xml ?role ?term)
   (role ?role)
   (sees_xml1 ?term)
)
(<= (sees_xml1 (cell ?x ?y ?c))
	(cell_color ?x ?y ?c)
    (not (true (snake ?x ?y ?c 1)))
)
(<= (sees_xml1 (cell ?x ?y red_pawn))
    (true (snake ?x ?y red 1))
    (cell_color ?x ?y red)
)
(<= (sees_xml1 (cell ?x ?y blue_pawn))
    (true (snake ?x ?y blue 1))
    (cell_color ?x ?y blue)
)
(<= (sees_xml1 (step ?x))
    (true (step ?x))
)
(<= (sees_xml1 (size ?x ?y))
    (true (size ?x ?y))
)
(<= (sees_xml1 ?t)
    (true ?t)
)
(<= (cell_color ?x ?y green)
    (any_part_of_snake_at ?x ?y red)
	(any_part_of_snake_at ?x ?y blue)
)
(<= (cell_color ?x ?y red)
    (any_part_of_snake_at ?x ?y red)
	(not (any_part_of_snake_at ?x ?y blue))
)
(<= (cell_color ?x ?y blue)
	(any_part_of_snake_at ?x ?y blue)
    (not (any_part_of_snake_at ?x ?y red))
)
(<= (any_part_of_snake_at ?x ?y ?player)
	(true (snake ?x ?y ?player ?n))
)