Gamemaster
General
Game
Playing
donttouch
Description
Two players take turns placing Xs and Os on a 4x4 grid. The game ends once a player marks a square adjacent to its own mark (not including diagonals).
Rulesheet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% /gamemaster/library/alquerque/rulesheet.hrf %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% metadata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% role(x) role(o) base(cell(M,N,x)) :- index(M) & index(N) base(cell(M,N,o)) :- index(M) & index(N) base(cell(M,N,b)) :- index(M) & index(N) base(control(R)) :- role(R) action(mark(M,N)) :- role(R) & index(M) & index(N) index(1) index(2) index(3) index(4) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% init(cell(1,1,b)) init(cell(1,2,b)) init(cell(1,3,b)) init(cell(1,4,b)) init(cell(2,1,b)) init(cell(2,2,b)) init(cell(2,3,b)) init(cell(2,4,b)) init(cell(3,1,b)) init(cell(3,2,b)) init(cell(3,3,b)) init(cell(3,4,b)) init(cell(4,1,b)) init(cell(4,2,b)) init(cell(4,3,b)) init(cell(4,4,b)) init(control(x)) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% legal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% legal(mark(X,Y)) :- cell(X,Y,b) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% operations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% mark(M,N) :: control(R) ==> cell(M,N,R) & ~cell(M,N,b) mark(M,N) :: control(x) ==> ~control(x) & control(o) mark(M,N) :: control(o) ==> ~control(o) & control(x) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% goal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% goal(x,0) :- touch(x) & ~touch(o) goal(x,50) :- ~touch(x) & ~touch(o) goal(x,100) :- ~touch(x) & touch(o) goal(o,0) :- ~touch(x) & touch(o) goal(o,50) :- ~touch(x) & ~touch(o) goal(o,100) :- touch(x) & ~touch(o) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% terminal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% terminal :- touch(x) terminal :- touch(o) terminal :- ~open %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Views %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% up(M,X) :-succ(M,M2) & cell(M,1,X) right(X) :- cell(1,3,X) & cell(2,2,X) & cell(3,1,X) touch(Player) :- cell(X1,Y,Player) & succ(X1,X2) & cell(X2,Y,Player) touch(Player) :- cell(X,Y1,Player) & succ(Y1,Y2) & cell(X,Y2,Player) open :- cell(M,N,b) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Facts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% succ(1,2) succ(2,3) succ(3,4) succ(4,5) succ(5,6) succ(6,7) succ(7,8) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Stylesheet
//============================================================================== // donttouch //============================================================================== 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'); makerow(table,0,state); makerow(table,1,state); makerow(table,2,state); makerow(table,3,state); return table} function makerow (table,rownum,state) {var row =table.insertRow(rownum); makecell(row,rownum,0,state); makecell(row,rownum,1,state); makecell(row,rownum,2,state); makecell(row,rownum,3,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 mark = compfindx('Z',seq('cell',rownum,colnum,'Z'),state,seq()); if (mark && mark != 'b') {cell.innerHTML = mark} else {cell.innerHTML = ' '}; return cell} //============================================================================== //============================================================================== //==============================================================================
Ownership