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

Game Description

(role red)
(role blue)
(role green)
(role yellow)

(init (counter n50))

(init (posx yellow p1))
(init (posy yellow p0))
(init (velx yellow p0))
(init (vely yellow p1))

(init (posx red p2))
(init (posy red p0))
(init (velx red p0))
(init (vely red p1))

(init (posx blue p3))
(init (posy blue p0))
(init (velx blue p0))
(init (vely blue p1))

(init (posx green p4))
(init (posy green p0))
(init (velx green p0))
(init (vely green p1))

; Have the counter count
(<= (next (counter ?nc))
    (true (counter ?c))
    (succ ?c ?nc))

; Set horizontal and vertical position
; for the next round
(<= (next (posx ?player ?nx))
    (does ?player (speed ?dx ?dy))
	(true (posx ?player ?x))
	(add ?x ?dx ?nx))
(<= (next (posx ?player ?x))
	(does ?player resign)
	(true (posx ?player ?x)))

(<= (next (posy ?player ?ny))
    (does ?player (speed ?dx ?dy))
	(true (posy ?player ?y))
	(add ?y ?dy ?ny))
(<= (next (posy ?player ?y))
	(does ?player resign)
	(true (posy ?player ?y)))

; Set hor. and vert. velocity according
; to the player's move
(<= (next (velx ?player ?dx))
	(does ?player (speed ?dx ?dy)))
(<= (next (velx ?player p0))
	(does ?player resign))

(<= (next (vely ?player ?dy))
	(does ?player (speed ?dx ?dy)))
(<= (next (vely ?player p0))
	(does ?player resign))

; Let the player resign
; in case there are no legal moves
(<= (next (resigned ?player)) (does ?player resign))

; | x - y | <= p1 ?
(<= (pmone ?x ?x)
	(number ?x))
(<= (pmone ?x ?y) (succ ?y ?x))
(<= (pmone ?x ?y) (succ ?x ?y))

; Player can move on the track,
; increasing or decreasing his velocity.
(<= (legal ?player (speed ?ndx ?ndy))
	(legal_speed ?player ?ndx ?ndy)
	(not (true (resigned ?player))))

(<= (legal_speed ?player ?ndx ?ndy)
	(true (velx ?player ?dx))
	(true (vely ?player ?dy))
	(pmone ?dx ?ndx)
	(pmone ?dy ?ndy)
	(or (distinct ?ndx p0) (distinct ?ndy p0)) ; the players have to move somewhere
	(smaller n2 ?ndx)
	(true (posx ?player ?px))
	(true (posy ?player ?py))
	(add ?px ?ndx ?x)
	(add ?py ?ndy ?y)
	(track ?x ?y))

; Ensure playability
(<= (legal ?player resign)
	(role ?player)
	(not (any_legal_speed ?player)))
(<= (legal ?player resign)
	(true (resigned ?player)))

(<= (any_legal_speed ?player)
	(legal_speed ?player ?dx ?dy))

; The goal is to get into the landing zone first.
(<= (goal ?player 100)
	(in_landing_zone ?player)
	(role ?otherplayer)
	(distinct ?player ?otherplayer)
	(not (in_landing_zone ?otherplayer)))

(<= (goal ?player 75)
	(in_landing_zone ?player)
	(in_landing_zone ?otherplayer)
	(distinct ?player ?otherplayer))

(<= (goal ?player 25)
	(role ?player)
	(not (in_landing_zone ?player))
	(not (true (resigned ?player))))

(<= (goal ?player 0)
	(true (resigned ?player)))

(<= (in_landing_zone ?player)
	(true (posy ?player ?y))
	(smaller ?y p0)
	(true (posx ?player ?x))
	(smaller p20 ?x))

; The game terminates if some player either resigns,
; reaches the landing zone or takes too long.
(<= terminal
	(not running))
(<= terminal
	(true (posy ?player ?y))
	(smaller ?y p0))
(<= terminal
	(true (counter p50)))

(<= running
	(role ?player)
	(not (true (resigned ?player))))

