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

Game Description

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; CephalopodMicro
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; GDL by Ethan Dreyfuss
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Description:
;;;; Cephalopod is a board game played with dice (with no randomness!) 
;;;; invented by Mark Steere in 2006.
;;;; See http://vying.org/games/cephalopod for details.
;;;; This is a smaller variant played on a 3x3 board instead of 3x5 or 5x5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(role red)
(role black)
(init (control red))

;;;; LEGAL MOVES ;;;;

(<= (legal red noop)
	(true (control black)))
	
(<= (legal black noop)
	(true (control red)))
	
(<= (legal red noop)
	boardFull)
	
(<= (legal black noop)
	boardFull)
	
(<= (legal ?player (play ?x ?y ?amount ?captureMask))
  (true (control ?player))
	(empty ?x ?y)
	(side ?amount)
	(mask ?captureMask)
	(captureSum ?x ?y ?amount ?captureMask))
	
(<= (legal ?player (play ?x ?y 1 0))
  (numX ?y)
  (true (control ?player))
	(empty ?x ?y)
	(noCaptureSum ?x ?y))
	
;;;;; Physics ;;;;;;;;;;

;;Cells persist if not the play location and not a capture location
(<= (next (cell ?x ?y ?val ?player))
	(true (cell ?x ?y ?val ?player))
	(not (capturedAt ?x ?y)))
	
(<= (capturedAt ?x ?y)
	(does ?player (play ?x2 ?y2 ?amount ?captureMask))
	(inMask ?x2 ?y2 ?captureMask ?x ?y))
	
;;Cells become whatever is played at that location
(<= (next (cell ?x ?y ?val ?player))
	(does ?player (play ?x ?y ?val ?captureMask)))
	
(<= (next (control red))
	(true (control black)))
	
(<= (next (control black))
	(true (control red)))
	
;;;; Terminal and Goal ;;;;;;

(<= terminal
	boardFull)
	
(<= (goal black 100)
	(morePieces black red))
	
(<= (goal red 0)
	(morePieces black red))
	
(<= (goal red 100)
	(morePieces red black))
	
(<= (goal black 0)
	(morePieces red black))
	
(<= (goal black 0)
	(not boardFull))
	
(<= (goal red 0)
	(not boardFull))
	
;;;;;; Helper Methods (AKA view) ;;;;;;;;;

;; There is no possible capture at a given square
(<= (noCaptureSum ?x ?y)
  (num ?x)
  (numX ?y)
  (not (isCaptureSum ?x ?y)))
  
(<= (isCaptureSum ?x ?y)
  (captureSum ?x ?y ?val ?captureMask))

;; Sums up adjacent squares
(<= (captureSum ?x ?y ?amount ?captureMask)
  (side ?amount)
  (leftVal ?captureMask ?x ?y ?val1)
  (topVal ?captureMask ?x ?y ?val2)
  (bottomVal ?captureMask ?x ?y ?val3)
  (rightVal ?captureMask ?x ?y ?val4)
  (not (threeZeros ?val1 ?val2 ?val3 ?val4))
  (fourSum ?val1 ?val2 ?val3 ?val4 ?amount))
  
(<= (threeZeros ?val 0 0 0)
    (side ?val))
(<= (threeZeros 0 ?val 0 0)
    (side ?val))
(<= (threeZeros 0 0 ?val 0)
    (side ?val))
(<= (threeZeros 0 0 0 ?val)
    (side ?val))
(threeZeros 0 0 0 0)
  
(<= (fourSum ?a ?b ?c ?d ?result)
  (sum ?a ?b ?res1)
  (sum ?c ?d ?res2)
  (sum ?res1 ?res2 ?result))
  
(<= (leftVal ?captureMask ?x ?y 0)
  (mask ?captureMask)
  (num ?x)
  (numX ?y)
  (not (leftBit ?captureMask)))
  
(<= (leftVal ?captureMask ?x ?y 0)
  (leftBit ?captureMask)
  (before ?x ?xMinus)
  (empty ?xMinus ?y))
  
(<= (leftVal ?captureMask ?x ?y ?val)
  (leftBit ?captureMask)
  (before ?x ?xMinus)
  (true (cell ?xMinus ?y ?val ?player)))
  
(<= (topVal ?captureMask ?x ?y 0)
  (mask ?captureMask)
  (num ?x)
  (numX ?y)
  (not (topBit ?captureMask)))

(<= (topVal ?captureMask ?x ?y 0)
  (topBit ?captureMask)
  (before ?y ?yMinus)
  (empty ?x ?yMinus))
  
(<= (topVal ?captureMask ?x ?y ?val)
  (topBit ?captureMask)
  (before ?y ?yMinus)
  (true (cell ?x ?yMinus ?val ?player)))
  
