Gamemaster
General
Game
Playing
rainbow
Description
Rainbow is a graph coloring game. The player is given a planar map and four colors. The goal of the game is to color the regions of the map with colors so that no two adjacent regions have the same color, including regions that meet at a point.
Rulesheet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% /gamemaster/library/rainbow/rulesheet.hrf %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% metadata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% role(robot) base(color(R,C)) :- region(R) & hue(C) base(control(robot)) action(mark(R,C)) :- region(R) & hue(C) region(r1) region(r2) region(r3) region(r4) region(r5) region(r6) hue(red) hue(yellow) hue(green) hue(blue) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% init(control(robot)) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% legal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% legal(mark(R,C)) :- region(R) & hue(C) & ~colored(R) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% operation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% mark(R,C) :: color(R,C) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% goal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% goal(robot,100) :- color(r1,C1) & color(r2,C2) & color(r3,C3) & color(r4,C4) & color(r5,C5) & color(r6,C6) & distinct(C1,C2) & distinct(C1,C3) & distinct(C1,C4) & distinct(C2,C3) & distinct(C2,C4) & distinct(C3,C4) & distinct(C3,C5) & distinct(C3,C6) & distinct(C4,C5) & distinct(C4,C6) & distinct(C5,C6) goal(robot,0) :- ~goal(robot,100) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% terminal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% terminal :- color(r1,C1) & color(r2,C2) & color(r3,C3) & color(r4,C4) & color(r5,C5) & color(r6,C6) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Views %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% colored(R) :- color(R,C) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Stylesheet
//------------------------------------------------------------------------------ // Rainbow //------------------------------------------------------------------------------ function renderstate (state) {var table = document.createElement('table'); table.setAttribute('cellspacing','0'); table.setAttribute('bgcolor','white'); table.setAttribute('border','10'); var row =table.insertRow(0); makecell(row,'r1',state); makecell(row,'r2',state); row =table.insertRow(1); makecell(row,'r3',state); makecell(row,'r4',state); row =table.insertRow(2); makecell(row,'r5',state); makecell(row,'r6',state); return table} function makecell (row,region,state) {var cell = row.insertCell(row.cells.length); cell.setAttribute('width','40'); cell.setAttribute('height','40'); var mark = compfindx('Z',seq('color',region,'Z'),state,seq()); if (mark) {cell.setAttribute('bgcolor',mark)}; cell.innerHTML=' '; return cell} //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Ownership