Gamemaster
General
Game
Playing
simpleswitches
Description
Nine rows of nine lights, all initially off. Clicking a light sets it to on. The game terminates when a "plus" sign is illuminated in the 5 middle switches of the board (i.e. cell(4,5), cell(5,4), cell(5,5), cell,(5,6), and cell(6,5)). The lights at the corners of the "plus" (i.e. cell(4,4), cell(4,6), cell(6,4), , and cell(6,6)) should be off. The status of the other lights does not matter. Has intermediate state values.
Rulesheet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% simpleswitches - same as simplelightboard but with intermediate state values %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% metadata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% role(robot) base(on(M,N)) :- index(M) & index(N) action(set(M,N)) :- index(M) & index(N) index(1) index(2) index(3) index(4) index(5) index(6) index(7) index(8) index(9) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% init(control(robot)) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% legal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% legal(set(4,4)) :- index(4) & index(4) & ~on(4,4) legal(set(4,5)) :- index(4) & index(5) & ~on(4,5) legal(set(4,6)) :- index(4) & index(6) & ~on(4,6) legal(set(5,4)) :- index(5) & index(4) & ~on(5,4) legal(set(5,5)) :- index(5) & index(5) & ~on(5,5) legal(set(5,6)) :- index(5) & index(6) & ~on(5,6) legal(set(6,4)) :- index(6) & index(4) & ~on(6,4) legal(set(6,5)) :- index(6) & index(5) & ~on(6,5) legal(set(6,6)) :- index(6) & index(6) & ~on(6,6) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% operations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set(M,N) :: on(M,N) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% goal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% goal(robot,100) :- ~on(4,4) & ~on(4,6) & ~on(6,4) & ~on(6,6) goal(robot,75) :- on(4,4) & ~on(4,6) & ~on(6,4) & ~on(6,6) goal(robot,75) :- ~on(4,4) & on(4,6) & ~on(6,4) & ~on(6,6) goal(robot,75) :- ~on(4,4) & ~on(4,6) & on(6,4) & ~on(6,6) goal(robot,75) :- ~on(4,4) & ~on(4,6) & ~on(6,4) & on(6,6) goal(robot,50) :- on(4,4) & on(4,6) & ~on(6,4) & ~on(6,6) goal(robot,50) :- on(4,4) & ~on(4,6) & on(6,4) & ~on(6,6) goal(robot,50) :- on(4,4) & ~on(4,6) & ~on(6,4) & on(6,6) goal(robot,50) :- ~on(4,4) & on(4,6) & on(6,4) & ~on(6,6) goal(robot,50) :- ~on(4,4) & on(4,6) & ~on(6,4) & on(6,6) goal(robot,50) :- ~on(4,4) & ~on(4,6) & on(6,4) & on(6,6) goal(robot,25) :- ~on(4,4) & on(4,6) & on(6,4) & on(6,6) goal(robot,25) :- on(4,4) & ~on(4,6) & on(6,4) & on(6,6) goal(robot,25) :- on(4,4) & on(4,6) & ~on(6,4) & on(6,6) goal(robot,25) :- on(4,4) & on(4,6) & on(6,4) & ~on(6,6) goal(robot,0) :- on(4,4) & on(4,6) & on(6,4) & on(6,6) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% terminal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% terminal :- on(4,5) & on(5,4) & on(5,5) & on(5,6) & on(6,5) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Stylesheet
//============================================================================== // simpleswitches //============================================================================== function renderstate (state) {var role = compfindx('R',seq('control','R'),state,library); var table = document.createElement('table'); table.setAttribute('border','0'); var row = table.insertRow(table.rows.length); var cell = row.insertCell(0); var board = renderboard(state); cell.appendChild(board); row = table.insertRow(table.rows.length); 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 table = document.createElement('table'); table.setAttribute('cellspacing','0'); table.setAttribute('bgcolor','#f4f6f8'); table.setAttribute('border','4'); for (var i=0; i<9; i++) {makerow(table,i,state)}; return table} function makerow (table,rownum,state) {var row =table.insertRow(rownum); for (var j=0; j<9; j++) {makecell(row,rownum,j,state)}; return row} function makecell (row,rownum,colnum,state) {var cell = row.insertCell(row.cells.length); cell.setAttribute('width','40'); cell.setAttribute('height','40'); cell.setAttribute('align','center'); cell.setAttribute('valign','center'); if (compfindp(seq('on',(rownum+1).toString(),(colnum+1).toString()),state,seq())) {cell.innerHTML = '
'} else {cell.innerHTML = '
'}; return cell} //============================================================================== //============================================================================== //==============================================================================
Ownership