(<= (rightVal ?captureMask ?x ?y 0)
  (mask ?captureMask)
  (num ?x)
  (numX ?y)
  (not (rightBit ?captureMask)))
  
(<= (rightVal ?captureMask ?x ?y 0)
  (rightBit ?captureMask)
  (after ?x ?xPlus)
  (empty ?xPlus ?y))
  
(<= (rightVal ?captureMask ?x ?y ?val)
  (rightBit ?captureMask)
  (after ?x ?xPlus)
  (true (cell ?xPlus ?y ?val ?player)))
  
(<= (bottomVal ?captureMask ?x ?y 0)
  (mask ?captureMask)
  (num ?x)
  (numX ?y)
  (not (bottomBit ?captureMask)))
  
(<= (bottomVal ?captureMask ?x ?y 0)
  (bottomBit ?captureMask)
  (afterX ?y ?yPlus)
  (empty ?x ?yPlus))
  
(<= (bottomVal ?captureMask ?x ?y ?val)
  (bottomBit ?captureMask)
  (afterX ?y ?yPlus)
  (true (cell ?x ?yPlus ?val ?player)))

(<= (notInMask ?xOrig ?yOrig ?captureMask ?x ?y)
	(num ?x)
	(numX ?y)
	(num ?xOrig)
	(numX ?yOrig)
	(mask ?captureMask)
	(not (inMask ?xOrig ?yOrig ?captureMask ?x ?y)))
	
(<= (empty ?x ?y)
	(num ?x)
	(numX ?y)
	(not (true (cell ?x ?y 1 red)))
	(not (true (cell ?x ?y 2 red)))
	(not (true (cell ?x ?y 3 red)))
	(not (true (cell ?x ?y 4 red)))
	(not (true (cell ?x ?y 5 red)))
	(not (true (cell ?x ?y 6 red)))
	(not (true (cell ?x ?y 1 black)))
	(not (true (cell ?x ?y 2 black)))
	(not (true (cell ?x ?y 3 black)))
	(not (true (cell ?x ?y 4 black)))
	(not (true (cell ?x ?y 5 black)))
	(not (true (cell ?x ?y 6 black)))
	)
		
(<= (empty ?x OFFBOARD)
  (num ?x))
  
(<= (empty OFFBOARD ?x)
  (numX ?x))
	
(<= boardFull
	(not someCellEmpty))
	
(<= someCellEmpty
  (num ?x)
  (numX ?y)
	(empty ?x ?y))
	
(<= (morePieces ?player1 ?player2)
	(pieceCount ?player1 ?val1)
	(pieceCount ?player2 ?val2)
	(greater ?val1 ?val2))
	
(<= (pieceCount ?player ?val)
	(addRow 0 1 ?player ?result1)
	(addRow ?result1 2 ?player ?result2)	
	(addRow ?result2 3 ?player ?val))
	
;; (<= (next (count ?player ?num))
;;   (pieceCount ?player ?num))
	
(<= (addRow ?inVal ?row ?player ?outVal)	
	(addCell ?inVal ?row 1 ?player ?result1)
	(addCell ?result1 ?row 2 ?player ?result2)	
	(addCell ?result2 ?row 3 ?player ?outVal))
	
(<= (addCell ?in ?row ?col ?player ?out)
	(true (cell ?row ?col ?val ?player))
	(plusplus ?in ?out))

(<= (addCell ?in ?row ?col ?player ?in)
  (oneThroughTwentyFive ?in)
	(role ?player)
	(role ?player2)
	(distinct ?player ?player2)
	(true (cell ?row ?col ?val ?player2)))
	
(<= (oneThroughTwentyFive ?x)
  (plusplus ?x ?y))
  
(<= (oneThroughTwentyFive ?x)
  (plusplus ?y ?x))
	
;;Before and After;;
(before 1 OFFBOARD) (before 2 1) (before 3 2)
(after 1 2)  (after 2 3)  (after 3  OFFBOARD)
(afterX 1 2)  (afterX 2 3)  (afterX 3 OFFBOARD)

;;;;;  Constants ;;;;;
(num 1) (num 2) (num 3)
(numX 1) (numX 2) (numX 3)
(side 1) (side 2) (side 3) (side 4) (side 5) (side 6)

;;;;;  Math ;;;;;;
(sum 0 0 0)
(sum 0 1 1)
(sum 0 2 2)
(sum 0 3 3)
(sum 0 4 4)
(sum 0 5 5)
(sum 0 6 6)
(sum 1 0 1)
(sum 1 1 2)
(sum 1 2 3)
(sum 1 3 4)
(sum 1 4 5)
(sum 1 5 6)
(sum 2 0 2)
(sum 2 1 3)
(sum 2 2 4)
(sum 2 3 5)
(sum 2 4 6)
(sum 3 0 3)
(sum 3 1 4)
(sum 3 2 5)
(sum 3 3 6)
(sum 4 0 4)
(sum 4 1 5)
(sum 4 2 6)
(sum 5 0 5)
(sum 5 1 6)
(sum 6 0 6)

