Gamemaster
General
Game
Playing
knightthroughsmall
Description
Knightthrough is a game played on an 6x6 rectangular board. White pieces on the bottom two rows of the board and and black pieces on the top two rows of the board. Pieces move like chess knights, except that can only move forward. The winner is the first player to advance one of its pieces to the opposite side of the board.
Rulesheet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% knightthroughsmall %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% metadata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% role(white) role(black) base(cell(X,Y,R)) :- file(X) & rank(Y) & role(R) base(control(R)) :- role(R) action(move(X1,Y1,X2,Y2)) :- file(X1) & rank(Y1) & whitemove(X1,Y1,X2,Y2) action(move(X1,Y1,X2,Y2)) :- file(X1) & rank(Y1) & blackmove(X1,Y1,X2,Y2) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% init(cell(a,1,white)) init(cell(b,1,white)) init(cell(c,1,white)) init(cell(d,1,white)) init(cell(e,1,white)) init(cell(f,1,white)) init(cell(a,2,white)) init(cell(b,2,white)) init(cell(c,2,white)) init(cell(d,2,white)) init(cell(e,2,white)) init(cell(f,2,white)) init(cell(a,5,black)) init(cell(b,5,black)) init(cell(c,5,black)) init(cell(d,5,black)) init(cell(e,5,black)) init(cell(f,5,black)) init(cell(a,6,black)) init(cell(b,6,black)) init(cell(c,6,black)) init(cell(d,6,black)) init(cell(e,6,black)) init(cell(f,6,black)) init(control(white)) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% legal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% legal(move(X1,Y1,X2,Y2)) :- control(white) & cell(X1,Y1,white) & whitemove(X1,Y1,X2,Y2) & ~cell(X2,Y2,white) legal(move(X1,Y1,X2,Y2)) :- control(black) & cell(X1,Y1,black) & blackmove(X1,Y1,X2,Y2) & ~cell(X2,Y2,black) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% operations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move(X1,Y1,X2,Y2) :: control(R) ==> ~cell(X1,Y1,R) & cell(X2,Y2,R) move(X1,Y1,X2,Y2) :: cell(X2,Y2,R) ==> ~cell(X2,Y2,R) move(X1,Y1,X2,Y2) :: control(white) ==> ~control(white) & control(black) move(X1,Y1,X2,Y2) :: control(black) ==> ~control(black) & control(white) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% goal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% goal(white,100) :- whitewin goal(white,0) :- blackwin goal(black,100) :- blackwin goal(black,0) :- whitewin %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% terminal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% terminal :- whitewin terminal :- blackwin %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Views %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% whitemove(X1,Y1,X2,Y2) :- skipfile(X1,X2) & nextrank(Y1,Y2) whitemove(X1,Y1,X2,Y2) :- skipfile(X2,X1) & nextrank(Y1,Y2) whitemove(X1,Y1,X2,Y2) :- skiprank(Y1,Y2) & nextfile(X1,X2) whitemove(X1,Y1,X2,Y2) :- skiprank(Y1,Y2) & nextfile(X2,X1) blackmove(X1,Y1,X2,Y2) :- skipfile(X1,X2) & nextrank(Y2,Y1) blackmove(X1,Y1,X2,Y2) :- skipfile(X2,X1) & nextrank(Y2,Y1) blackmove(X1,Y1,X2,Y2) :- skiprank(Y2,Y1) & nextfile(X1,X2) blackmove(X1,Y1,X2,Y2) :- skiprank(Y2,Y1) & nextfile(X2,X1) whitewin :- cell(X,6,white) whitewin :- ~hasanypiece(black) blackwin :- cell(X,1,black) blackwin :- ~hasanypiece(white) hasanypiece(Role) :- cell(X,Y,Role) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Facts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% file(a) file(b) file(c) file(d) file(e) file(f) rank(1) rank(2) rank(3) rank(4) rank(5) rank(6) nextrank(1,2) nextrank(2,3) nextrank(3,4) nextrank(4,5) nextrank(5,6) nextfile(a,b) nextfile(b,c) nextfile(c,d) nextfile(d,e) nextfile(e,f) skiprank(1,3) skiprank(2,4) skiprank(3,5) skiprank(4,6) skipfile(a,c) skipfile(b,d) skipfile(c,e) skipfile(d,f) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Stylesheet
//------------------------------------------------------------------------------ // Knightthroughsmall //------------------------------------------------------------------------------ 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(0); var cell = row.insertCell(0); var board = renderboard(state); cell.appendChild(board); row = table.insertRow(1); 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','2'); table.setAttribute('bgcolor','#cccccc'); table.setAttribute('border','4'); for (var i=6; i>0; i--) {var row = table.insertRow(6-i); var rank = stringize(i); makecell(row,'a',rank,state); makecell(row,'b',rank,state); makecell(row,'c',rank,state); makecell(row,'d',rank,state); makecell(row,'e',rank,state); makecell(row,'f',rank,state)}; return table} function makecell (row,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(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 (file,rank,state) {var image = compfindx('Piece',seq('cell',file,rank,'Piece'),state,library); if (image=='white') {return '../library/knightthrough/white.png'}; if (image=='black') {return '../library/knightthrough/black.png'}; return ''} //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Ownership