Gamemaster
General
Game
Playing
bridgecrossing
Description
Four people (a, b, c, d) want to cross a bridge at night. Person a takes 1 minute; peron b takes 2 minutes; person c takes 5 minutes, and person d takes 10 minutes. They have only one torch and the bridge cannot be crossed without the torch. There cannot be more than two people on the bridge at the same time; and, when two people cross the bridge together they move at the slower person's pace. To win the game, a player must find a series of 5 crossings that gets all four people across the bridge in no more than 17 minutes.
Rulesheet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% bridgecrossing %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% metadata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% role(robot) base(location(X,left)) :- individual(X) base(location(X,right)) :- individual(X) base(torch(left)) base(torch(right)) base(current(M)) :- step(N) base(control(robot)) action(left(X)) :- person(X) action(right(X)) :- person(X) action(left(X,Y)) :- person(X) & person(Y) & symless(X,Y) action(right(X,Y)) :- person(X) & person(Y) & symless(X,Y) person(a) person(b) person(c) person(d) pace(a,1) pace(b,2) pace(c,5) pace(d,10) step(1) step(2) step(3) step(4) step(5) step(6) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% init(location(a,left)) init(location(b,left)) init(location(c,left)) init(location(d,left)) init(torch(left)) init(clock(0)) init(current(1)) init(control(robot)) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% legal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% legal(left(X)) :- torch(right) & location(X,right) legal(right(X)) :- torch(left) & location(X,left) legal(left(X,Y)) :- torch(right) & location(X,right) & location(Y,right) & symless(X,Y) legal(right(X,Y)) :- torch(left) & location(X,left) & location(Y,left) & symless(X,Y) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% operations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% left(X) :: ~torch(right) & ~location(X,right) & torch(left) & location(X,left) & kerchunk & tick(X) right(X) :: ~torch(left) & ~location(X,left) & torch(right) & location(X,right) & kerchunk & tick(X) left(X,Y) :: ~torch(right) & ~location(X,right) & ~location(Y,right) & torch(left) & location(X,left) & location(Y,left) & kerchunk & ticket(X,Y) right(X,Y) :: ~torch(left) & ~location(X,left) & ~location(Y,left) & torch(right) & location(X,right) & location(Y,right) & kerchunk & ticket(X,Y) kerchunk :: current(M) & succ(M,N) ==> ~current(M) & current(N) tick(X) :: clock(O) & pace(X,D) & evaluate(plus(O,D),N) ==> ~clock(O) & clock(N) ticket(X,Y) :: clock(O) & pace(X,C) & pace(Y,D) & evaluate(plus(O,max(C,D)),N) ==> ~clock(O) & clock(N) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% goal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% goal(robot,100) :- countofall(X,location(X,right),4) & clock(C) & leq(C,17) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% terminal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% terminal :- current(6) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Views %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Facts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% succ(1,2) succ(2,3) succ(3,4) succ(4,5) succ(5,6) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Stylesheet
//------------------------------------------------------------------------------ // bridgecrossing //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // stylesheet //------------------------------------------------------------------------------ function renderstate (state) {var step = compfindx('N',seq('current','N'),state,library); var clock = compfindx('N',seq('clock','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 + ' ' + 'Clock: ' + clock; 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'); table.setAttribute('width','50'); table.setAttribute('cellspacing','0'); var row =table.insertRow(0); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('location','a',side),state,[])) {cell.innerHTML = 'a'} else {cell.innerHTML = ' '}; var row =table.insertRow(1); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('location','b',side),state,[])) {cell.innerHTML = 'b'} else {cell.innerHTML = ' '}; var row =table.insertRow(2); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('location','c',side),state,[])) {cell.innerHTML = 'c'} else {cell.innerHTML = ' '}; var row =table.insertRow(3); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('location','d',side),state,[])) {cell.innerHTML = 'd'} else {cell.innerHTML = ' '}; var row =table.insertRow(4); var cell = row.insertCell(0); cell.setAttribute('align','center'); if (compfindp(seq('torch',side),state,[])) {cell.innerHTML = 'torch'} else {cell.innerHTML = ' '}; return table} //============================================================================== //============================================================================== //==============================================================================
Ownership