Gamemaster
General
Game
Playing
parallelknightthrough
Description
Parallelknightthrough is a game played on three 3x8 boards. White pieces on the bottom two rows of each board and black pieces on the top two rows of each board. Pieces move like chess knights, except that can only move forward. White wins if it advances a knight to the 8th row of the first board, and black wins if it advances a knight to the 1st row of the third board.
Rulesheet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% parallelknightthrough %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% metadata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% role(white) role(black) base(cell(B,X,Y,R)) :- board(B) & file(X) & rank(Y) & role(R) base(played(B)) :- board(B) base(step(1)) base(step(N)) :- succ(M,N) base(control(R)) :- role(R) action(move(B,X1,Y1,X2,Y2)) :- board(B) & knightmove(X1,Y1,X2,Y2) action(tick) board(a) board(b) board(c) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% init(cell(a,a,1,white)) init(cell(a,b,1,white)) init(cell(a,c,1,white)) init(cell(a,a,2,white)) init(cell(a,b,2,white)) init(cell(a,c,2,white)) init(cell(a,a,7,black)) init(cell(a,b,7,black)) init(cell(a,c,7,black)) init(cell(a,a,8,black)) init(cell(a,b,8,black)) init(cell(a,c,8,black)) init(cell(b,a,1,white)) init(cell(b,b,1,white)) init(cell(b,c,1,white)) init(cell(b,a,2,white)) init(cell(b,b,2,white)) init(cell(b,c,2,white)) init(cell(b,a,7,black)) init(cell(b,b,7,black)) init(cell(b,c,7,black)) init(cell(b,a,8,black)) init(cell(b,b,8,black)) init(cell(b,c,8,black)) init(cell(c,a,1,white)) init(cell(c,b,1,white)) init(cell(c,c,1,white)) init(cell(c,a,2,white)) init(cell(c,b,2,white)) init(cell(c,c,2,white)) init(cell(c,a,7,black)) init(cell(c,b,7,black)) init(cell(c,c,7,black)) init(cell(c,a,8,black)) init(cell(c,b,8,black)) init(cell(c,c,8,black)) init(step(1)) init(control(white)) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% legal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% legal(move(B,X1,Y1,X2,Y2)) :- control(white) & cell(B,X1,Y1,white) & ~played(B) & whiteknightmove(X1,Y1,X2,Y2) & ~cell(B,X2,Y2,white) legal(move(B,X1,Y1,X2,Y2)) :- control(black) & cell(B,X1,Y1,black) & ~played(B) & blackknightmove(X1,Y1,X2,Y2) & ~cell(B,X2,Y2,black) legal(tick) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% operations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move(B,X1,Y1,X2,Y2) :: cell(B,X1,Y1,R) ==> ~cell(B,X1,Y1,R) & cell(B,X2,Y2,R) move(B,X1,Y1,X2,Y2) :: cell(B,X2,Y2,R) ==> ~cell(B,X2,Y2,R) move(B,X1,Y1,X2,Y2) :: played(B) tick :: ~played(a) & ~played(b) & ~played(c) tick :: step(M) & succ(M,N) ==> ~step(M) & step(N) tick :: control(white) ==> ~control(white) & control(black) tick :: control(black) ==> ~control(black) & control(white) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% goal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% goal(white,100) :- cell(a,X,8,white) goal(black,100) :- cell(c,X,1,black) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% terminal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% terminal :- cell(a,X,8,white) terminal :- cell(c,X,1,black) terminal :- step(21) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Views %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% whiteknightmove(X1,Y1,X2,Y2) :- skipfile(X1,X2) & nextrank(Y1,Y2) whiteknightmove(X1,Y1,X2,Y2) :- skipfile(X2,X1) & nextrank(Y1,Y2) whiteknightmove(X1,Y1,X2,Y2) :- nextfile(X1,X2) & skiprank(Y1,Y2) whiteknightmove(X1,Y1,X2,Y2) :- nextfile(X2,X1) & skiprank(Y1,Y2) blackknightmove(X1,Y1,X2,Y2) :- skipfile(X1,X2) & nextrank(Y2,Y1) blackknightmove(X1,Y1,X2,Y2) :- skipfile(X2,X1) & nextrank(Y2,Y1) blackknightmove(X1,Y1,X2,Y2) :- nextfile(X1,X2) & skiprank(Y2,Y1) blackknightmove(X1,Y1,X2,Y2) :- nextfile(X2,X1) & skiprank(Y2,Y1) knightmove(X1,Y1,X2,Y2) :- whiteknightmove(X1,Y1,X2,Y2) knightmove(X1,Y1,X2,Y2) :- blackknightmove(X1,Y1,X2,Y2) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Facts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% file(a) file(b) file(c) rank(1) rank(2) rank(3) rank(4) rank(5) rank(6) rank(7) rank(8) nextrank(1,2) nextrank(2,3) nextrank(3,4) nextrank(4,5) nextrank(5,6) nextrank(6,7) nextrank(7,8) nextfile(a,b) nextfile(b,c) skiprank(1,3) skiprank(2,4) skiprank(3,5) skiprank(4,6) skiprank(5,7) skiprank(6,8) skipfile(a,c) 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) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Stylesheet
//------------------------------------------------------------------------------ // parallelknightthrough //------------------------------------------------------------------------------ function renderstate (state) {var step = compfindx('N',seq('step','N'),state,library); var role = compfindx('R',seq('control','R'),state,library); var table = document.createElement('table'); table.setAttribute('border','0'); var row = table.insertRow(0); var cell = row.insertCell(0); cell.setAttribute('align','center'); cell.setAttribute('style','font-size:20px'); cell.innerHTML = 'Step: ' + step; row = table.insertRow(1); var cell = row.insertCell(0); var board = renderboard(state); cell.appendChild(board); row = table.insertRow(2); 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','20'); table.setAttribute('cellpadding','0'); table.setAttribute('border','0'); var row = table.insertRow(0); var cell = row.insertCell(0); cell.appendChild(rendergame('a',state)); cell = row.insertCell(1); cell.appendChild(rendergame('b',state)); cell = row.insertCell(2); cell.appendChild(rendergame('c',state)); return table} function rendergame (game,state) {var table = document.createElement('table'); table.setAttribute('cellspacing','2'); table.setAttribute('bgcolor','#cccccc'); table.setAttribute('border','4'); for (var i=8; i>0; i--) {var row = table.insertRow(8-i); var rank = stringize(i); makecell(row,game,'a',rank,state); makecell(row,game,'b',rank,state); makecell(row,game,'c',rank,state)}; return table} function makecell (row,game,file,rank,state) {var cell = row.insertCell(row.cells.length); cell.setAttribute('width','50'); cell.setAttribute('height','50'); cell.setAttribute('align','center'); cell.setAttribute('valign','center'); var image = getimage(game,file,rank,state); if (image) {var widget = document.createElement('img'); widget.setAttribute('width','40'); widget.setAttribute('height','40'); widget.setAttribute('src',image); cell.appendChild(widget)} else {cell.innerHTML = ' '}; return cell} function getimage (game,file,rank,state) {var image = compfindx('Piece',seq('cell',game,file,rank,'Piece'),state,library); if (image=='white') {return '../library/knightthrough/white.png'}; if (image=='black') {return '../library/knightthrough/black.png'}; return ''} //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Ownership