Skip to content

Commit

Permalink
Merge pull request #5 from ggp-org/master
Browse files Browse the repository at this point in the history
Merge changes from ggp-org.
  • Loading branch information
AlexLandau committed Jun 21, 2015
2 parents a83f7b0 + 489ad3b commit f16defc
Show file tree
Hide file tree
Showing 15 changed files with 1,299 additions and 64 deletions.
5 changes: 5 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.alloyggp.griddle.gdlValidator</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
Expand Down
6 changes: 6 additions & 0 deletions war/root/games/amazonsSuicide_10x10/METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"gameName": "Amazons Suicide (10x10)",

"rulesheet": "amazonsSuicide_10x10.kif",
"stylesheet": "amazonsSuicide_10x10.xsl"
}
192 changes: 192 additions & 0 deletions war/root/games/amazonsSuicide_10x10/amazonsSuicide_10x10.kif
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
; Amazons Suicide 10x10 (variant)
;
; In this version of Amazons, moving and firing an arrow occur on separate turns.
; This vastly speeds up rule simulation relative to the earlier GDL representation.
;
; As a suicide/misere variant, goal values are the opposite of normal Amazons.

(role white)
(role black)

; Bases and inputs

(base (turn white move))
(base (turn white fire))
(base (turn black move))
(base (turn black fire))

(<= (base (cell ?x ?y white))
(index ?x)
(index ?y))
(<= (base (cell ?x ?y black))
(index ?x)
(index ?y))
(<= (base (cell ?x ?y arrow))
(index ?x)
(index ?y))
(<= (base (justMoved ?x ?y))
(index ?x)
(index ?y))

(<= (input ?player noop)
(role ?player))
(<= (input ?player (move ?x1 ?y1 ?x2 ?y2))
(role ?player)
(queenMove ?x1 ?y1 ?x2 ?y2))
(<= (input ?player (fire ?x ?y))
(role ?player)
(index ?x)
(index ?y))

; Initial state

(init (cell 1 4 white))
(init (cell 4 1 white))
(init (cell 7 1 white))
(init (cell 10 4 white))
(init (cell 1 7 black))
(init (cell 4 10 black))
(init (cell 7 10 black))
(init (cell 10 7 black))

(init (turn white move))

; Legal moves

(<= (legal white noop)
(true (turn black ?any)))
(<= (legal black noop)
(true (turn white ?any)))

(<= (legal ?player ?move)
(legalMove ?player ?move))
(<= (legalMove ?player (move ?x1 ?y1 ?x2 ?y2))
(true (turn ?player move))
(true (cell ?x1 ?y1 ?player))
(dir ?dir)
(openPath ?x1 ?y1 ?x2 ?y2 ?dir))
(<= (legalMove ?player (fire ?x2 ?y2))
(true (turn ?player fire))
(true (justMoved ?x1 ?y1))
(dir ?dir)
(openPath ?x1 ?y1 ?x2 ?y2 ?dir))

(<= (openPath ?x1 ?y1 ?x2 ?y2 ?dir)
(oneInDir ?x1 ?y1 ?x2 ?y2 ?dir)
(not (occupied ?x2 ?y2)))
; Ideal recursive call would probably look like this, but hard for provers to handle right...
;(<= (openPath ?x1 ?y1 ?x3 ?y3 ?dir)
; (openPath ?x1 ?y1 ?x2 ?y2 ?dir)
; (oneInDir ?x2 ?y2 ?x3 ?y3 ?dir)
; (not (occupied ?x3 ?y3)))
; This is in a sense "quadratic", because we also need to compute versions of openPath
; that start with each intermediate coordinate
(<= (openPath ?x1 ?y1 ?x3 ?y3 ?dir)
(oneInDir ?x1 ?y1 ?x2 ?y2 ?dir)
(not (occupied ?x2 ?y2))
(openPath ?x2 ?y2 ?x3 ?y3 ?dir))