; Outline the track
(track p0 p4) (track p0 p5) (track p0 p6) (track p0 p7)
(track p1 p0) (track p1 p1) (track p1 p2) (track p1 p3) (track p1 p4) (track p1 p5) (track p1 p6) (track p1 p7) (track p1 p8)
(track p2 p0) (track p2 p1) (track p2 p2) (track p2 p3) (track p2 p4) (track p2 p5) (track p2 p6) (track p2 p7) (track p2 p8) (track p2 p9) (track p2 p10)
(track p3 p0) (track p3 p1) (track p3 p2) (track p3 p3) (track p3 p4) (track p3 p5) (track p3 p6) (track p3 p7) (track p3 p8) (track p3 p9) (track p3 p10) (track p3 p11) (track p3 p12)
(track p4 p0) (track p4 p1) (track p4 p2) (track p4 p3) (track p4 p4) (track p4 p5) (track p4 p6) (track p4 p7) (track p4 p8) (track p4 p9) (track p4 p10) (track p4 p11) (track p4 p12) (track p4 p13)
(track p5 p6) (track p5 p7) (track p5 p8) (track p5 p9) (track p5 p10) (track p5 p11) (track p5 p12) (track p5 p13) (track p5 p14)
(track p6 p7) (track p6 p8) (track p6 p9) (track p6 p10) (track p6 p11) (track p6 p12) (track p6 p13) (track p6 p14) (track p6 p15)
(track p7 p8) (track p7 p9) (track p7 p10) (track p7 p11) (track p7 p12) (track p7 p13) (track p7 p14) (track p7 p15) (track p7 p16)
(track p8 p10) (track p8 p11) (track p8 p12) (track p8 p13) (track p8 p14) (track p8 p15) (track p8 p16) (track p8 p17)
(track p9 p10) (track p9 p11) (track p9 p12) (track p9 p13) (track p9 p14) (track p9 p15) (track p9 p16) (track p9 p17)
(track p10 p7) (track p10 p8) (track p10 p9) (track p10 p10) (track p10 p11) (track p10 p12) (track p10 p13) (track p10 p14) (track p10 p15) (track p10 p16)
(track p11 p7) (track p11 p8) (track p11 p9) (track p11 p10) (track p11 p11) (track p11 p12) (track p11 p13) (track p11 p14) (track p11 p15)
(track p12 p6) (track p12 p7) (track p12 p8) (track p12 p9) (track p12 p10) (track p12 p11)
(track p13 p6) (track p13 p7) (track p13 p8) (track p13 p9) (track p13 p10)
(track p14 p6) (track p14 p7) (track p14 p8) (track p14 p9) (track p14 p10)
(track p15 p5) (track p15 p6) (track p15 p7) (track p15 p8) (track p15 p9) (track p15 p10)
(track p16 p5) (track p16 p6) (track p16 p7) (track p16 p8) (track p16 p9) (track p16 p10)
(track p17 p6) (track p17 p7) (track p17 p8) (track p17 p9) (track p17 p10) (track p17 p11)
(track p18 p7) (track p18 p8) (track p18 p9) (track p18 p10) (track p18 p11)
(track p19 p8) (track p19 p9) (track p19 p10) (track p19 p11) (track p19 p12)
(track p20 p8) (track p20 p9) (track p20 p10) (track p20 p11) (track p20 p12) (track p20 p13)
(track p21 n4) (track p21 n3) (track p21 n2) (track p21 n1) (track p21 p0) (track p21 p1) (track p21 p2) (track p21 p3) (track p21 p4) (track p21 p5) (track p21 p6) (track p21 p7) (track p21 p8) (track p21 p9) (track p21 p10) (track p21 p11) (track p21 p12) (track p21 p13)
(track p22 n4) (track p22 n3) (track p22 n2) (track p22 n1) (track p22 p0) (track p22 p1) (track p22 p2) (track p22 p3) (track p22 p4) (track p22 p5) (track p22 p6) (track p22 p7) (track p22 p8) (track p22 p9) (track p22 p10) (track p22 p11) (track p22 p12)
(track p23 n4) (track p23 n3) (track p23 n2) (track p23 n1) (track p23 p0) (track p23 p1) (track p23 p2) (track p23 p3) (track p23 p4) (track p23 p5) (track p23 p6) (track p23 p7) (track p23 p8) (track p23 p9) (track p23 p10) (track p23 p11)
(track p24 n4) (track p24 n3) (track p24 n2) (track p24 n1) (track p24 p0) (track p24 p1) (track p24 p2) (track p24 p3) (track p24 p4) (track p24 p5) (track p24 p6) (track p24 p7) (track p24 p8) (track p24 p9) (track p24 p10)

