You are not logged in. login register
Game battlebrushes
name battlebrushes
creator stephan
number of roles 4
stylesheet battlebrushes/battlebrushes.xsl
GDL v1
enabled
matches show matches
statistics show game statistics
description Inspired by the game "Battle Painters", where some players with brushes try to color as large an area as possible in their own color.
In this four-player version, the board is set to a size of 8 x 8 and the brushes can only be moved to a horizontally or vertically adjacent cell. With each step to a cell the destination is colored in the player's color. If more than one player tries to reach the same cell in the same step, they become dizzy and cannot move for two turns.
GDL by Tim Federholzner and Peter Kissmann (TZI, University of Bremen)

Game Description

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;                                                ;;;;;;;;;;;;;;;;;
;;;;             Battlebrushes                      ;;;;;;;;;;;;;;;;;
;;;;                                                ;;;;;;;;;;;;;;;;;
;;;;    by Tim Federholzner and Peter Kissmann 2011 ;;;;;;;;;;;;;;;;;
;;;;                                                ;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; four players move around on an 8x8 board and paint the cells in
;;; their color

;;; every brush has a unique color
(role blue)
(role red)
(role green)
(role yellow)

;;; each player starts in one corner
(startingcell 2 2)
(startingcell 2 7)
(startingcell 7 2)
(startingcell 7 7)

;;; every other cell is not painted
(<= (init (cell ?x ?y b))
	(coordinate ?x)
	(coordinate ?y)
	(not (startingcell ?x ?y))
)

;;; the startingcells are already painted
(init (cell 2 2 blue))
(init (cell 2 7 red))
(init (cell 7 2 green))
(init (cell 7 7 yellow))

;;; fluent which saves the position of the players
(init (at bluebrush 2 2))
(init (at redbrush 2 7))
(init (at greenbrush 7 2))
(init (at yellowbrush 7 7))
(brush blue bluebrush)
(brush red redbrush)
(brush green greenbrush)
(brush yellow yellowbrush)

;;; fluent which tells the color of every cell
(<= (next (cell ?x ?y ?c))
	(nextcellcolor ?x ?y ?c)
)

;;; a cells remains in its color, if no player moves to it
(<= (nextcellcolor ?x ?y ?s)
	(true (cell ?x ?y ?s))
	(not (does blue (goto ?x ?y)))
	(not (does red (goto ?x ?y)))
	(not (does green (goto ?x ?y)))
	(not (does yellow (goto ?x ?y)))
)

;;; a cell remains in its color, if more than one player tries to move to it
(<= (nextcellcolor ?x ?y ?s)
	(true (cell ?x ?y ?s))
	(role ?r)
	(does ?r (goto ?x ?y))
	(role ?r2)
	(distinct ?r ?r2)
	(does ?r2 (goto ?x ?y))
)

;;; a cell is painted if exactly one player moves to it
(<= (nextcellcolor ?x ?y blue)
	(does blue (goto ?x ?y))
	(not (does red (goto ?x ?y)))
	(not (does green (goto ?x ?y)))
	(not (does yellow (goto ?x ?y)))
)
(<= (nextcellcolor ?x ?y red)
	(does red (goto ?x ?y))
	(not (does blue (goto ?x ?y)))
	(not (does green (goto ?x ?y)))
	(not (does yellow (goto ?x ?y)))
)
(<= (nextcellcolor ?x ?y green)
	(does green (goto ?x ?y))
	(not (does blue (goto ?x ?y)))
	(not (does red (goto ?x ?y)))
	(not (does yellow (goto ?x ?y)))
)
(<= (nextcellcolor ?x ?y yellow)
	(does yellow (goto ?x ?y))
	(not (does blue (goto ?x ?y)))
	(not (does red (goto ?x ?y)))
	(not (does green (goto ?x ?y)))
)

;;; a player may move to adjacent cells if they are not occupied
(<= (legal ?r (goto ?x ?y))
	(role ?r)
	(not (true (dizzy ?r 1)))
	(not (true (dizzy ?r 0)))
	(true (cell ?x ?y ?s))
	(not (occupied ?x ?y))
	(brush ?r ?b)
	(true (at ?b ?i ?j))
	(adjacent ?x ?y ?i ?j)
)