(plusplus 0 1)
(plusplus 1 2)
(plusplus 2 3)
(plusplus 3 4)
(plusplus 4 5)
(plusplus 5 6)
(plusplus 6 7)
(plusplus 7 8)
(plusplus 8 9)

(greater 1 0)
(greater 2 0)
(greater 2 1)
(greater 3 0)
(greater 3 1)
(greater 3 2)
(greater 4 0)
(greater 4 1)
(greater 4 2)
(greater 4 3)
(greater 5 0)
(greater 5 1)
(greater 5 2)
(greater 5 3)
(greater 5 4)
(greater 6 0)
(greater 6 1)
(greater 6 2)
(greater 6 3)
(greater 6 4)
(greater 6 5)
(greater 7 0)
(greater 7 1)
(greater 7 2)
(greater 7 3)
(greater 7 4)
(greater 7 5)
(greater 7 6)
(greater 8 0)
(greater 8 1)
(greater 8 2)
(greater 8 3)
(greater 8 4)
(greater 8 5)
(greater 8 6)
(greater 8 7)
(greater 9 0)
(greater 9 1)
(greater 9 2)
(greater 9 3)
(greater 9 4)
(greater 9 5)
(greater 9 6)
(greater 9 7)
(greater 9 8)

;;; Masks ;;;;
(mask 3)
(mask 5)
(mask 6)
(mask 7)
(mask 9)
(mask 10)
(mask 11)
(mask 12)
(mask 13)
(mask 14)
(mask 15)

(leftBit 1) 
(topBit 2) 
(leftBit 3) (topBit 3) 
(bottomBit 4) 
(leftBit 5) (bottomBit 5) 
(topBit 6) (bottomBit 6) 
(leftBit 7) (topBit 7) (bottomBit 7) 
(rightBit 8) 
(leftBit 9) (rightBit 9) 
(topBit 10) (rightBit 10) 
(leftBit 11) (topBit 11) (rightBit 11) 
(bottomBit 12) (rightBit 12) 
(leftBit 13) (bottomBit 13) (rightBit 13) 
(topBit 14) (bottomBit 14) (rightBit 14) 
(leftBit 15) (topBit 15) (bottomBit 15) (rightBit 15) 

