Gamemaster
General
Game
Playing
leafymcfairface
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 at any point the player in control has no moves (i.e. there is no adjacent leafy cell), then the game terminates and the scores of both players are equal to the number of cells visited.
Rulesheet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% leafymcfairface %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% metadata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% role(red) role(blue) base(leaf(X,Y)) :- index(X) & index(Y) base(isplayer(X,Y,R)) :- index(X) & index(Y) & role(R) base(score(R,1)) :- role(R) base(score(R,N)) :- role(R) & succ(M,N) 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) index(8) index(9) index(10) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% init(leaf(1,N)) :- index(N) & distinct(N,1) init(leaf(2,N)) :- index(N) init(leaf(3,N)) :- index(N) init(leaf(4,N)) :- index(N) init(leaf(5,N)) :- index(N) init(leaf(6,N)) :- index(N) init(leaf(7,N)) :- index(N) init(leaf(8,N)) :- index(N) init(leaf(9,N)) :- index(N) init(leaf(10,N)) :- index(N) & distinct(N,10) init(isplayer(1,1,red)) init(isplayer(10,10,blue)) init(score(red,1)) init(score(blue,1)) init(control(red)) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% legal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% legal(move(X,Y)) :- control(R) & isplayer(N,Y,R) & close(N,X) & leaf(X,Y) legal(move(X,Y)) :- control(R) & isplayer(X,N,R) & close(N,Y) & leaf(X,Y) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% 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) move(X,Y) :: control(R) & score(R,ON) & succ(ON,NN) ==> ~score(R,ON) & score(R,NN) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% goal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% goal(R,N) :- score(R,N) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% terminal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% terminal :- ~hasmove hasmove :- legal(A) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Facts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% close(1,2) close(2,3) close(3,4) close(4,5) close(5,6) close(6,7) close(7,8) close(8,9) close(9,10) close(2,1) close(3,2) close(4,3) close(5,4) close(6,5) close(7,6) close(8,7) close(9,8) close(10,9) succ(1,2) succ(2,3) succ(3,4) succ(4,5) succ(5,6) succ(6,7) succ(7,8) succ(8,9) succ(9,10) succ(10,11) succ(11,12) succ(12,13) succ(13,14) succ(14,15) succ(15,16) succ(16,17) succ(17,18) succ(18,19) succ(19,20) succ(20,21) succ(21,22) succ(22,23) succ(23,24) succ(24,25) succ(25,26) succ(26,27) succ(27,28) succ(28,29) succ(29,30) succ(31,32) succ(32,33) succ(33,34) succ(34,35) succ(35,36) succ(36,37) succ(37,38) succ(38,39) succ(39,40) succ(41,42) succ(42,43) succ(43,44) succ(44,45) succ(45,46) succ(46,47) succ(47,48) succ(48,49) succ(49,50) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Stylesheet
//============================================================================== // leafymcfairface //============================================================================== 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<10; i++) makerow(table,i,state); return table} function makerow (table,rownum,state) {var row =table.insertRow(rownum); for (var i=0; i<10; 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