Gamemaster
General
Game
Playing
capturetheflag
Description
A variant of capture the flag where each player possesses a chess knight. The goal is to pick up the flag and return it to the other edge of your side without getting captured. A player can capture by moving onto the same cell as an opponent while on their defending side, or anywhere if the opponent is carrying the flag.
Rulesheet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% capturetheflag %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% metadata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% role(robot1) role(robot2) role(robot3) role(robot4) base(step(0)) base(step(M)) :- add(1,count,N,M) base(cell(M,N,P)) :- col(M) & row(N) & piece(P) base(cell(M,N,P)) :- col(M) & row(N) & flag(P) base(control(R)) :- role(R) action(move(X1,Y1,X2,Y2)) :- col(X1) & row(Y1) & knightMove(X1,Y1,X2,Y2) action(noop) team(robot1, a) team(robot2, a) team(robot3, b) team(robot4, b) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% init(cell(1,10,knight1)) init(cell(5,10,knight2)) init(cell(1,1,knight3)) init(cell(5,1,knight4)) init(cell(3,10,flag1)) init(cell(3,1,flag4)) init(step(0)) init(control(robot1)) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% legal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% legal(move(X1,Y1,X2,Y2)) :- control(R) & owns(K,R) & cell(X1,Y1,K) & knightMove(X1,Y1,X2,Y2) legal(noop) :- owns(K,R) & cell(X1,Y1,K) & cell(X2,Y2,F) & distinct(X1,X2) & distinct(Y1,Y2) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% operations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move(X1,Y1,X2,Y2) :: owns(K,R) ==> ~cell(X1,Y1,K) & cell(X2,Y2,K) noop :: kerchunk nextmove(cell(X2,Y2,F)) :- flag(F) & owns(F,T) & team(R,T) & does(R,move(X1,Y1,X2,Y2)) & cell(X1,Y1,F) next(cell(X,Y,F)) :- flag(F) & row(Y2) & col(X2) & ~nextmove(cell(X2,Y2,F)) & cell(X,Y,F) next(cell(X2,Y2,P)) :- nextmove(cell(X2,Y2,P)) & ~captured(P) next(cell(X,Y,P)) :- init(cell(X,Y,P)) & captured(P) kerchunk :: step(M) & add(1,count,M,N) ==> ~step(M) & step(N) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% goal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% goal(R,100) :- role(R) & team(R,a) & flagcap(a) & ~flagcap(b) goal(R,0) :- role(R) & team(R,b) & flagcap(a) & ~flagcap(b) goal(R,100) :- role(R) & team(R,b) & flagcap(b) & ~flagcap(a) goal(R,0) :- role(R) & team(R,a) & flagcap(b) & ~flagcap(a) goal(R,75) :- role(R) & flagcap(a) & flagcap(b) goal(R,50) :- role(R) & expired %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% terminal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% terminal :- expired terminal :- flagcap(T) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Views %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% knightMove(X1,Y1,X2,Y2) :- add(1,x,X1,X2) & add(2,y,Y1,Y2) knightMove(X1,Y1,X2,Y2) :- add(1,x,X1,X2) & add(2,y,Y2,Y1) knightMove(X1,Y1,X2,Y2) :- add(1,x,X2,X1) & add(2,y,Y1,Y2) knightMove(X1,Y1,X2,Y2) :- add(1,x,X2,X1) & add(2,y,Y2,Y1) knightMove(X1,Y1,X2,Y2) :- add(2,x,X1,X2) & add(1,y,Y1,Y2) knightMove(X1,Y1,X2,Y2) :- add(2,x,X1,X2) & add(1,y,Y2,Y1) knightMove(X1,Y1,X2,Y2) :- add(2,x,X2,X1) & add(1,y,Y1,Y2) knightMove(X1,Y1,X2,Y2) :- add(2,x,X2,X1) & add(1,y,Y2,Y1) captured(F) :- flag(F) & team(R,T) & ~owns(F,T) & owns(K,R) & nextmove(cell(X,Y,F)) & nextmove(cell(X,Y,K)) captured(K) :- piece(K) & owns(K,R) & team(R,a) & team(R2,b) & owns(K2,R2) & nextmove(cell(X,Y,K)) & nextmove(cell(X,Y,K2)) & left(Y) & flag(F) & owns(F,b) & ~nextmove(cell(X,Y,F)) captured(K) :- piece(K) & owns(K,R) & team(R,b) & team(R2,a) & owns(K2,R2) & nextmove(cell(X,Y,K)) & nextmove(cell(X,Y,K2)) & right(Y) & flag(F) & owns(F,a) & ~nextmove(cell(X,Y,F)) captured(K) :- piece(K) & flag(F) & team(R,T) & owns(F,T) & owns(K,R) & piece(K2) & owns(K2,R2) & ~team(R2,T) & nextmove(cell(X,Y,K)) & nextmove(cell(X,Y,F)) & nextmove(cell(X,Y,K2)) flagcap(a) :- cell(X,10,F) & owns(F,a) flagcap(b) :- cell(X,1,F) & owns(F,b) expired :- step(30) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Facts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% piece(knight1) piece(knight2) piece(knight3) piece(knight4) flag(flag1) %flag(flag2) %flag(flag3) flag(flag4) %flag(flag5) %flag(flag6) owns(knight1, robot1) owns(knight2, robot2) owns(knight3, robot3) owns(knight4, robot4) owns(flag1, b) %owns(flag2, a) %owns(flag3, a) owns(flag4, a) %owns(flag5, b) %owns(flag6, b) add(1,count,0,1) add(1,count,1,2) add(1,count,2,3) add(1,count,3,4) add(1,count,4,5) add(1,count,5,6) add(1,count,6,7) add(1,count,7,8) add(1,count,8,9) add(1,count,9,10) add(1,count,10,11) add(1,count,11,12) add(1,count,12,13) add(1,count,13,14) add(1,count,14,15) add(1,count,15,16) add(1,count,16,17) add(1,count,17,18) add(1,count,18,19) add(1,count,19,20) add(1,count,20,21) add(1,count,21,22) add(1,count,22,23) add(1,count,23,24) add(1,count,24,25) add(1,count,25,26) add(1,count,26,27) add(1,count,27,28) add(1,count,28,29) add(1,count,29,30) add(1,x,1,2) add(1,x,2,3) add(1,x,3,4) add(1,x,4,5) %add(1,x,5,6) %add(1,x,6,7) %add(1,x,7,8) %add(1,x,8,9) add(1,y,1,2) add(1,y,2,3) add(1,y,3,4) add(1,y,4,5) add(1,y,5,6) add(1,y,6,7) add(1,y,7,8) add(1,y,8,9) add(1,y,9,10) %add(1,y,10,11) %add(1,y,11,12) %add(1,y,12,13) %add(1,y,13,14) %add(1,y,14,15) %add(1,y,15,16) %add(1,y,16,17) %add(1,y,17,18) add(2,x,1,3) add(2,x,2,4) add(2,x,3,5) %add(2,x,4,6) %add(2,x,5,7) %add(2,x,6,8) %add(2,x,7,9) add(2,y,1,3) add(2,y,2,4) add(2,y,3,5) add(2,y,4,6) add(2,y,5,7) add(2,y,6,8) add(2,y,7,9) add(2,y,8,10) %add(2,y,9,11) %add(2,y,10,12) %add(2,y,11,13) %add(2,y,12,14) %add(2,y,13,15) %add(2,y,14,16) %add(2,y,15,17) %add(2,y,16,18) left(1) left(2) left(3) left(4) left(5) right(6) right(7) right(8) right(9) right(10) row(1) row(2) row(3) row(4) row(5) row(6) row(7) row(8) row(9) row(10) %row(11) %row(12) %row(13) %row(14) %row(15) %row(16) %row(17) %row(18) col(1) col(2) col(3) col(4) col(5) %col(6) %col(7) %col(8) %col(9) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Stylesheet
//------------------------------------------------------------------------------ // knights tour duo //------------------------------------------------------------------------------ function renderstate (state) {var table = document.createElement('table'); table.setAttribute('cellspacing','0'); //table.setAttribute('bgcolor','white'); table.setAttribute('border','10'); for (var i=0; i<5; 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'); rownum_str = (rownum+1).toString(); colnum_str = (colnum+1).toString(); var mark = compfinds('Z',seq('cell',rownum_str,colnum_str,'Z'),state,seq()); if (colnum < 5) {cell.setAttribute('bgcolor','#BBDDFF');} else {cell.setAttribute('bgcolor','#FFDDBB');} if (mark.includes('flag1')) {cell.setAttribute('bgcolor','#FF0000');}; if (mark.includes('flag4')){cell.setAttribute('bgcolor','#0000FF');}; if (mark.includes('knight1')) {cell.innerHTML = '
'}; if (mark.includes('knight2')) {cell.innerHTML = '
'}; if (mark.includes('knight3')) {cell.innerHTML = '
'}; if (mark.includes('knight4')) {cell.innerHTML = '
'}; if (mark==false) {cell.innerHTML = ' '}; return cell} //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Ownership