Gamemaster
General
Game
Playing
leafymcfallface
Description
There are two caterpillars on a grid of leaves, initially at opposite corners. Each time they move, they eat the leaf behind them and move to a horizontally or vertically adjacent non-empty square. If a player still has a move and its opponent has no moves (i.e. it is surrounded by empty space), then the first player gets 100 points and the second player gets 0 points. Otherwise, both players get 0 points.
Rulesheet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% leafymcfallface %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% metadata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% role(red) role(blue) opp(red,blue) opp(blue,red) base(leaf(X,Y)) :- index(X) & index(Y) base(isplayer(X,Y,R)) :- index(X) & index(Y) & role(R) base(control(R)) :- role(R) action(move(X,Y)) :- index(X) & index(Y) index(1) index(2) index(3) index(4) index(5) index(6) index(7) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% init(leaf(1,2)) init(leaf(1,3)) init(leaf(1,4)) init(leaf(1,5)) init(leaf(1,6)) init(leaf(1,7)) init(leaf(2,1)) init(leaf(2,2)) init(leaf(2,3)) init(leaf(2,4)) init(leaf(2,5)) init(leaf(2,6)) init(leaf(2,7)) init(leaf(3,1)) init(leaf(3,2)) init(leaf(3,3)) init(leaf(3,4)) init(leaf(3,5)) init(leaf(3,6)) init(leaf(3,7)) init(leaf(4,1)) init(leaf(4,2)) init(leaf(4,3)) init(leaf(4,4)) init(leaf(4,5)) init(leaf(4,6)) init(leaf(4,7)) init(leaf(5,1)) init(leaf(5,2)) init(leaf(5,3)) init(leaf(5,4)) init(leaf(5,5)) init(leaf(5,6)) init(leaf(5,7)) init(leaf(6,1)) init(leaf(6,2)) init(leaf(6,3)) init(leaf(6,4)) init(leaf(6,5)) init(leaf(6,6)) init(leaf(6,7)) init(leaf(7,1)) init(leaf(7,2)) init(leaf(7,3)) init(leaf(7,4)) init(leaf(7,5)) init(leaf(7,6)) init(isplayer(1,1,red)) init(isplayer(7,7,blue)) init(control(red)) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% legal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% legal(move(X,Y)) :- control(R) & isplayer(N,Y,R) & close(N,X) & leaf(X,Y) & opp(R,O) & ~isplayer(X,Y,O) legal(move(X,Y)) :- control(R) & isplayer(X,N,R) & close(N,Y) & leaf(X,Y) & opp(R,O) & ~isplayer(X,Y,O) close(1,2) close(2,3) close(3,4) close(4,5) close(5,6) close(6,7) close(2,1) close(3,2) close(4,3) close(5,4) close(6,5) close(7,6) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% operations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move(X,Y) :: control(R) & isplayer(OX,OY,R) ==> ~leaf(X,Y) & ~isplayer(OX,OY,R) & isplayer(X,Y,R) move(X,Y) :: control(red) ==> ~control(red) & control(blue) move(X,Y) :: control(blue) ==> ~control(blue) & control(red) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% goal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% goal(red,0) :- control(red) & ~hasmove goal(red,100) :- control(blue) & ~hasmove goal(Role,50) :- role(Role) & hasmove(red) goal(blue,0) :- control(blue) & ~hasmove goal(blue,100) :- control(red) & ~hasmove %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% terminal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% terminal :- ~hasmove hasmove :- legal(A) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Stylesheet
//============================================================================== // leafymcfallface //============================================================================== function renderstate (state) {var role = compfindx('R',seq('control','R'),state,library); var table = document.createElement('table'); table.setAttribute('border','0'); var row = table.insertRow(table.rows.length); var cell = row.insertCell(0); var board = renderboard(state); cell.appendChild(board); row = table.insertRow(table.rows.length); var cell = row.insertCell(0); cell.setAttribute('align','center'); cell.setAttribute('style','font-size:20px'); if (compfindp('terminal',state,library)) {cell.innerHTML = 'Game over'} else {cell.innerHTML = 'Control: ' + role}; return table} function renderboard (state) {var table = document.createElement('table'); table.setAttribute('cellspacing','0'); table.setAttribute('bgcolor','white'); table.setAttribute('border','10'); for (var i = 0; i < 7; i++) makerow(table,i,state); return table} function makerow (table,rownum,state) {var row =table.insertRow(rownum); for (var i = 0; i < 7; i++) makecell(row,rownum,i,state); return row} function makecell (row,rownum,colnum,state) {var cell = row.insertCell(colnum); cell.setAttribute('width','40'); cell.setAttribute('height','40'); cell.setAttribute('align','center'); cell.setAttribute('valign','center'); cell.setAttribute('style','font-family:helvetica;font-size:18pt'); rownum = (rownum+1).toString(); colnum = (colnum+1).toString(); var leaf = compfindp(seq('leaf',rownum,colnum),state,seq()); var player = compfindx("Z", seq('isplayer',rownum,colnum,"Z"),state,seq()); if (player) { cell.style.backgroundColor = player; } else if (leaf) { cell.style.backgroundColor = "green"; } return cell} //============================================================================== //============================================================================== //==============================================================================
Ownership