;;; a cell is occupied, if a player is there
(<= (occupied ?x ?y)
	(true (at ?b ?x ?y))
)

;;; if two or more players collided, they feel dizzy for two steps
(<= (legal ?r feeldizzy)
	(true (dizzy ?r ?n))
)

;;; supportive predicates for corners and edges of the board
(corner 1 1)
(corner 1 8)
(corner 8 1)
(corner 8 8)

(<= (edge 1 ?y)
	(coordinate ?y)
	(distinct ?y 1)
	(distinct ?y 8)
)
(<= (edge 8 ?y)
	(coordinate ?y)
	(distinct ?y 1)
	(distinct ?y 8)
)
(<= (edge ?x 1)
	(coordinate ?x)
	(distinct ?x 1)
	(distinct ?x 8)
)
(<= (edge ?x 8)
	(coordinate ?x)
	(distinct ?x 1)
	(distinct ?x 8)
)

;;; if all cells around a player are occupied, that player cannot move
(<= (legal ?r feeldizzy)
	(brush ?r ?b)
	(true (at ?b ?x ?y))
	(corner ?x ?y)
	(brush ?r2 ?b2)
	(true (at ?b2 ?x2 ?y2))
	(adjacent ?x ?y ?x2 ?y2)
	(brush ?r3 ?b3)
	(true (at ?b3 ?x3 ?y3))
	(adjacent ?x ?y ?x3 ?y3)
	(distinct ?r2 ?r3)
)
(<= (legal ?r feeldizzy)
	(brush ?r ?b)
	(true (at ?b ?x ?y))
	(edge ?x ?y)
	(brush ?r2 ?b2)
	(true (at ?b2 ?x2 ?y2))
	(adjacent ?x ?y ?x2 ?y2)
	(brush ?r3 ?b3)
	(true (at ?b3 ?x3 ?y3))
	(adjacent ?x ?y ?x3 ?y3)
	(brush ?r4 ?b4)
	(true (at ?b4 ?x4 ?y4))
	(adjacent ?x ?y ?x4 ?y4)
	(threeDistinctRoles ?r2 ?r3 ?r4)
)
(<= (adjacent ?x ?y ?x ?j)
	(coordinate ?x)
	(succ ?y ?j)
)
(<= (adjacent ?x ?y ?x ?j)
	(coordinate ?x)
	(succ ?j ?y)
)
(<= (adjacent ?x ?y ?i ?y)
	(coordinate ?y)
	(succ ?x ?i)
)
(<= (adjacent ?x ?y ?i ?y)
	(coordinate ?y)
	(succ ?i ?x)
)

;;; a player reaches a cell, if it is the only one to move there
(<= (next (at bluebrush ?x ?y))
	(does blue (goto ?x ?y))
	(not (does red (goto ?x ?y)))
	(not (does green (goto ?x ?y)))
	(not (does yellow (goto ?x ?y)))
)
(<= (next (at redbrush ?x ?y))
	(does red (goto ?x ?y))
	(not (does blue (goto ?x ?y)))
	(not (does green (goto ?x ?y)))
	(not (does yellow (goto ?x ?y)))
)
(<= (next (at greenbrush ?x ?y))
	(does green (goto ?x ?y))
	(not (does blue (goto ?x ?y)))
	(not (does red (goto ?x ?y)))
	(not (does yellow (goto ?x ?y)))
)
(<= (next (at yellowbrush ?x ?y))
	(does yellow (goto ?x ?y))
	(not (does blue (goto ?x ?y)))
	(not (does red (goto ?x ?y)))
	(not (does green (goto ?x ?y)))
)

;;; a player stays at its position, if it collided with another player
(<= (next (at ?b ?x ?y))
	(role ?r)
	(brush ?r ?b)
	(true (at ?b ?x ?y))
	(willfeeldizzy ?r)
)
(<= (next (at ?b ?x ?y))
	(role ?r)
	(brush ?r ?b)
	(true (at ?b ?x ?y))
	(does ?r feeldizzy)
)

;;; a counter for dizzy players, which decreases to zero
(<= (next (dizzy ?r 1))
	(willfeeldizzy ?r)
)
(<= (next (dizzy ?r 0))
	(true (dizzy ?r 1))
)

