Gamemaster
General
Game
Playing
kono
Description
Kono is a game played on a 4x4 grid. Red pieces on the bottom two rows of the board and black pieces on the top two rows of the board. Pieces can move forward one step along lines connecting vertices or can jump over a piece of their own color to capture an opponent's piece on the opposite side. Each player gets points for each piece captured. The game terminates on move 30 or when one of the players has no more pieces to move.
Rulesheet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% kono %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% metadata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% role(red) role(black) base(cell(M,N,Mark)) :- index(M) & index(N) & mark(Mark) base(score(Role,0)) :- role(Role) base(score(Role,N)) :- role(Role) & incr(M,N) base(step(1)) base(step(N)) :- succ(M,N) base(control(Role)) :- role(Role) action(move(U,V,X,Y)) :- doublet(U,V,X,Y) action(jump(U,V,W,X,Y,Z)) :- triplet(U,V,W,X,Y,Z) action(kerchunk) mark(black) mark(red) mark(blank) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% init(cell(1,1,black)) init(cell(1,2,black)) init(cell(1,3,black)) init(cell(1,4,black)) init(cell(2,1,black)) init(cell(2,2,black)) init(cell(2,3,black)) init(cell(2,4,black)) init(cell(3,1,red)) init(cell(3,2,red)) init(cell(3,3,red)) init(cell(3,4,red)) init(cell(4,1,red)) init(cell(4,2,red)) init(cell(4,3,red)) init(cell(4,4,red)) init(score(red,0)) init(score(black,0)) init(step(1)) init(control(red)) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% legal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% legal(move(U,V,X,Y)) :- control(R) & cell(U,V,R) & doublet(U,V,X,Y) & cell(X,Y,blank) legal(jump(U,V,W,X,Y,Z)) :- control(red) & cell(U,V,red) & triplet(U,V,W,X,Y,Z) & cell(W,X,red) & cell(Y,Z,black) legal(jump(U,V,W,X,Y,Z)) :- control(black) & cell(U,V,black) & triplet(U,V,W,X,Y,Z) & cell(W,X,black) & cell(Y,Z,red) legal(kerchunk) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% operations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% move(U,V,X,Y) :: cell(U,V,R) ==> ~cell(U,V,R) & cell(U,V,blank) move(U,V,X,Y) :: cell(U,V,R) ==> ~cell(X,Y,blank) & cell(X,Y,R) move(U,V,X,Y) :: kerchunk jump(U,V,W,X,Y,Z) :: cell(U,V,R) ==> ~cell(U,V,R) & cell(U,V,blank) jump(U,V,W,X,Y,Z) :: cell(U,V,R) & cell(Y,Z,S) ==> ~cell(Y,Z,S) & cell(Y,Z,R) jump(U,V,W,X,Y,Z) :: cell(U,V,R) & score(R,M) & incr(M,N) ==> ~score(R,M) & score(R,N) jump(U,V,W,X,Y,Z) :: kerchunk kerchunk :: control(black) ==> ~control(black) & control(red) kerchunk :: control(red) ==> ~control(red) & control(black) kerchunk :: step(M) & succ(M,N) ==> ~step(M) & step(N) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% goal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% goal(R,N) :- score(R,N) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% terminal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% terminal :- score(R,100) terminal :- step(30) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Views %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% doublet(U,V,X,Y) :- horizontal(U,V,X,Y) doublet(U,V,X,Y) :- horizontal(X,Y,U,V) doublet(U,V,X,Y) :- vertical(U,V,X,Y) doublet(U,V,X,Y) :- vertical(X,Y,U,V) doublet(U,V,X,Y) :- slash(U,V,X,Y) doublet(U,V,X,Y) :- slash(X,Y,U,V) doublet(U,V,X,Y) :- backslash(U,V,X,Y) doublet(U,V,X,Y) :- backslash(X,Y,U,V) triplet(U,V,W,X,Y,Z) :- horizontal(U,V,W,X) & horizontal(W,X,Y,Z) triplet(U,V,W,X,Y,Z) :- horizontal(Y,Z,W,X) & horizontal(W,X,U,V) triplet(U,V,W,X,Y,Z) :- vertical(U,V,W,X) & vertical(W,X,Y,Z) triplet(U,V,W,X,Y,Z) :- vertical(Y,Z,W,X) & vertical(W,X,U,V) triplet(U,V,W,X,Y,Z) :- slash(U,V,W,X) & slash(W,X,Y,Z) triplet(U,V,W,X,Y,Z) :- slash(Y,Z,W,X) & slash(W,X,U,V) triplet(U,V,W,X,Y,Z) :- backslash(U,V,W,X) & backslash(W,X,Y,Z) triplet(U,V,W,X,Y,Z) :- backslash(Y,Z,W,X) & backslash(W,X,U,V) horizontal(U,V,X,V) :- nextspot(U,X) & index(V) vertical(U,V,U,Y) :- nextspot(V,Y) & index(U) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Facts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% index(1) index(2) index(3) index(4) nextspot(1,2) nextspot(2,3) nextspot(3,4) incr(0,12) incr(12,25) incr(25,37) incr(37,50) incr(50,62) incr(62,75) incr(75,87) incr(87,100) 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) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Stylesheet
//------------------------------------------------------------------------------ // Kono //------------------------------------------------------------------------------ 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 canvas = document.createElement('canvas'); canvas.setAttribute('width','210px'); canvas.setAttribute('height','210px'); drawline( 15, 15,195, 15,canvas); drawline( 15, 75,195, 75,canvas); drawline( 15,135,195,135,canvas); drawline( 15,195,195,195,canvas); drawline( 15, 15, 15,195,canvas); drawline( 75, 15, 75,195,canvas); drawline(135, 15,135,195,canvas); drawline(195, 15,195,195,canvas); drawnode('1','1', 0, 0,state,canvas); drawnode('1','2', 60, 0,state,canvas); drawnode('1','3',120, 0,state,canvas); drawnode('1','4',180, 0,state,canvas); drawnode('2','1', 0, 60,state,canvas); drawnode('2','2', 60, 60,state,canvas); drawnode('2','3',120, 60,state,canvas); drawnode('2','4',180, 60,state,canvas); drawnode('3','1', 0,120,state,canvas); drawnode('3','2', 60,120,state,canvas); drawnode('3','3',120,120,state,canvas); drawnode('3','4',180,120,state,canvas); drawnode('4','1', 0,180,state,canvas); drawnode('4','2', 60,180,state,canvas); drawnode('4','3',120,180,state,canvas); drawnode('4','4',180,180,state,canvas); return canvas} //------------------------------------------------------------------------------ // Drawing subroutines //------------------------------------------------------------------------------ function drawred (x,y,w) {var ctx = w.getContext('2d'); ctx.beginPath(); ctx.lineWidth=2; ctx.arc(x+15,y+15,12,0,2*Math.PI,false); ctx.stroke(); ctx.fillStyle = "#ff8888"; ctx.fill();} function drawblack (x,y,w) {var ctx = w.getContext('2d'); ctx.beginPath(); ctx.lineWidth=2; ctx.arc(x+15,y+15,12,0,2*Math.PI,false); ctx.stroke(); ctx.fillStyle = "#888888"; ctx.fill();} function drawblank (x,y,w) {var ctx = w.getContext('2d'); ctx.beginPath(); ctx.lineWidth=2; ctx.arc(x+15,y+15,12,0,2*Math.PI,false); ctx.stroke(); ctx.fillStyle = "#ffffff"; ctx.fill();} function drawline(u,v,x,y,w) {var ctx = w.getContext('2d'); ctx.beginPath(); ctx.lineWidth=2; ctx.moveTo(u,v); ctx.lineTo(x,y); ctx.stroke()} function drawnode (m,n,x,y,state,canvas) {var mark = compfindx('X',seq('cell',m,n,'X'),state,library); if (mark=='red') {drawred(x,y,canvas); return true}; if (mark=='black') {drawblack(x,y,canvas); return true}; drawblank(x,y,canvas); return true} function drawscore (text,x,y,w) {var ctx = w.getContext('2d'); ctx.fillStyle = "#000000"; ctx.font="28px Times" ctx.fillText(text,x+12,y+18); return true} //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Ownership