Gamemaster
General
Game
Playing
soldiers
Description
Three soldiers (s1, hs, s3) want to cross a river. Two boys (b1 and b2) have a boat on the same side of the river. However, the boat can carry only the two boys or one solder at a time. To win the game, a player must find a schedule of crossings that gets all three soldiers across the river and leave the boat with the two boys on the original bank by step 12.
Rulesheet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% soldiers %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% metadata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% role(robot) base(location(X,left)) :- individual(X) base(location(X,right)) :- individual(X) base(boat(left)) base(boat(right)) base(current(M)) :- step(N) base(control(robot)) action(left(X)) :- individual(X) action(right(X)) :- individual(X) action(left(X,Y)) :- boy(X) & boy(Y) action(right(X,Y)) :- boy(X) & boy(Y) individual(X) :- soldier(X) individual(X) :- boy(X) soldier(s1) soldier(s2) soldier(s3) boy(b1) boy(b2) step(1) step(2) step(3) step(4) step(5) step(6) step(7) step(8) step(9) step(10) step(11) step(12) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% init(location(s1,left)) init(location(s2,left)) init(location(s3,left)) init(location(b1,left)) init(location(b2,left)) init(boat(left)) init(current(1)) init(control(robot)) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% legal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% legal(left(X)) :- boat(right) & location(X,right) legal(right(X)) :- boat(left) & location(X,left) legal(left(b1,b2)) :- boat(right) & location(b1,right) & location(b2,right) legal(right(b1,b2)) :- boat(left) & location(b1,left) & location(b2,left) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% operations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% left(X) :: ~boat(right) & ~location(X,right) & boat(left) & location(X,left) & kerchunk right(X) :: ~boat(left) & ~location(X,left) & boat(right) & location(X,right) & kerchunk left(X,Y) :: ~boat(right) & ~location(X,right) & ~location(Y,right) & boat(left) & location(X,left) & location(Y,left) & kerchunk right(X,Y) :: ~boat(left) & ~location(X,left) & ~location(Y,left) & boat(right) & location(X,right) & location(Y,right) & kerchunk kerchunk :: current(M) & succ(M,N) ==> ~current(M) & current(N) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% goal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% goal(robot,100) :- location(s1,right) & location(s2,right) & location(s3,right) & location(b1,left) & location(b2,left) & boat(left) goal(robot,0) :- location(s1,left) goal(robot,0) :- location(s2,left) goal(robot,0) :- location(s3,left) goal(robot,0) :- location(b1,right) goal(robot,0) :- location(b2,right) goal(robot,0) :- boat(right) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% terminal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% terminal :- location(s1,right) & location(s2,right) & location(s3,right) & location(b1,left) & location(b2,left) & boat(left) terminal :- current(13) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Views %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Facts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 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) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Stylesheet
//------------------------------------------------------------------------------ // Soldiers //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // stylesheet //------------------------------------------------------------------------------ function renderstate (state) {var step = compfindx('N',seq('current','N'),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); return table} function renderboard (state) {var table = document.createElement('table'); table.setAttribute('cellspacing','0'); table.setAttribute('border','1'); var row =table.insertRow(0); var cell = row.insertCell(0); cell.setAttribute('width',50); cell.setAttribute('align','center'); cell.appendChild(makebank('left',state)); var cell = row.insertCell(1); cell.setAttribute('width',100); cell.setAttribute('bgcolor',"#eeeeee"); var cell = row.insertCell(2); cell.setAttribute('width',50); cell.setAttribute('align','center'); cell.appendChild(makebank('right',state)); return table} function makebank (side,state) {var table = document.createElement('table'); var row =table.insertRow(0); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('location','s1',side),state,[])) {cell.innerHTML = 's1'} else {cell.innerHTML = ' '}; var row =table.insertRow(1); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('location','s2',side),state,[])) {cell.innerHTML = 's2'} else {cell.innerHTML = ' '}; var row =table.insertRow(2); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('location','s3',side),state,[])) {cell.innerHTML = 's3'} else {cell.innerHTML = ' '}; var row =table.insertRow(3); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('boat',side),state,[])) {cell.innerHTML = 'boat'} else {cell.innerHTML = ' '}; var row =table.insertRow(4); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('location','b1',side),state,[])) {cell.innerHTML = 'b1'} else {cell.innerHTML = ' '}; var row =table.insertRow(5); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('location','b2',side),state,[])) {cell.innerHTML = 'b2'} else {cell.innerHTML = ' '}; var row =table.insertRow(6); var cell = row.insertCell(0); cell.setAttribute('align','center'); cell.innerHTML = ' '; return table} //============================================================================== //============================================================================== //==============================================================================
Ownership