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

Game Description

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; The Golden Rectangle
;;;
;;; The game is similar to Connect-4 with the difference that the goal is to
;;; create a rectangle where each corner is at least 3 squares from the next
;;; one.
;;;
;;; modified 2009-10-29 by 2MC1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  (role red)
  (role yellow)

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


  (init (cell 1 0 dirt))
  (init (cell 2 0 dirt))
  (init (cell 3 0 dirt))
  (init (cell 4 0 dirt))
  (init (cell 5 0 dirt))
  (init (cell 6 0 dirt))
  (init (cell 7 0 dirt))

  (init (cell 1 1 b))
  (init (cell 1 2 b))
  (init (cell 1 3 b))
  (init (cell 1 4 b))
  (init (cell 1 5 b))
  (init (cell 1 6 b))
  
  (init (cell 2 1 b))
  (init (cell 2 2 b))
  (init (cell 2 3 b))
  (init (cell 2 4 b))
  (init (cell 2 5 b))
  (init (cell 2 6 b))
  
  (init (cell 3 1 b))
  (init (cell 3 2 b))
  (init (cell 3 3 b))
  (init (cell 3 4 b))
  (init (cell 3 5 b))
  (init (cell 3 6 b))
  
  (init (cell 4 1 b))
  (init (cell 4 2 b))
  (init (cell 4 3 b))
  (init (cell 4 4 b))
  (init (cell 4 5 b))
  (init (cell 4 6 b))
  
  (init (cell 5 1 b))
  (init (cell 5 2 b))
  (init (cell 5 3 b))
  (init (cell 5 4 b))
  (init (cell 5 5 b))
  (init (cell 5 6 b))
  
  (init (cell 6 1 b))
  (init (cell 6 2 b))
  (init (cell 6 3 b))
  (init (cell 6 4 b))
  (init (cell 6 5 b))
  (init (cell 6 6 b))
  
  (init (cell 7 1 b))
  (init (cell 7 2 b))
  (init (cell 7 3 b))
  (init (cell 7 4 b))
  (init (cell 7 5 b))
  (init (cell 7 6 b))
  
  (init (control red))

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

(<= (legal ?p (mark ?x ?y) )
	(true(cell ?x ?y dirt ))
	(true(control ?p)) )
(<= (legal red noop)
	(true(cell ?x ?y dirt))
	(true(control yellow)) )
(<= (legal yellow noop)
	(true(cell ?x ?y dirt))
	(true (control red)) )

(<= (next (cell ?m ?n y))
	(does yellow (mark ?m ?n)) )
(<= (next (cell ?m ?n r))
	(does red (mark ?m ?n)) )
(<= (next (cell ?m ?p dirt))
	(does ?player (mark ?m ?n))
	(succ ?n ?p)
	(lte ?p 7) )
(<= (next (cell ?m ?n ?w))
	(true (cell ?m ?n ?w))
	(distinct ?w b)
	(distinct ?w dirt) )
(<= (next (cell ?m ?n dirt))
	(true (cell ?m ?n dirt))
	(does ?player (mark ?j ?k))
	(distinct ?n ?k) )
(<= (next (cell ?m ?n dirt))
	(true (cell ?m ?n dirt))
	(does ?player (mark ?j ?k))
	(distinct ?m ?j) )
(<= (next (cell ?m ?n b))
	(true (cell ?m ?n b))
	(does ?player (mark ?j ?k))
	(distinct ?m ?j) )
(<= (next (cell ?m ?n b))
	(true (cell ?m ?n b))
	(does ?player (mark ?j ?k))
	(succ ?k ?x)
	(distinct ?n ?x) )
(<= (next (control yellow))
	(true (control red)) )
(<= (next (control red))
	(true (control yellow)) )

(<= (checkDist ?m ?n)
	(lte ?z ?n)
	(succ ?m ?x)
	(succ ?x ?y)
	(succ ?y ?z) )
(<= (checkRow ?x ?y ?a ?y)
	(checkDist ?x ?a)
	(number ?y) )
(<= (checkCol ?x ?y ?x ?b)
	(checkDist ?y ?b)
	(number ?x) )
(<= (checkRect ?ax ?ay ?bx ?by ?cx ?cy ?dx ?dy)
	(checkRow ?ax ?ay ?cx ?cy)
	(checkRow ?bx ?by ?dx ?dy)
	(checkCol ?ax ?ay ?bx ?by)
	(checkCol ?cx ?cy ?dx ?dy) )
(<= (rectangle ?player)
	(checkRect ?ax ?ay ?bx ?by ?cx ?cy ?dx ?dy)
	(true (cell ?ax ?ay ?player))
	(true (cell ?bx ?by ?player))
	(true (cell ?cx ?cy ?player))
	(true (cell ?dx ?dy ?player)) )

(<= open
	(true(cell ?m ?n dirt)) )

(<= terminal
	(rectangle y) )
(<= terminal
	(rectangle r) )
(<= terminal
	(not open) )

(<= (goal red 100)
	(rectangle r) )
(<= (goal red 0)
	(rectangle y)  )
(<= (goal red 0)
	(not open)
	(not (rectangle r))
	(not (rectangle y)) )
(<= (goal yellow 100)
	(rectangle y) )
(<= (goal yellow 0)
	(rectangle r)  )
(<= (goal yellow 100)
	(not open)
	(not (rectangle r))
	(not (rectangle y)) )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; arithmetic 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(<= (lte 0 ?x)
        (number ?x))
        
(<= (lte ?x ?x)
        (number ?x))
        
(<= (lte ?x ?z)
    (succ ?y ?z)
    (lte ?x ?y))

(<= (lte ?x ?y)
    (succ ?x ?y))

(number 0)
(number 1)
(number 2)
(number 3)
(number 4)
(number 5)
(number 6)
(number 7)
(number 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) 

sees_XML(...) rules

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

; transform the cells such that the normal chess stylesheet understands them
(<= (sees_xml1 (cell ?x ?y b)) (true (cell ?x ?y b)))
(<= (sees_xml1 (cell ?x ?y red)) (true (cell ?x ?y r)))
(<= (sees_xml1 (cell ?x ?y yellow)) (true (cell ?x ?y y)))
(<= (sees_xml1 (control ?p)) (true (control ?p)))