;;;;; Fatty flattened inMask relation (generated by short little Java program) ;;;;;
(inMask 1 2 3 1 1)
(inMask 1 3 3 1 2)
(inMask 2 1 3 1 1)
(inMask 2 2 3 1 2)
(inMask 2 2 3 2 1)
(inMask 2 3 3 1 3)
(inMask 2 3 3 2 2)
(inMask 3 1 3 2 1)
(inMask 3 2 3 2 2)
(inMask 3 2 3 3 1)
(inMask 3 3 3 2 3)
(inMask 3 3 3 3 2)
(inMask 1 1 5 1 2)
(inMask 1 2 5 1 3)
(inMask 2 1 5 1 1)
(inMask 2 1 5 2 2)
(inMask 2 2 5 1 2)
(inMask 2 2 5 2 3)
(inMask 2 3 5 1 3)
(inMask 3 1 5 2 1)
(inMask 3 1 5 3 2)
(inMask 3 2 5 2 2)
(inMask 3 2 5 3 3)
(inMask 3 3 5 2 3)
(inMask 1 1 6 1 2)
(inMask 1 2 6 1 1)
(inMask 1 2 6 1 3)
(inMask 1 3 6 1 2)
(inMask 2 1 6 2 2)
(inMask 2 2 6 2 1)
(inMask 2 2 6 2 3)
(inMask 2 3 6 2 2)
(inMask 3 1 6 3 2)
(inMask 3 2 6 3 1)
(inMask 3 2 6 3 3)
(inMask 3 3 6 3 2)
(inMask 1 1 7 1 2)
(inMask 1 2 7 1 1)
(inMask 1 2 7 1 3)
(inMask 1 3 7 1 2)
(inMask 2 1 7 1 1)
(inMask 2 1 7 2 2)
(inMask 2 2 7 1 2)
(inMask 2 2 7 2 1)
(inMask 2 2 7 2 3)
(inMask 2 3 7 1 3)
(inMask 2 3 7 2 2)
(inMask 3 1 7 2 1)
(inMask 3 1 7 3 2)
(inMask 3 2 7 2 2)
(inMask 3 2 7 3 1)
(inMask 3 2 7 3 3)
(inMask 3 3 7 2 3)
(inMask 3 3 7 3 2)
(inMask 1 1 9 2 1)
(inMask 1 2 9 2 2)
(inMask 1 3 9 2 3)
(inMask 2 1 9 1 1)
(inMask 2 1 9 3 1)
(inMask 2 2 9 1 2)
(inMask 2 2 9 3 2)
(inMask 2 3 9 1 3)
(inMask 2 3 9 3 3)
(inMask 3 1 9 2 1)
(inMask 3 2 9 2 2)
(inMask 3 3 9 2 3)
(inMask 1 1 10 2 1)
(inMask 1 2 10 1 1)
(inMask 1 2 10 2 2)
(inMask 1 3 10 1 2)
(inMask 1 3 10 2 3)
(inMask 2 1 10 3 1)
(inMask 2 2 10 2 1)
(inMask 2 2 10 3 2)
(inMask 2 3 10 2 2)
(inMask 2 3 10 3 3)
(inMask 3 2 10 3 1)
(inMask 3 3 10 3 2)
(inMask 1 1 11 2 1)
(inMask 1 2 11 1 1)
(inMask 1 2 11 2 2)
(inMask 1 3 11 1 2)
(inMask 1 3 11 2 3)
(inMask 2 1 11 1 1)
(inMask 2 1 11 3 1)
(inMask 2 2 11 1 2)
(inMask 2 2 11 2 1)
(inMask 2 2 11 3 2)
(inMask 2 3 11 1 3)
(inMask 2 3 11 2 2)
(inMask 2 3 11 3 3)
(inMask 3 1 11 2 1)
(inMask 3 2 11 2 2)
(inMask 3 2 11 3 1)
(inMask 3 3 11 2 3)
(inMask 3 3 11 3 2)
(inMask 1 1 12 1 2)
(inMask 1 1 12 2 1)
(inMask 1 2 12 1 3)
(inMask 1 2 12 2 2)
(inMask 1 3 12 2 3)
(inMask 2 1 12 2 2)
(inMask 2 1 12 3 1)
(inMask 2 2 12 2 3)
(inMask 2 2 12 3 2)
(inMask 2 3 12 3 3)
(inMask 3 1 12 3 2)
(inMask 3 2 12 3 3)
(inMask 1 1 13 1 2)
(inMask 1 1 13 2 1)
(inMask 1 2 13 1 3)
(inMask 1 2 13 2 2)
(inMask 1 3 13 2 3)
(inMask 2 1 13 1 1)
(inMask 2 1 13 2 2)
(inMask 2 1 13 3 1)
(inMask 2 2 13 1 2)
(inMask 2 2 13 2 3)
(inMask 2 2 13 3 2)
(inMask 2 3 13 1 3)
(inMask 2 3 13 3 3)
(inMask 3 1 13 2 1)
(inMask 3 1 13 3 2)
(inMask 3 2 13 2 2)
(inMask 3 2 13 3 3)
(inMask 3 3 13 2 3)
(inMask 1 1 14 1 2)
(inMask 1 1 14 2 1)
(inMask 1 2 14 1 1)
(inMask 1 2 14 1 3)
(inMask 1 2 14 2 2)
(inMask 1 3 14 1 2)
(inMask 1 3 14 2 3)
(inMask 2 1 14 2 2)
(inMask 2 1 14 3 1)
(inMask 2 2 14 2 1)
(inMask 2 2 14 2 3)
(inMask 2 2 14 3 2)
(inMask 2 3 14 2 2)
(inMask 2 3 14 3 3)
(inMask 3 1 14 3 2)
(inMask 3 2 14 3 1)
(inMask 3 2 14 3 3)
(inMask 3 3 14 3 2)
(inMask 1 1 15 1 2)
(inMask 1 1 15 2 1)
(inMask 1 2 15 1 1)
(inMask 1 2 15 1 3)
(inMask 1 2 15 2 2)
(inMask 1 3 15 1 2)
(inMask 1 3 15 2 3)
(inMask 2 1 15 1 1)
(inMask 2 1 15 2 2)
(inMask 2 1 15 3 1)
(inMask 2 2 15 1 2)
(inMask 2 2 15 2 1)
(inMask 2 2 15 2 3)
(inMask 2 2 15 3 2)
(inMask 2 3 15 1 3)
(inMask 2 3 15 2 2)
(inMask 2 3 15 3 3)
(inMask 3 1 15 2 1)
(inMask 3 1 15 3 2)
(inMask 3 2 15 2 2)
(inMask 3 2 15 3 1)
(inMask 3 2 15 3 3)
(inMask 3 3 15 2 3)
(inMask 3 3 15 3 2)

sees_XML(...) rules

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