;;; a player will feel dizzy, if it collides with another one
(<= (willfeeldizzy ?r)
	(role ?r)
	(does ?r (goto ?i ?j))
	(role ?r2)
	(distinct ?r ?r2)
	(does ?r2 (goto ?i ?j))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; neighbor relation of cell coordinates
(succ 1 2)
(succ 2 3)
(succ 3 4)
(succ 4 5)
(succ 5 6)
(succ 6 7)
(succ 7 8)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; supportive predicate which holds all/three players in any order
(<= (fourDistinctRoles ?r1 ?r2 ?r3 ?r4)
	(role ?r1)
	(role ?r2)
	(role ?r3)
	(role ?r4)
	(distinct ?r1 ?r2)
	(distinct ?r1 ?r3)
	(distinct ?r1 ?r4)
	(distinct ?r2 ?r3)
	(distinct ?r2 ?r4)
	(distinct ?r3 ?r4)
)
(<= (threeDistinctRoles ?r1 ?r2 ?r3)
	(role ?r1)
	(role ?r2)
	(role ?r3)
	(distinct ?r1 ?r2)
	(distinct ?r1 ?r3)
	(distinct ?r2 ?r3)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; the step counter is also used for counting the points of the players
(step++ -1 0)
(step++ 0 1)

;;; recursive greater-than relation
(<= (moreThan ?n ?n2)
	(step++ ?n2 ?n)
)
(<= (moreThan ?n ?n2)
	(step++ ?t ?n)
	(moreThan ?t ?n2)
)
(step++ 1 2)
(step++ 2 3)
(step++ 3 4)
(step++ 4 5)
(step++ 5 6)
(step++ 6 7)
(step++ 7 8)
(step++ 8 9)
(step++ 9 10)
(step++ 10 11)
(step++ 11 12)
(step++ 12 13)
(step++ 13 14)
(step++ 14 15)
(step++ 15 16)
(step++ 16 17)
(step++ 17 18)
(step++ 18 19)
(step++ 19 20)
(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)

;;; in the step just before the terminal state the points for each player are calculated
(<= (next (points blue ?p))
	(true (step 19))
	(calculatePoints blue 0 ?p 1 1)
)
(<= (next (points red ?p))
	(true (step 19))
	(calculatePoints red 0 ?p 1 1)
)
(<= (next (points green ?p))
	(true (step 19))
	(calculatePoints green 0 ?p 1 1)
)
(<= (next (points yellow ?p))
	(true (step 19))
	(calculatePoints yellow 0 ?p 1 1)
)

;;; the points are counted recursively from the upper left edge
;;; if a cell has the color of the player, the counter is increased
(<= (calculatePoints ?r ?p0 ?pn ?x ?y)
	(nextcellcolor ?x ?y ?r)
	(step++ ?p0 ?p1)
	(succ ?y ?y2)
	(calculatePoints ?r ?p1 ?pn ?x ?y2)
)
(<= (calculatePoints ?r ?p0 ?pn ?x 8)
	(nextcellcolor ?x 8 ?r)
	(step++ ?p0 ?p1)
	(succ ?x ?x2)
	(calculatePoints ?r ?p1 ?pn ?x2 1)
)
(<= (calculatePoints ?r ?p0 ?pn ?x ?y)
	(coordinate ?x)
	(coordinate ?y)
	(role ?r)
	(not (nextcellcolor ?x ?y ?r))
	(succ ?y ?y2)
	(calculatePoints ?r ?p0 ?pn ?x ?y2)
)
(<= (calculatePoints ?r ?p0 ?pn ?x 8)
	(coordinate ?x)
	(role ?r)
	(not (nextcellcolor ?x 8 ?r))
	(succ ?x ?x2)
	(calculatePoints ?r ?p0 ?pn ?x2 1)
)
;;; the calculation ends in the (8,8)-cell
(<= (calculatePoints ?r ?p0 ?pn 8 8)
	(nextcellcolor 8 8 ?r)
	(step++ ?p0 ?pn)
)
(<= (calculatePoints ?r ?pn ?pn 8 8)
	(role ?r)
	(not (nextcellcolor 8 8 ?r))
	(number ?pn)
)

;;; step counter fluents
(init (step 1))
(<= (next (step ?n2))
	(true (step ?n))
	(step++ ?n ?n2)
)

;;; in every case the game ends in step 20
(<= terminal
	(true (step 20))
)
(coordinate 1)
(coordinate 2)
(coordinate 3)
(coordinate 4)
(coordinate 5)
(coordinate 6)
(coordinate 7)
(coordinate 8)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; if one player has more points than every other player, it gains 100
(<= (goal ?r 100)
	(true (step 20))
	(true (points ?r ?n))
	(true (points ?r2 ?n2))
	(moreThan ?n ?n2)
	(true (points ?r3 ?n3))
	(moreThan ?n ?n3)
	(true (points ?r4 ?n4))
	(moreThan ?n ?n4)
	(threeDistinctRoles ?r2 ?r3 ?r4)
)

;;; if one player has more points than two players, but another player has more points, it gains 50
(<= (goal ?r 50)
	(true (step 20))
	(true (points ?r ?n))
	(true (points ?r2 ?n2))
	(moreThan ?n2 ?n)
	(true (points ?r3 ?n3))
	(moreThan ?n ?n3)
	(true (points ?r4 ?n4))
	(moreThan ?n ?n4)
	(distinct ?r3 ?r4)
)

;;; if one player has more points than another player, but two have more, it gains 25
(<= (goal ?r 25)
	(true (step 20))
	(true (points ?r ?n))
	(true (points ?r2 ?n2))
	(moreThan ?n2 ?n)
	(true (points ?r3 ?n3))
	(moreThan ?n3 ?n)
	(true (points ?r4 ?n4))
	(moreThan ?n ?n4)
	(distinct ?r2 ?r3)
)

;;; the player with the lowest point counter gains 0
(<= (goal ?r 0)
	(true (step 20))
	(true (points ?r ?n))
	(true (points ?r2 ?n2))
	(moreThan ?n2 ?n)
	(true (points ?r3 ?n3))
	(moreThan ?n3 ?n)
	(true (points ?r4 ?n4))
	(moreThan ?n4 ?n)
	(threeDistinctRoles ?r2 ?r3 ?r4)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; two players have the same number of points but have more than the other two players,
;;; both get 75
(<= (goal ?r 75)
	(true (step 20))
	(true (points ?r ?n))
	(true (points ?r2 ?n))
	(distinct ?r ?r2)
	(true (points ?r3 ?n3))
	(moreThan ?n ?n3)
	(true (points ?r4 ?n4))
	(moreThan ?n ?n4)
	(distinct ?r3 ?r4)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; if three players share the top score, they get 66
(<= (goal ?r 66)
	(true (step 20))
	(true (points ?r ?n))
	(threeDistinctRoles ?r ?r2 ?r3)
	(true (points ?r2 ?n))
	(true (points ?r3 ?n))
	(true (points ?r4 ?n4))
	(moreThan ?n ?n4)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; if all players have equal points, they get 50
(<= (goal ?r 50)
	(true (step 20))
	(true (points ?r ?n))
	(fourDistinctRoles ?r ?r2 ?r3 ?r4)
	(true (points ?r2 ?n))
	(true (points ?r3 ?n))
	(true (points ?r4 ?n))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; two second rated players with equal points get 33
(<= (goal ?r 33)
	(true (step 20))
	(true (points ?r ?n))
	(true (points ?r2 ?n))
	(distinct ?r ?r2)
	(true (points ?r3 ?n3))
	(moreThan ?n3 ?n)
	(true (points ?r4 ?n4))
	(moreThan ?n ?n4)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; if three players share the second place, they get 25
(<= (goal ?r 25)
	(true (step 20))
	(true (points ?r ?n))
	(threeDistinctRoles ?r ?r2 ?r3)
	(true (points ?r2 ?n))
	(true (points ?r3 ?n))
	(true (points ?r4 ?n4))
	(moreThan ?n4 ?n)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; if two players share the last place, they get 12 points
(<= (goal ?r 12)
	(true (step 20))
	(true (points ?r ?n))
	(true (points ?r2 ?n))
	(distinct ?r ?r2)
	(true (points ?r3 ?n3))
	(moreThan ?n3 ?n)
	(true (points ?r4 ?n4))
	(moreThan ?n4 ?n)
	(distinct ?r3 ?r4)
)
;;;;;;;;;;;;;;;;;

sees_XML(...) rules

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