(<= (occupied ?x ?y)
(true (cell ?x ?y ?any)))

; Game dynamics

(<= (next (turn ?player fire))
(true (turn ?player move)))
(<= (next (turn ?opponent move))
(true (turn ?player fire))
(opponent ?player ?opponent))

(<= (next (cell ?x2 ?y2 ?player))
(does ?player (move ?x1 ?y1 ?x2 ?y2)))
(<= (next (cell ?x ?y ?player))
(true (cell ?x ?y ?player))
(not (vacated ?x ?y)))
(<= (vacated ?x1 ?y1)
(does ?player (move ?x1 ?y1 ?x2 ?y2)))
(<= (next (justMoved ?x2 ?y2))
(does ?player (move ?x1 ?y1 ?x2 ?y2)))

(<= (next (cell ?x ?y arrow))
(does ?player (fire ?x ?y)))

; Game ending conditions
(<= terminal
(true (turn ?player ?any))
(not (anyLegalMove ?player)))
(<= (anyLegalMove ?player)
(legal ?player ?move))

(<= (goal ?player 100)
(true (turn ?player ?any)))
(<= (goal ?player 0)
(true (turn ?opponent ?any))
(opponent ?opponent ?player))

; Constants

(index 1)
(index 2)
(index 3)
(index 4)
(index 5)
(index 6)
(index 7)
(index 8)
(index 9)
(index 10)
(nextIndex 1 2)
(nextIndex 2 3)
(nextIndex 3 4)
(nextIndex 4 5)
(nextIndex 5 6)
(nextIndex 6 7)
(nextIndex 7 8)
(nextIndex 8 9)
(nextIndex 9 10)

(opponent white black)
(opponent black white)

(dir n)
(dir ne)
(dir e)
(dir se)
(dir s)
(dir sw)
(dir w)
(dir nw)

(<= (oneInDir ?x ?y1 ?x ?y2 n)
(index ?x)
(nextIndex ?y1 ?y2))
(<= (oneInDir ?x1 ?y1 ?x2 ?y2 ne)
(nextIndex ?x1 ?x2)
(nextIndex ?y1 ?y2))
(<= (oneInDir ?x1 ?y ?x2 ?y e)
(nextIndex ?x1 ?x2)
(index ?y))
(<= (oneInDir ?x1 ?y2 ?x2 ?y1 se)
(nextIndex ?x1 ?x2)
(nextIndex ?y1 ?y2))
(<= (oneInDir ?x ?y2 ?x ?y1 s)
(index ?x)
(nextIndex ?y1 ?y2))
(<= (oneInDir ?x2 ?y2 ?x1 ?y1 sw)
(nextIndex ?x1 ?x2)
(nextIndex ?y1 ?y2))
(<= (oneInDir ?x2 ?y ?x1 ?y w)
(nextIndex ?x1 ?x2)
(index ?y))
(<= (oneInDir ?x2 ?y1 ?x1 ?y2 nw)
(nextIndex ?x1 ?x2)
(nextIndex ?y1 ?y2))

(<= (queenMove ?x1 ?y1 ?x2 ?y2)
(dir ?dir)
(queenMoveDir ?x1 ?y1 ?x2 ?y2 ?dir))
(<= (queenMoveDir ?x1 ?y1 ?x2 ?y2 ?dir)
(oneInDir ?x1 ?y1 ?x2 ?y2 ?dir))
(<= (queenMoveDir ?x1 ?y1 ?x3 ?y3 ?dir)
(oneInDir ?x1 ?y1 ?x2 ?y2 ?dir)
(queenMoveDir ?x2 ?y2 ?x3 ?y3 ?dir))
112 changes: 112 additions & 0 deletions war/root/games/amazonsSuicide_10x10/amazonsSuicide_10x10.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="width" select="400"/>
<xsl:param name="height" select="400"/>