; Define integers from -50 to +50
(succ n50 n49)
(succ n49 n48)
(succ n48 n47)
(succ n47 n46)
(succ n46 n45)
(succ n45 n44)
(succ n44 n43)
(succ n43 n42)
(succ n42 n41)
(succ n41 n40)
(succ n40 n39)
(succ n39 n38)
(succ n38 n37)
(succ n37 n36)
(succ n36 n35)
(succ n35 n34)
(succ n34 n33)
(succ n33 n32)
(succ n32 n31)
(succ n31 n30)
(succ n30 n29)
(succ n29 n28)
(succ n28 n27)
(succ n27 n26)
(succ n26 n25)
(succ n25 n24)
(succ n24 n23)
(succ n23 n22)
(succ n22 n21)
(succ n21 n20)
(succ n20 n19)
(succ n19 n18)
(succ n18 n17)
(succ n17 n16)
(succ n16 n15)
(succ n15 n14)
(succ n14 n13)
(succ n13 n12)
(succ n12 n11)
(succ n11 n10)
(succ n10 n9)
(succ n9 n8)
(succ n8 n7)
(succ n7 n6)
(succ n6 n5)
(succ n5 n4)
(succ n4 n3)
(succ n3 n2)
(succ n2 n1)
(succ n1 p0)
(succ p0 p1)
(succ p1 p2)
(succ p2 p3)
(succ p3 p4)
(succ p4 p5)
(succ p5 p6)
(succ p6 p7)
(succ p7 p8)
(succ p8 p9)
(succ p9 p10)
(succ p10 p11)
(succ p11 p12)
(succ p12 p13)
(succ p13 p14)
(succ p14 p15)
(succ p15 p16)
(succ p16 p17)
(succ p17 p18)
(succ p18 p19)
(succ p19 p20) 
(succ p20 p21)
(succ p21 p22)
(succ p22 p23)
(succ p23 p24)
(succ p24 p25)
(succ p25 p26)
(succ p26 p27)
(succ p27 p28)
(succ p28 p29)
(succ p29 p30)
(succ p30 p31)
(succ p31 p32)
(succ p32 p33)
(succ p33 p34)
(succ p34 p35)
(succ p35 p36)
(succ p36 p37)
(succ p37 p38)
(succ p38 p39)
(succ p39 p40)
(succ p40 p41)
(succ p41 p42)
(succ p42 p43)
(succ p43 p44)
(succ p44 p45)
(succ p45 p46)
(succ p46 p47)
(succ p47 p48)
(succ p48 p49)
(succ p49 p50)

(number n50)
(number n49)
(number n48)
(number n47)
(number n46)
(number n45)
(number n44)
(number n43)
(number n42)
(number n41)
(number n40)
(number n39)
(number n38)
(number n37)
(number n36)
(number n35)
(number n34)
(number n33)
(number n32)
(number n31)
(number n30)
(number n29)
(number n28)
(number n27)
(number n26)
(number n25)
(number n24)
(number n23)
(number n22)
(number n21)
(number n20)
(number n19)
(number n18)
(number n17)
(number n16)
(number n15)
(number n14)
(number n13)
(number n12)
(number n11)
(number n10)
(number n9)
(number n8)
(number n7)
(number n6)
(number n5)
(number n4)
(number n3)
(number n2)
(number n1)
(number p0)
(number p1)
(number p2)
(number p3)
(number p4)
(number p5)
(number p6)
(number p7)
(number p8)
(number p9)
(number p10)
(number p11)
(number p12)
(number p13)
(number p14)
(number p15)
(number p16)
(number p17)
(number p18)
(number p19) 
(number p20)
(number p21)
(number p22)
(number p23)
(number p24)
(number p25)
(number p26)
(number p27)
(number p28)
(number p29)
(number p30)
(number p31)
(number p32)
(number p33)
(number p34)
(number p35)
(number p36)
(number p37)
(number p38)
(number p39)
(number p40)
(number p41)
(number p42)
(number p43)
(number p44)
(number p45)
(number p46)
(number p47)
(number p48)
(number p49)
(number p50)

; Define addition and smaller for integers

(<= (smaller ?x ?y)
	(succ ?x ?y))
(<= (smaller ?x ?z)
	(succ ?x ?y)
	(smaller ?y ?z))

(<= (add ?x p0 ?x)
	(number ?x))
(<= (add ?x ?y ?z)
	(smaller p0 ?y)
	(add_positive ?x ?y ?z))
(<= (add ?x ?y ?z)
	(smaller ?y p0)
	(add_negative ?x ?y ?z))

; positive y
(<= (add_positive ?x p0 ?x)
	(number ?x))
(<= (add_positive ?x ?y ?z)
	(distinct ?y p0)
    (succ ?y1 ?y)
    (succ ?x ?x1)
    (add_positive ?x1 ?y1 ?z))

; negative y
(<= (add_negative ?x p0 ?x)
	(number ?x))
(<= (add_negative ?x ?y ?z)
	(distinct ?y p0)
    (succ ?y ?y1)
    (succ ?x1 ?x)
    (add_negative ?x1 ?y1 ?z))

sees_XML(...) rules

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