Gamemaster
General
Game
Playing
missionaries
Description
Three missionaries (m1, m2, m3) and three cannibals (c1, c2, c3) want to cross a river. There is a boat that can hold only two people at a time, and any combination of missionaries and cannibals can row the boat. However, there is a catch. If the cannibals on either side of the river outnumber the missionaries, the cannibals will eat the missionaries, and the game will end. To win the game, a player must find a schedule of crossings that gets all missionaries and cannibals across the river by step 12.
Rulesheet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% missionaries %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% 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)) :- individual(X) & individual(Y) & symless(X,Y) action(right(X,Y)) :- individual(X) & individual(Y) & symless(X,Y) individual(X) :- missionary(X) individual(X) :- cannibal(X) missionary(m1) missionary(m2) missionary(m3) cannibal(c1) cannibal(c2) cannibal(c3) 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(m1,left)) init(location(m2,left)) init(location(m3,left)) init(location(c1,left)) init(location(c2,left)) init(location(c3,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(X,Y)) :- boat(right) & location(X,right) & location(Y,right) & symleq(X,Y) & distinct(X,Y) legal(right(X,Y)) :- boat(left) & location(X,left) & location(Y,left) & symleq(X,Y) & distinct(X,Y) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% 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,Goal) :- countofall(X,location(X,right),N) & scoremap(N,Goal) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% terminal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% terminal :- countofall(X,location(X,right),6) terminal :- countofall(X,missionary(X) & location(X,left),M) & countofall(X,cannibal(X) & location(X,left),N) & less(0,M) & less(M,N) terminal :- countofall(X,missionary(X) & location(X,right),M) & countofall(X,cannibal(X) & location(X,right),N) & less(0,M) & less(M,N) terminal :- current(12) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% 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) scoremap(0,0) scoremap(1,10) scoremap(2,20) scoremap(3,30) scoremap(4,40) scoremap(5,50) scoremap(6,100) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Stylesheet
//------------------------------------------------------------------------------ // Missionaries //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // 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','m1',side),state,[])) {cell.innerHTML = 'm1'} else {cell.innerHTML = ' '}; var row =table.insertRow(1); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('location','m2',side),state,[])) {cell.innerHTML = 'm2'} else {cell.innerHTML = ' '}; var row =table.insertRow(2); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('location','m3',side),state,[])) {cell.innerHTML = 'm3'} 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','c1',side),state,[])) {cell.innerHTML = 'c1'} else {cell.innerHTML = ' '}; var row =table.insertRow(5); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('location','c2',side),state,[])) {cell.innerHTML = 'c2'} else {cell.innerHTML = ' '}; var row =table.insertRow(6); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('location','c3',side),state,[])) {cell.innerHTML = 'c3'} else {cell.innerHTML = ' '}; return table} //============================================================================== //============================================================================== //==============================================================================
Ownership