<xsl:template name="main" match="/">
<div>
<!-- Set Style -->
<style type="text/css" media="all">
td.cell {
width: <xsl:value-of select="$width * 0.1"/>px;
height: <xsl:value-of select="$height * 0.1"/>px;
border: 2px solid #000;
background-color: #CCCCCC;
align: center;
valign: middle;
}
table.board {
background-color: #000000;
}
img.piece {
width: <xsl:value-of select="$width * 0.9 * 0.1"/>px;
height: <xsl:value-of select="$height * 0.9 * 0.1"/>px;
}
</style>

<!-- Draw Board -->
<xsl:call-template name="board">
<xsl:with-param name="cols" select="10"/>
<xsl:with-param name="rows" select="10"/>
</xsl:call-template>
</div>
</xsl:template>

<xsl:template name="cell" match="state/fact">
<xsl:param name="row" select="1"/>
<xsl:param name="col" select="1"/>

<td class="cell">
<xsl:attribute name="id">
<xsl:value-of select="'cell_'"/>
<xsl:value-of select="$col"/>
<xsl:value-of select="$row"/>
</xsl:attribute>

<xsl:if test="//fact[relation='cell' and argument[1]=$col and argument[2]=$row and argument[3]='arrow']">
<xsl:attribute name="style">background-color: #222</xsl:attribute>
</xsl:if>

<center>
<xsl:if test="//fact[relation='cell' and argument[1]=$col and argument[2]=$row and argument[3]='white']"> <img class="piece" src="&ROOT;/resources/images/chess/White_Queen.png"/> </xsl:if>
<xsl:if test="//fact[relation='cell' and argument[1]=$col and argument[2]=$row and argument[3]='black']"> <img class="piece" src="&ROOT;/resources/images/chess/Black_Queen.png"/> </xsl:if>
</center>

</td>
</xsl:template>

<xsl:template name="board_row">
<xsl:param name="cols" select="1"/>
<xsl:param name="rows" select="1"/>
<xsl:param name="row" select="1"/>
<xsl:param name="col" select="1"/>

<xsl:call-template name="cell">
<xsl:with-param name="row" select="$row"/>
<xsl:with-param name="col" select="$col"/>
</xsl:call-template>

<xsl:if test="$col &lt; $cols">
<xsl:call-template name="board_row">
<xsl:with-param name="cols" select="$cols"/>
<xsl:with-param name="rows" select="$rows"/>
<xsl:with-param name="row" select="$row"/>
<xsl:with-param name="col" select="$col + 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

<xsl:template name="board_rows">
<xsl:param name="cols" select="1"/>
<xsl:param name="rows" select="1"/>
<xsl:param name="row" select="1"/>

<tr>
<xsl:call-template name="board_row">
<xsl:with-param name="cols" select="$cols"/>
<xsl:with-param name="rows" select="$rows"/>
<xsl:with-param name="row" select="$row"/>
</xsl:call-template>
</tr>

<xsl:if test="$row &lt; $rows">
<xsl:call-template name="board_rows">
<xsl:with-param name="cols" select="$cols"/>
<xsl:with-param name="rows" select="$rows"/>
<xsl:with-param name="row" select="$row + 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

<xsl:template name="board">
<xsl:param name="cols" select="1"/>
<xsl:param name="rows" select="1"/>

<table class="board">
<xsl:call-template name="board_rows">
<xsl:with-param name="cols" select="$cols"/>
<xsl:with-param name="rows" select="$rows"/>
</xsl:call-template>
</table>
</xsl:template>

</xsl:stylesheet>
6 changes: 6 additions & 0 deletions war/root/games/amazonsTorus_10x10/METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"gameName": "Amazons Torus (10x10)",

"rulesheet": "amazonsTorus_10x10.kif",
"stylesheet": "amazonsTorus_10x10.xsl"
}
Loading

0 comments on commit f16defc

Please sign in to comment.