KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /domains/gohover/cell/paprica/uploadtestfolder/ios-test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /domains/gohover/cell/paprica/uploadtestfolder/ios-test/iosTest-multi-rule-89.5-extraicons.html
<html>
 <body id="MainBody" onkeydown = "getArrows(event)" ; style="background-color:#b0c4de"  >
<!-- this can be inserted into the <body  [...]>  onkeyup = "resetArrows(event)  -->


<!-- style="border: 1px solid #c3c3c3 -->




<div style="border: 1px solid #c3c3c3; width: 960px; background-color:#b0c4de;  -webkit-user-select: none;  font-size: 85%">
   <!-- Regarding the reference to -webkit-user-select see http://stackoverflow.com/questions/2659999/html5-canvas-hand-cursor-problems -->



<form name= "controlform" >

<div id="Range2_weights_div" >
<table  border="0" cellspacing="0" >

<tr align = "right" rowspan="2" >

<th align = "right" style="font-weight: normal;font-size: 85%"> Red:</th>
<td  align = "right">
<select id="redweight1" onchange="change_weight(red, this.value)">
         </select><br>
<select id="r2_redrule1" onchange="r2_change_rule(red, this.value)">
         </select>
</td>


<th align = " right" style="font-weight: normal;font-size: 85%"> Yellow:</th>

<td align = "right">
<select id="yellowweight1" onchange="change_weight(yellow, this.value)">
   </select> 
<select id="r2_yellowrule1" onchange="r2_change_rule(yellow, this.value)">
   </select>
</td>


<th align = "right" style="font-weight: normal;font-size: 85%"> Green:</th>
<td align = "right">
<select id="greenweight1" onchange="change_weight(green, this.value)">
   </select>
<select id="r2_greenrule1" onchange="r2_change_rule(green, this.value)">
   </select>
</td>


<th  align = "right" style="font-weight: normal;font-size: 85%"> Blue:</th>
<td align = "right" >
<select id="blueweight1" onchange="change_weight(blue, this.value)">
      </select>
<select id="r2_bluerule1" onchange="r2_change_rule(blue, this.value)">
      </select>
</td>
</tr>
</table>

<hr>



</div>


<div id="original_rules_div" >
Red:
<select id="redrule1" onchange="change_rule(red, this.value)">
         </select>
Yellow:
<select id="yellowrule1" onchange="change_rule(yellow, this.value)">
   </select>

Green:
<select id="greenrule1" onchange="change_rule(green, this.value)">
   </select>

Blue:
<select id="bluerule1" onchange="change_rule(blue, this.value)">
      </select>
<br><hr>

</div>


<!--Use mouse to--> 
<select id="insertmode" onchange="change_insertmode(this.value)">
   <option value="insert" selected="selected">Insert</option>
   <option value="select">Select</option>
   <option value="select_all">Select All</option>
   <option value="save">Get RLE</option>
   <option value="save">Get Multirule RLE</option>

   <option value="insert">==========</option>
   <option value="cut">Cut</option>
   <option value="copy">Copy</option>
   <option value="paste">Paste</option>
   <option value="insert">==========</option>
   <option value="clear">Clear Selection</option>
   <option value="clear_outside">Clear Outside</option>
   <option value="clear_all">Clear All</option>
   <option value="insert">==========</option>

   <option value="fill">Fill</option>
   <option value="random_fill">Random Fill</option>
   <option value="insert">==========</option>
   <option value="rotate_cw">Rotate CW</option>
   <option value="rotate_ccw">Rotate CCW</option>
   <option value="flip_N-S">Flip N-S</option>
   <option value="flip_E-W">Flip E-W</option>
   <option value="insert">==========</option>
   <option value="drive">Insert drivable</option>
   <option value="orthobullet">Set ortho bullet</option>
   <option value="diagbullet">Set diag bullet</option>
</select>
<select id="colorchoice" onchange="change_color_pencil(this.value)">
   <option value =  "0x1000" >red</option>
   <option value =  "0x0100" selected ="selected">yellow </option>
   <option value =  "0x0010">green</option>
   <option value =  "0x0001">blue</option>
   <option value =  "0">Erase</option>
</select>

<select id="drawmode" onchange="change_draw_choice(this.value)">
  
   <option value = "freehand" selected ="selected">freehand drawing</option>
   <option value = "user pattern" >pattern from the clipboard</option>

</select>
 pointed
<select id="orientmode" onchange="change_orient_pencil(this.value)">
      <option value = "North right"  >North or NE</option>
      <option value = "East up"  selected="selected"  >East or NE</option>
      <option value = "East down"      >East or SE</option>
      <option value = "South right"  >South or SE </option>
      <option value = "South left" >South or SW</option>
      <option value = "West down"     >West or SW</option>
      <option value = "West up"   >West or NW</option>
      <option value = "North left" >North or NW</option>
</select>
 with 
<select id="x-vel-choice" onchange="change_x_vel_pencil(this.value)">
    <option value = 16 >16  Eastward</option>

  <option value = 8 >8.0  Eastward</option>
  <option value = 5 >5.0  Eastward</option>
  <option value = 4 >4.0  Eastward</option>
  <option value = 3 >3.0  Eastward</option>
  <option value = 2 >2.0  Eastward</option>

  <option value = 1 >1.0  Eastward</option>
   <option value = 0.5>0.5 Eastward</option>
   <option value = 0.4>0.4 Eastward</option>
   <option value = 0.3>0.3 Eastward </option>
    <option value = 0.25>.25 Eastward</option>
   <option value = "0.2">0.2 Eastward</option>
   <option value = 0.1>0.1 Eastward</option>

   <option value = 0 selected ="selected">no East or West</option>
      <option value = -0.1>0.1 Westward</option>
      <option value = -0.2>0.2 Westward </option>
      <option value = -0.25>0.25 Westward </option>
      <option value = -0.3>0.3 Westward </option>
      <option value = -0.4>0.4 Westward </option>
      <option value = -0.5>0.5 Westward </option>
      <option value = -1>1.0 Westward </option>
      <option value = -2>2.0 Westward </option>
      <option value = -3>3.0 Westward </option>
      <option value = -4>4.0 Westward </option>
      <option value = -5>5.0 Westward </option>
      <option value = -8>8.0 Westward </option>
      <option value = -16>16 Westward </option>

   </select>
velocity and
<select id="y-vel-choice" onchange="change_y_vel_pencil(this.value)">
     <option value = -16 >16 Northward </option>

   <option value = -8 >8.0 Northward </option>
   <option value = -5 >5.0 Northward </option>
   <option value = -4 >4.0 Northward </option>

   <option value = -3 >3.0 Northward </option>
   <option value = -2 >2.0 Northward </option>
   <option value = -1 >1.0 Northward </option>
   <option value = -0.5>0.5 Northward </option>
   <option value = -0.4>0.4 Northward </option>
   <option value = -0.3>0.3 Northward </option>
      <option value = -0.25 >.25 Northward </option>
   <option value = -0.2 >0.2 Northward </option>
   <option value = -0.1 >0.1 Northward </option>
   <option value = 0 selected ="selected">no North or South</option>
      <option value = 0.1>0.1 Southward</option>
      <option value = 0.2>0.2 Southward </option>
      <option value = 0.25>.25 Southward </option>
      <option value = 0.3>0.3 Southward </option>
      <option value = 0.4>0.4 Southward </option>
      <option value = 0.5>0.5 Southward </option>
      <option value = 1>1.0 Southward </option>
      <option value = 2>2.0 Southward </option>
      <option value = 3>3.0 Southward </option>
      <option value = 4>4.0 Southward </option>
      <option value = 5>5.0 Southward </option>
      <option value = 8>8.0 Southward </option>
      <option value = 16>16 Southward </option>

   </select>
velocity.
<br><hr>


<input type="button" id="gobutton" style="width: 40px" value=" Go " onclick=doTimer()>
<input type="button" value="Step" onclick="stepCount()">


<select id="mag" onchange="change_settings_menu(this.value)">
   <option selected ="selected"value = "title">Settings</option>
       <option value = "title">---Zoom---</option>
<!--
   <option value = "0.5">Cell size 0.5</option>
-->
   <option value = "1">Cell size 1</option>
   <option value = "2" >Cell size 2</option>
   <option value = "3" >Cell size 3</option>
   <option value = "4" >Cell size 4</option>
   <option value = "8" >Cell size 8</option>

   <option value = "16">Cell size 16</option>

<!--
      <option value = "10">Cell size 10</option>
      <option value = "15">Cell size 15</option>
      <option value = "30">Cell size 30</option>
-->
      <option value = "title">--- Resize & Clear Board ---</option>
       <option value="fill window">Fill window at current cell size</option>
       <option value="960x640">Total cells: 960x640, cell size: 1</option>
       <option value="480x320">Total cells: 480x320, cell size: 2</option>  
       <option value="320x213">Total cells: 320x213, cell size: 3</option>    
       <option value="240x160">Total cells: 240x160, cell size: 4</option> 
      <option value = "title">---Misc Settings---</option>
   <option value = "not rule specific">Offer all patterns in memory</option>
      <option value = "rule specific">Offer only rule-specific patterns</option>

<!--

      <option value = "toggleX">Disable X wraparound</option>
      <option value = "toggleY">Disable Y wraparound</option>
      <option value = ".1 effect">Enable weird history effect</option>

      <option value = "twoNeigh">Disable 2 neighbors convert</option>
      <option value = "togglePhysics">Disable physics</option>
      <option value = "toggleDriving">Disable driving</option>
-->
      <option value = "no background">Remove background picture</option>
       
      <option value = "toggleRange">Switch to Range 2</option>

   </select>

Steps:
<select id="speed_step_menu" onchange="change_speed_step(this.value)">
  
   <option value = 1> 1</option>
   <option value = 2 > 2</option>
   <option selected ="selected"value = 3>3</option>  
   <option value = 4 > 4</option>

   <option value = 5 > 5</option>
   <option value = 6> 6</option>
   <option value = 7 > 7</option>
   <option value = 8 > 8</option>
   <option value = 9 > 9</option>
   <option value = 10> 10</option>
   <option value = 11 > 11</option>
   <option value = 21 > 21</option>

   </select>
Zoom:
<input type="button" id="zoom_in_button" style="width: 40px" value="+" onclick= increase_magnification()>
<input type="button" id="zoom_out_button" style="width: 40px" value="-" onclick= decrease_magnification()>

 <div id="info_message2" style="float:right; position: relative;"> </div>

<div id="info_message"style="float:right; position: relative;" > </div>

</form>
</div>
<div id="s3" style="position: relative; display: none">
<textarea id="s2" style="position: relative; left:1; " rows="6" cols="80">
x = 158, y = 158, rule = B36/S23
6$127b3o9b3o$130bo7bo$125bobo3bo5bo3bobo$132bo3bo$123bobo7bobo7bobo$
126bo6bobo6bo$121bobo3bo3bobobobo3bo3bobo$121bo6bo11bo6bo$121bo7bobo5b
obo7bo$122bo23bo$123bo3bobo9bobo3bo$124bo19bo$125b3o13b3o2$122bo23bo$
120bo3bo19bo3bo2$119bo5bo17bo5bo2$120bo3bo19bo3bo$122bo23bo2$125b3o13b
3o$124bo19bo$123bo3bobo9bobo3bo$122bo23bo$121bo7bobo5bobo7bo$121bo6bo
11bo6bo$121bobo3bo3bobobobo3bo3bobo$126bo6bobo6bo$123bobo7bobo7bobo$
132bo3bo$125bobo3bo5bo3bobo$75b3o9b3o40bo7bo$78bo7bo40b3o9b3o$73bobo3b
o5bo3bobo$80bo3bo$71bobo7bobo7bobo$74bo6bobo6bo$69bobo3bo3bobobobo3bo
3bobo$69bo6bo11bo6bo$69bo7bobo5bobo7bo$70bo23bo$71bo3bobo9bobo3bo$72bo
19bo$73b3o13b3o2$70bo23bo$68bo3bo19bo3bo2$67bo5bo17bo5bo2$68bo3bo19bo
3bo$70bo23bo31b3o9b3o$129bo7bo$73b3o13b3o32bobo3bo5bo3bobo$72bo19bo38b
o3bo$71bo3bobo9bobo3bo28bobo7bobo7bobo$70bo23bo30bo6bobo6bo$30b3o9b3o
24bo7bobo5bobo7bo24bobo3bo3bobobobo3bo3bobo$33bo7bo27bo6bo11bo6bo24bo
6bo11bo6bo$28bobo3bo5bo3bobo22bobo3bo3bobobobo3bo3bobo24bo7bobo5bobo7b
o$35bo3bo34bo6bobo6bo30bo23bo$26bobo7bobo7bobo22bobo7bobo7bobo28bo3bob
o9bobo3bo$29bo6bobo6bo34bo3bo38bo19bo$24bobo3bo3bobobobo3bo3bobo22bobo
3bo5bo3bobo32b3o13b3o$24bo6bo11bo6bo27bo7bo$24bo7bobo5bobo7bo24b3o9b3o
31bo23bo$25bo23bo69bo3bo19bo3bo$26bo3bobo9bobo3bo$27bo19bo70bo5bo17bo
5bo$28b3o13b3o$119bo3bo19bo3bo$25bo23bo71bo23bo$23bo3bo19bo3bo$124b3o
13b3o$22bo5bo17bo5bo70bo19bo$122bo3bobo9bobo3bo$23bo3bo19bo3bo69bo23bo
$25bo23bo70bo7bobo5bobo7bo$120bo6bo11bo6bo$28b3o13b3o73bobo3bo3bobobob
o3bo3bobo$27bo19bo27b3o9b3o35bo6bobo6bo$26bo3bobo9bobo3bo29bo7bo35bobo
7bobo7bobo$25bo23bo23bobo3bo5bo3bobo39bo3bo$24bo7bobo5bobo7bo29bo3bo
39bobo3bo5bo3bobo$24bo6bo11bo6bo20bobo7bobo7bobo35bo7bo$24bobo3bo3bobo
bobo3bo3bobo23bo6bobo6bo35b3o9b3o$29bo6bobo6bo23bobo3bo3bobobobo3bo3bo
bo$26bobo7bobo7bobo20bo6bo11bo6bo$35bo3bo29bo7bobo5bobo7bo$28bobo3bo5b
o3bobo23bo23bo$33bo7bo29bo3bobo9bobo3bo$30b3o9b3o27bo19bo$73b3o13b3o2$
70bo23bo$68bo3bo19bo3bo2$67bo5bo17bo5bo$127b3o9b3o$68bo3bo19bo3bo33bo
7bo$70bo23bo30bobo3bo5bo3bobo$132bo3bo$73b3o13b3o31bobo7bobo7bobo$72bo
19bo33bo6bobo6bo$71bo3bobo9bobo3bo27bobo3bo3bobobobo3bo3bobo$70bo23bo
26bo6bo11bo6bo$69bo7bobo5bobo7bo25bo7bobo5bobo7bo$69bo6bo11bo6bo26bo
23bo$69bobo3bo3bobobobo3bo3bobo27bo3bobo9bobo3bo$74bo6bobo6bo33bo19bo$
71bobo7bobo7bobo31b3o13b3o$80bo3bo$73bobo3bo5bo3bobo30bo23bo$78bo7bo
33bo3bo19bo3bo$75b3o9b3o$119bo5bo17bo5bo2$120bo3bo19bo3bo$122bo23bo2$
125b3o13b3o$124bo19bo$123bo3bobo9bobo3bo$122bo23bo$121bo7bobo5bobo7bo$
121bo6bo11bo6bo$121bobo3bo3bobobobo3bo3bobo$126bo6bobo6bo$123bobo7bobo
7bobo$132bo3bo$125bobo3bo5bo3bobo$130bo7bo$127b3o9b3o!
</textarea>
<br>
<input type="button" style="float:center; position: relative;" value="Hide info window" onclick="hide_info_window()">

</div>

<div style="position: relative; border: 1px solid #c3c3c3; width: 960px;   -webkit-user-select: none;  font-size: 100%">

<!-- <div id="info_message" style="float:left; position: relative;">hi</div> -->
<canvas id="layer3" width="960" height="640" 
style="border:1px solid #c3c3c3; position: absolute;  left: 8;" style="z-index: 3;"
>
Your browser does not support the canvas element.
</canvas>

<canvas id="layer2" width="960" height="640" 
style="border:1px solid #c3c3c3; position: absolute;  left: 8;" style="z-index: 2;"
>
Your browser does not support the canvas element.
</canvas>
 
 
<canvas id="myCanvas" width="960" height="640" 
style="border:1px solid #c3c3c3;  position: absolute;  left: 8;" style="z-index: 1;"
onkeydown = "getArrows(event)" 
onmousemove="cnvs_mousemove(event)" 
onmouseup="cnvs_mouseup(event)" 
onmousedown="cnvs_mousedown(event)">
Your browser does not support the canvas element.
</canvas>

<!--
<style>
        #layer3 { background-image: url(./spritelife-aux/1over16-grid-8k.jpg); background-repeat: repeat; }
</style>

-->

</div>







<!--
<script type="text/javascript" src="./browserdetect.js"></script>
-->




<script type="text/javascript">

function hide_info_window () {
      mouseYoffset = mouseYoffset - 120;

   // This code hides  "s3"  :
  document.getElementById("s3").style.display = "none";

}

function show_info_window (msg) {
      mouseYoffset = mouseYoffset + 120;   // need to integrate this with initialize R1 and R2!!!!!!!!!!!!!!!!!

   // This code shows  "s3"  :
   document.getElementById("s3").style.display = "";
   document.getElementById("s2").value = msg;
}



// vegetable tray and mashed potatoes, no soup.   2pm

//***************************************

// global variables for now. 


//var kilroy_red = "rgba(255,0,0,0.2)";


var red =    0x1000;       //"rgba(255,0,0,1)"; // The colors are really coming from the html input form above
var yellow = 0x0100;    //"#FFFF00";
var green =  0x0010;    // "#00FF00";
var blue =   0x0001;      //"#0066FF";
var decaygray =  0x10000;
var gray      =   0x10000;  // gray and decaygray are interchangeable for now

var brown = "#804000"; 
var black = "#000000";
var white = "#FFFFFF";
var non_game_canvas_color = white;
var transparent_color1 = "rgba(0,0,0,0)";
var transparent_color2 = "#000000";
var background = 0 // transparent_color1;
var erase = background;
var greenish_select_color = "#69874C"  
// "greenish_select_color doesn't have to be green, but this name helps disambiguate 
//  the color of the "select box" from the color of what was selected.

var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
var rpxid1 = cxt.createImageData(1,1);
var rpxdd1 = rpxid1.data;
var rpxid2 = cxt.createImageData(2,2);
var rpxdd2 = rpxid2.data;
var rpxid3 = cxt.createImageData(3,3);
var rpxdd3 = rpxid3.data;
var rpxid4 = cxt.createImageData(4,4);
var rpxdd4 = rpxid4.data;
var rpxid8 = cxt.createImageData(8,8);
var rpxdd8 = rpxid8.data;
var rpxid16 = cxt.createImageData(16,16);
var rpxdd16 = rpxid16.data;




var  ypxid1 = cxt.createImageData(1,1);
var  ypxdd1 =  ypxid1.data;
var  ypxid2 = cxt.createImageData(2,2);
var  ypxdd2 =  ypxid2.data;
var  ypxid3 = cxt.createImageData(3,3);
var  ypxdd3 =  ypxid3.data;
var  ypxid4 = cxt.createImageData(4,4);
var  ypxdd4 =  ypxid4.data;
var  ypxid8 = cxt.createImageData(8,8);
var  ypxdd8 =  ypxid8.data;
var  ypxid16 = cxt.createImageData(16,16);
var  ypxdd16 =  ypxid16.data;

var  gpxid1 = cxt.createImageData(1,1);
var  gpxdd1 =  gpxid1.data;
var  gpxid2 = cxt.createImageData(2,2);
var  gpxdd2 =  gpxid2.data;
var  gpxid3 = cxt.createImageData(3,3);
var  gpxdd3 =  gpxid3.data;
var  gpxid4 = cxt.createImageData(4,4);
var  gpxdd4 =  gpxid4.data;
var  gpxid8 = cxt.createImageData(8,8);
var  gpxdd8 =  gpxid8.data;
var  gpxid16 = cxt.createImageData(16,16);
var  gpxdd16 =  gpxid16.data;


var  bpxid1 = cxt.createImageData(1,1);
var  bpxdd1 =  bpxid1.data;
var  bpxid2 = cxt.createImageData(2,2);
var  bpxdd2 =  bpxid2.data;
var  bpxid3 = cxt.createImageData(3,3);
var  bpxdd3 =  bpxid3.data;
var  bpxid4 = cxt.createImageData(4,4);
var  bpxdd4 =  bpxid4.data;
var  bpxid8 = cxt.createImageData(8,8);
var  bpxdd8 =  bpxid8.data;
var  bpxid16 = cxt.createImageData(16,16);
var  bpxdd16 =  bpxid16.data;

var  clrpxid1 = cxt.createImageData(1,1);
var  clrpxdd1 =  clrpxid1.data;
var  clrpxid2 = cxt.createImageData(2,2);
var  clrpxdd2 =  clrpxid2.data;
var  clrpxid3 = cxt.createImageData(3,3);
var  clrpxdd3 =  clrpxid3.data;
var  clrpxid4 = cxt.createImageData(4,4);
var  clrpxdd4 =  clrpxid4.data;
var  clrpxid8 = cxt.createImageData(8,8);
var  clrpxdd8 =  clrpxid8.data;
var  clrpxid16 = cxt.createImageData(16,16);
var  clrpxdd16 =  clrpxid16.data;

var  graypxid1 = cxt.createImageData(1,1);
var  graypxdd1 =  graypxid1.data;
var  graypxid2 = cxt.createImageData(2,2);
var  graypxdd2 =  graypxid2.data;
var  graypxid3 = cxt.createImageData(3,3);
var  graypxdd3 =  graypxid3.data;
var  graypxid4 = cxt.createImageData(4,4);
var  graypxdd4 =  graypxid4.data;
var  graypxid8 = cxt.createImageData(8,8);
var  graypxdd8 =  graypxid8.data;
var  graypxid16 = cxt.createImageData(16,16);
var  graypxdd16 =  graypxid16.data;


// rpxdd[0] = r; rpxdd[1] = g; rpxdd[2] = b; rpxdd[3] = a where a=normal a * 255; cxt.putImageData(pxid, x, y)

var red1x1array =    [255, 0, 0, 255];
var yellow1x1array = [255, 255, 0, 255];
var green1x1array =  [0, 255,0, 255];
var blue1x1array =   [0,255,255,255];
var clr1x1array =   [0,0,0,0];
var gray1x1array =   [189,189,189,255];


//var clr1x1array = [0, 0, 0, 255]; // The above is proven to work, this is just to see what happens if there are 255s instead of zeros.  Nope, doesn't work!  Leaves the screen with a black background. 

for (var j = 0;  j<4; j++){rpxdd1[j] = red1x1array[j]};
for (var i = 0;  i<4; i++){for (var j=0; j<4; j++) {rpxdd2[(i*4)+ j ] = red1x1array[j]}};   
for (var i = 0;  i<9; i++){for (var j=0; j<4; j++) {rpxdd3[(i*4)+ j ] = red1x1array[j]}};
for (var i = 0;  i<12; i++){for (var j=0; j<4; j++) {if (i%4 != 0) {rpxdd4[(i*4)+ j ] = red1x1array[j]}}};
for (var i = 0;  i<56; i++){for (var j=0; j<4; j++) {if (i%8 != 0) {rpxdd8[(i*4)+ j ] = red1x1array[j]}}};
for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {if (i%16 != 0) {rpxdd16[(i*4)+ j ] = red1x1array[j]}}};

for (var j = 0;  j<4; j++){ypxdd1[j] = yellow1x1array[j]};
for (var i = 0;  i<4; i++){for (var j=0; j<4; j++) {ypxdd2[(i*4)+ j ] = yellow1x1array[j]}};    
for (var i = 0;  i<9; i++){for (var j=0; j<4; j++) {ypxdd3[(i*4)+ j ] = yellow1x1array[j]}};
for (var i = 0;  i<12; i++){for (var j=0; j<4; j++) {if (i%4 != 0) {ypxdd4[(i*4)+ j ] = yellow1x1array[j]}}};
for (var i = 0;  i<56; i++){for (var j=0; j<4; j++) {if (i%8 != 0) {ypxdd8[(i*4)+ j ] = yellow1x1array[j]}}};
for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {if (i%16 != 0) {ypxdd16[(i*4)+ j ] = yellow1x1array[j]}}};


for (var j = 0;  j<4; j++){gpxdd1[j] = green1x1array[j]};
for (var i = 0;  i<4; i++){for (var j=0; j<4; j++) {gpxdd2[(i*4)+ j ] = green1x1array[j]}};    
for (var i = 0;  i<9; i++){for (var j=0; j<4; j++) {gpxdd3[(i*4)+ j ] = green1x1array[j]}};
for (var i = 0;  i<12; i++){for (var j=0; j<4; j++) {if (i%4 != 0) {gpxdd4[(i*4)+ j ] = green1x1array[j]}}};
for (var i = 0;  i<56; i++){for (var j=0; j<4; j++) {if (i%8 != 0) {gpxdd8[(i*4)+ j ] = green1x1array[j]}}};
for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {if (i%16 != 0) {gpxdd16[(i*4)+ j ] = green1x1array[j]}}};


/*  The above lines give the cells a 1 pixel gap, so that they align with a grid background, and can be seen as individual cells.
To do the same thing with the fillrect, do this:  
  cxt.fillStyle = "#FFFF00"
                cxt.fillRect(cel.xpos*magnification, cel.ypos*magnification, magnification - 1 , magnification - 1)
Except, magnification - 1 needn't be calculated over and over, so whenever magnification changes to 4, change a new variable called "magnigraph" to one less, 3 and then 
do this:  cxt.fillRect(cel.xpos*magnification, cel.ypos*magnification, magnigraph , magnigraph) and so forth for other magnifcation changes, like 16 (magnigraph = 15). 

Here's how to create cells without a 1 pixel gap:
for (var j = 0;  j<4; j++){rpxdd1[j] = red1x1array[j]};
for (var i = 0;  i<4; i++){for (var j=0; j<4; j++) {rpxdd2[(i*4)+ j ] = red1x1array[j]}};   
for (var i = 0;  i<9; i++){for (var j=0; j<4; j++) {rpxdd3[(i*4)+ j ] = red1x1array[j]}};
for (var i = 0;  i<16; i++){for (var j=0; j<4; j++) {rpxdd4[(i*4)+ j ] = red1x1array[j]}};
for (var i = 0;  i<64; i++){for (var j=0; j<4; j++) {rpxdd8[(i*8)+ j ] = red1x1array[j]}};
for (var i = 0;  i<256; i++){for (var j=0; j<4; j++) {rpxdd16[(i*4)+ j ] = red1x1array[j]}};



*/
for (var j = 0;  j<4; j++){bpxdd1[j] = blue1x1array[j]};
for (var i = 0;  i<4; i++){for (var j=0; j<4; j++) {bpxdd2[(i*4)+ j ] = blue1x1array[j]}};    
for (var i = 0;  i<9; i++){for (var j=0; j<4; j++) {bpxdd3[(i*4)+ j ] = blue1x1array[j]}};
for (var i = 0;  i<12; i++){for (var j=0; j<4; j++) {if (i%4 != 0) {bpxdd4[(i*4)+ j ] = blue1x1array[j]}}};
for (var i = 0;  i<56; i++){for (var j=0; j<4; j++) {if (i%8 != 0) {bpxdd8[(i*4)+ j ] = blue1x1array[j]}}};
for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {if (i%16 != 0) {bpxdd16[(i*4)+ j ] = blue1x1array[j]}}};


for (var j = 0;  j<4; j++){clrpxdd1[j] = clr1x1array[j]};
for (var i = 0;  i<4; i++){for (var j=0; j<4; j++) {clrpxdd2[(i*4)+ j ] = clr1x1array[j]}};    
for (var i = 0;  i<9; i++){for (var j=0; j<4; j++) {clrpxdd3[(i*4)+ j ] = clr1x1array[j]}};
for (var i = 0;  i<12; i++){for (var j=0; j<4; j++) {if (i%4 != 0) {clrpxdd4[(i*4)+ j ] = clr1x1array[j]}}};
for (var i = 0;  i<56; i++){for (var j=0; j<4; j++) {if (i%8 != 0) {clrpxdd8[(i*4)+ j ] = clr1x1array[j]}}};
for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {if (i%16 != 0) {clrpxdd16[(i*4)+ j ] = clr1x1array[j]}}};

for (var j = 0;  j<4; j++){graypxdd1[j] = gray1x1array[j]};
for (var i = 0;  i<4; i++){for (var j=0; j<4; j++) {graypxdd2[(i*4)+ j ] = gray1x1array[j]}};    
for (var i = 0;  i<9; i++){for (var j=0; j<4; j++) {graypxdd3[(i*4)+ j ] = gray1x1array[j]}};
for (var i = 0;  i<12; i++){for (var j=0; j<4; j++) {if (i%4 != 0) {graypxdd4[(i*4)+ j ] = gray1x1array[j]}}};
for (var i = 0;  i<56; i++){for (var j=0; j<4; j++) {if (i%8 != 0) {graypxdd8[(i*4)+ j ] = gray1x1array[j]}}};
for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {if (i%16 != 0) {graypxdd16[(i*4)+ j ] = gray1x1array[j]}}};





bighexarraypixels = [0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,
                     0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,
                     0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,
                     1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,
                     1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,
                     0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,
                     0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,
                     0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,
                     0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,
                     0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,
                     0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,
                     0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,
                     0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,
                     0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,
                     0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0]

smallhexarraypixels  = [0,1,1,0,0,0,0,0,
                        1,1,1,1,1,0,0,0,
                        1,1,1,1,1,1,0,0,
                        0,1,1,1,1,1,0,0,
                        0,1,1,1,1,1,1,0,
                        0,0,1,1,1,1,1,0,
                        0,0,0,0,1,1,0,0]


big_penta_prismatic = [0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,
                       0,0,2,2,2,2,2,0,0,0,0,0,0,0,0,0,
                       0,1,0,2,2,2,2,2,2,0,0,0,0,0,0,0,
                       1,1,1,0,2,2,2,2,2,2,2,0,0,0,0,0,
                       1,1,1,1,0,2,2,2,2,2,2,2,0,0,0,0,
                       0,1,1,1,1,0,2,2,2,2,2,2,0,0,0,0,
                       0,1,1,1,1,1,0,2,2,2,2,2,2,0,0,0,
                       0,0,1,1,1,1,1,0,2,2,2,2,2,0,0,0,
                       0,0,1,1,1,1,1,1,0,2,2,2,2,2,0,0,
                       0,0,0,1,1,1,1,1,1,0,2,2,2,2,0,0,
                       0,0,0,1,1,1,1,1,1,1,0,2,2,2,2,0,
                       0,0,0,0,1,1,1,1,1,1,1,0,2,2,2,0,
                       0,0,0,0,0,0,1,1,1,1,1,1,0,2,0,0,
                       0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,
                       0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0]

big_rhombus =
[0,0,0,3,3,0,0,0,0,0,0,0,0,0,0,0,
0,0,3,3,3,3,3,0,0,0,0,0,0,0,0,0,
0,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,
3,3,3,3,3,3,3,3,3,3,3,0,0,0,0,0,
0,0,3,3,3,3,3,3,3,3,0,2,0,0,0,0,
0,1,0,0,3,3,3,3,3,0,2,2,0,0,0,0,
0,1,1,1,0,0,3,3,0,2,2,2,2,0,0,0,
0,0,1,1,1,1,0,0,2,2,2,2,2,0,0,0,
0,0,1,1,1,1,1,1,0,2,2,2,2,2,0,0,
0,0,0,1,1,1,1,1,0,2,2,2,2,2,0,0,
0,0,0,1,1,1,1,1,1,0,2,2,2,2,2,0,
0,0,0,0,1,1,1,1,1,0,2,2,2,2,2,0,
0,0,0,0,0,0,1,1,1,1,0,2,2,2,0,0,
0,0,0,0,0,0,0,0,1,1,0,2,2,0,0,0,
0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0]

small_rhombus =
[0,3,3,0,0,0,0,0,
3,3,3,3,3,0,0,0,
0,0,3,3,0,2,0,0,
1,1,0,0,2,2,0,0,
1,1,1,0,2,2,2,0,
0,1,1,1,0,2,2,0,
0,0,1,1,0,2,0,0]



small_penta_prismatic = [0,2,2,0,0,0,0,0,
                         1,0,2,2,2,0,0,0,
                         1,1,0,2,2,2,0,0,
                         0,1,1,0,2,2,0,0,
                         0,1,1,1,0,2,2,0,
                         0,0,1,1,1,0,2,0,
                         0,0,0,0,1,1,0,0]


small_tri_general =    [0,2,2,2,2,2,2,0,
                        1,0,2,2,2,2,2,0,
                        1,1,0,2,2,2,2,0,
                        1,1,1,0,2,2,2,0,
                        1,1,1,1,0,2,2,0,
                        1,1,1,1,1,0,2,0,
                        1,1,1,1,1,1,0,0]



big_tri_general =   [0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,
                     1,0,2,2,2,2,2,2,2,2,2,2,2,2,2,0,
                     1,1,0,2,2,2,2,2,2,2,2,2,2,2,2,0,
                     1,1,1,0,2,2,2,2,2,2,2,2,2,2,2,0,
                     1,1,1,1,0,2,2,2,2,2,2,2,2,2,2,0,
                     1,1,1,1,1,0,2,2,2,2,2,2,2,2,2,0,
                     1,1,1,1,1,1,0,2,2,2,2,2,2,2,2,0,
                     1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
                     1,1,1,1,1,1,1,1,0,2,2,2,2,2,2,0,
                     1,1,1,1,1,1,1,1,1,0,2,2,2,2,2,0,
                     1,1,1,1,1,1,1,1,1,1,0,2,2,2,2,0,
                     1,1,1,1,1,1,1,1,1,1,1,0,2,2,2,0,
                     1,1,1,1,1,1,1,1,1,1,1,1,0,2,2,0,
                     1,1,1,1,1,1,1,1,1,1,1,1,1,0,2,0,
                     1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0]

small_reverse_tri =    [1,1,1,1,1,1,0,0,
                        1,1,1,1,1,0,2,0,
                        1,1,1,1,0,2,2,0,
                        1,1,1,0,2,2,2,0,
                        1,1,0,2,2,2,2,0,
                        1,0,2,2,2,2,2,0,
                        0,2,2,2,2,2,2,0]



big_reverse_tri =   [1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,
                     1,1,1,1,1,1,1,1,1,1,1,1,1,0,2,0,
                     1,1,1,1,1,1,1,1,1,1,1,1,0,2,2,0,
                     1,1,1,1,1,1,1,1,1,1,1,0,2,2,2,0,
                     1,1,1,1,1,1,1,1,1,1,0,2,2,2,2,0,
                     1,1,1,1,1,1,1,1,1,0,2,2,2,2,2,0,
                     1,1,1,1,1,1,1,1,0,2,2,2,2,2,2,0,
                     1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
                     1,1,1,1,1,1,0,2,2,2,2,2,2,2,2,0,
                     1,1,1,1,1,0,2,2,2,2,2,2,2,2,2,0,
                     1,1,1,1,0,2,2,2,2,2,2,2,2,2,2,0,
                     1,1,1,0,2,2,2,2,2,2,2,2,2,2,2,0,
                     1,1,0,2,2,2,2,2,2,2,2,2,2,2,2,0,
                     1,0,2,2,2,2,2,2,2,2,2,2,2,2,2,0,
                     0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0]
big_kagome = 
[1,1,1,1,1,1,0,3,3,3,3,3,3,3,3,0,
1,1,1,1,1,0,3,3,3,3,3,3,3,3,3,0,
1,1,1,1,0,3,3,3,3,3,3,3,3,3,3,0,
1,1,1,0,3,3,3,3,3,3,3,3,3,3,3,0,
1,1,0,3,3,3,3,3,3,3,3,3,3,3,3,0,
1,0,3,3,3,3,3,3,3,3,3,3,3,3,3,0,
0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,
3,3,3,3,3,3,3,3,3,3,3,3,3,0,2,0,
3,3,3,3,3,3,3,3,3,3,3,3,0,2,2,0,
3,3,3,3,3,3,3,3,3,3,3,0,2,2,2,0,
3,3,3,3,3,3,3,3,3,3,0,2,2,2,2,0,
3,3,3,3,3,3,3,3,3,0,2,2,2,2,2,0,
3,3,3,3,3,3,3,3,0,2,2,2,2,2,2,0]

small_kagome = 
[1,1,1,0,3,3,3,0,
1,1,0,3,3,3,3,0,
1,0,3,3,3,3,3,0,
0,3,3,3,3,3,0,0,
3,3,3,3,3,0,2,0,
3,3,3,3,0,2,2,0,
3,3,3,0,2,2,2,0]

big_trunc_hex = 
[0,0,0,1,1,1,0,3,3,3,3,3,3,3,3,0,
0,0,1,1,1,0,3,3,3,3,3,3,3,3,3,0,
0,1,1,1,0,3,3,3,3,3,3,3,3,3,3,0,
1,1,1,0,3,3,3,3,3,3,3,3,3,3,3,0,
1,1,0,3,3,3,3,3,3,3,3,3,3,3,3,0,
1,0,3,3,3,3,3,3,3,3,3,3,3,3,3,0,
0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,
3,3,3,3,3,3,3,3,3,3,3,3,3,0,2,0,
3,3,3,3,3,3,3,3,3,3,3,3,0,2,2,0,
3,3,3,3,3,3,3,3,3,3,3,0,2,2,2,0,
3,3,3,3,3,3,3,3,3,3,0,2,2,2,0,0,
3,3,3,3,3,3,3,3,3,0,2,2,2,0,0,0,
3,3,3,3,3,3,3,3,0,2,2,2,0,0,0,0]

small_trunc_hex = 
[0,0,1,0,3,3,3,0,
0,1,0,3,3,3,3,0,
1,0,3,3,3,3,3,0,
0,3,3,3,3,3,0,0,
3,3,3,3,3,0,2,0,
3,3,3,3,0,2,0,0,
3,3,3,0,2,0,0,0]



big_basketweave_left_and_right =
[1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,0]

big_basketweave_top_and_down = 
[4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0]

small_basketweave_lr = 
[1,1,1,0,2,2,2,0,
1,1,1,0,2,2,2,0,
1,1,1,0,2,2,2,0,
1,1,1,0,2,2,2,0,
1,1,1,0,2,2,2,0,
1,1,1,0,2,2,2,0,
1,1,1,0,2,2,2,0]

small_basketweave_td =
[4,4,4,4,4,4,4,0,
4,4,4,4,4,4,4,0,
4,4,4,4,4,4,4,0,
0,0,0,0,0,0,0,0,
5,5,5,5,5,5,5,0,
5,5,5,5,5,5,5,0,
5,5,5,5,5,5,5,0]

// turn "4arms" into a diamond!  

big_4arms =
[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,
 0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,
 0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,
 0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,
 0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,
 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
 0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,
 0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,
 0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,
 0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,
 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,
 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0]


small_4arms = 
[0,0,0,1,0,0,0,0,
 0,0,1,1,1,0,0,0,
 0,1,1,1,1,1,0,0,
 1,1,1,1,1,1,1,0,
 0,1,1,1,1,1,0,0,
 0,0,1,1,1,0,0,0,
 0,0,0,1,0,0,0,0]

big_8arms =
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0]


small_8arms = 
[1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,0]


big_kites = 
[9,9,9,2,2,9,9,9,9,9,9,9,9,9,9,9,
9,9,2,2,2,2,2,9,9,9,9,9,9,9,9,9,
9,1,9,2,2,2,2,9,4,9,9,9,9,9,9,9,
1,1,1,9,2,2,2,9,4,4,4,9,9,9,9,9,
1,1,1,1,9,2,2,9,4,4,4,4,9,9,9,9,
9,1,1,1,1,9,2,9,4,4,4,4,9,9,9,9,
9,1,1,1,1,1,9,9,4,4,4,4,4,9,9,9,
9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
9,9,3,3,3,3,3,9,9,6,6,6,6,6,9,9,
9,9,9,3,3,3,3,9,5,9,6,6,6,6,9,9,
9,9,9,3,3,3,3,9,5,5,9,6,6,6,6,9,
9,9,9,9,3,3,3,9,5,5,5,9,6,6,6,9,
9,9,9,9,9,9,3,9,5,5,5,5,9,6,9,9,
9,9,9,9,9,9,9,9,5,5,5,5,5,9,9,9,
9,9,9,9,9,9,9,9,9,5,5,9,9,9,9,9]

big_pentafloret =
[9,9,9,2,2,9,9,9,9,9,9,9,9,9,9,9,
9,9,9,2,2,2,2,9,9,9,9,9,9,9,9,9,
9,1,1,9,2,2,2,2,9,9,9,9,9,9,9,9,
1,1,1,1,9,2,2,2,9,4,4,9,9,9,9,9,
1,1,1,1,1,9,2,2,9,4,4,4,9,9,9,9,
9,1,1,1,1,1,9,2,9,4,4,4,9,9,9,9,
9,9,9,9,9,9,9,9,9,4,4,4,4,9,9,9,
9,3,3,3,3,3,9,9,9,4,4,4,4,9,9,9,
9,9,3,3,3,3,9,9,9,9,9,9,9,9,9,9,
9,9,9,3,3,3,9,5,9,6,6,6,6,6,9,9,
9,9,9,3,3,3,9,5,5,9,6,6,6,6,6,9,
9,9,9,9,3,3,9,5,5,5,9,6,6,6,6,9,
9,9,9,9,9,9,9,5,5,5,5,9,6,6,9,9,
9,9,9,9,9,9,9,9,5,5,5,5,9,9,9,9,
9,9,9,9,9,9,9,9,9,5,5,9,9,9,9,9]




// here's an experiment to see if cell size 4 can be made into a hex pattern from Golly's EmulateHexagonal icon
//for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {if  i%16 != 0) {ypxdd16[(i*4)+ j ] = yellow1x1array[j]*bighexarraypixels[i]}}};

for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { ypxdd8[(i*4)+ j ] = yellow1x1array[j]*smallhexarraypixels[i]}};
for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) { ypxdd16[(i*4)+ j ] = yellow1x1array[j]*bighexarraypixels[i]}};

// triange experiment
//for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { gpxdd8[(i*4)+ j ] = green1x1array[j]*( 1 == small_tri_general[i] )}};
//for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) { gpxdd16[(i*4)+ j ] = green1x1array[j]*( 1 == big_tri_general[i] || 2 == big_tri_general[i])}};

// Here's a multicolor experiment -- it assigns the green non-array size 16 block to half green (left triagnle) and half yellow (right triangle).
for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) { if (big_tri_general[i] == 1) {gpxdd16[(i*4)+ j ] = green1x1array[j]}}};
for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) { if (big_tri_general[i] == 2) {gpxdd16[(i*4)+ j ] = yellow1x1array[j]}}};

// end of experiment



var bpixel_array = []
var bpxid8_array = []
var bpxdd8_array = []
var bpxid16_array = []
var bpxdd16_array = []

var gpixel_array = []
var gpxid8_array = []
var gpxdd8_array = []
var gpxid16_array = []
var gpxdd16_array = []

var ypixel_array = []
var ypxid8_array = []
var ypxdd8_array = []
var ypxid16_array = []
var ypxdd16_array = []

var rpixel_array = []
var rpxid8_array = []
var rpxdd8_array = []
var rpxid16_array = []
var rpxdd16_array = []

var graypixel_array = []
var graypxid8_array = []
var graypxdd8_array = []
var graypxid16_array = []
var graypxdd16_array = []

for (var i = 0;  i<64; i++){
   gpxid8_array[i] = cxt.createImageData(8,8);
   gpxdd8_array[i] =  gpxid8_array[i].data;
   for (var k = 0;  k<56; k++) {for (var j=0; j<4; j++) {if (k%8 != 0) {gpxdd8_array[i][(k*4)+ j ] =  green1x1array[j]}}};  // Unless overrridden, default is a colored block
   gpxid16_array[i] = cxt.createImageData(16,16);
   gpxdd16_array[i] = gpxid16_array[i].data;
   for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++) {if (k%16 != 0) {gpxdd16_array[i][(k*4)+ j ] =  green1x1array[j]}}};  // Unless overrridden, default is a colored block


   ypxid8_array[i] = cxt.createImageData(8,8);
   ypxdd8_array[i] =  ypxid8_array[i].data;
   for (var k = 0;  k<56; k++) {for (var j=0; j<4; j++) {if (k%8 != 0) {ypxdd8_array[i][(k*4)+ j ] =  yellow1x1array[j]}}};  // Unless overrridden, default is a colored block

   ypxid16_array[i] = cxt.createImageData(16,16);
   ypxdd16_array[i] = ypxid16_array[i].data;
   for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++) {if (k%16 != 0) {ypxdd16_array[i][(k*4)+ j ] =  yellow1x1array[j]}}};  // Unless overrridden, default is a colored block

   bpxid8_array[i] = cxt.createImageData(8,8);
   bpxdd8_array[i] =  bpxid8_array[i].data;
   for (var k = 0;  k<56; k++) {for (var j=0; j<4; j++) {if (k%8 != 0) {bpxdd8_array[i][(k*4)+ j ] =  blue1x1array[j]}}};  // Unless overrridden, default is a colored block

   bpxid16_array[i] = cxt.createImageData(16,16);
   bpxdd16_array[i] = bpxid16_array[i].data;
   for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++) {if (k%16 != 0) {bpxdd16_array[i][(k*4)+ j ] =  blue1x1array[j]}}};  // Unless overrridden, default is a colored block

   rpxid8_array[i] = cxt.createImageData(8,8);
   rpxdd8_array[i] =  rpxid8_array[i].data;
   for (var k = 0;  k<56; k++) {for (var j=0; j<4; j++) {if (k%8 != 0) {rpxdd8_array[i][(k*4)+ j ] =  red1x1array[j]}}};  // Unless overrridden, default is a colored block

   rpxid16_array[i] = cxt.createImageData(16,16);
   rpxdd16_array[i] = rpxid16_array[i].data;
   for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++) {if (k%16 != 0) {rpxdd16_array[i][(k*4)+ j ] =  red1x1array[j]}}};  // Unless overrridden, default is a colored block

   graypxid8_array[i] = cxt.createImageData(8,8);
   graypxdd8_array[i] =  graypxid8_array[i].data;
   for (var k = 0;  k<56; k++) {for (var j=0; j<4; j++) {if (k%8 != 0) {graypxdd8_array[i][(k*4)+ j ] =  gray1x1array[j]}}};  // Unless overrridden, default is a colored block

   graypxid16_array[i] = cxt.createImageData(16,16);
   graypxdd16_array[i] = graypxid16_array[i].data;
   for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++) {if (k%16 != 0) {graypxdd16_array[i][(k*4)+ j ] =  gray1x1array[j]}}};  // Unless overrridden, default is a colored block

}


// Settig *pxdd*_array[0] to a colored block.

//What happens if color is non-background, and .extra value is zero?  Default to the color.
//  I'm making ALL .extra values the default above.    That way, if there isn't an icon for them, they'll show up as a colored block
// However, icons will ovewrite all but .extra = 0
// Example:  // color == green and .extra value = 0,  then the cell is green!
//for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) {if (i%8 != 0) {gpxdd8_array[0][(i*4)+ j ] =  green1x1array[j]}}};  
//for (var i = 0;  i<240; i++) {for (var j=0; j<4; j++) {if (i%16 != 0) {gpxdd16_array[0][(i*4)+ j ] =  green1x1array[j]}}}; 

//for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) {if (i%8 != 0) {ypxdd8_array[0][(i*4)+ j ] =  yellow1x1array[j]}}};  
//for (var i = 0;  i<240; i++) {for (var j=0; j<4; j++) {if (i%16 != 0) {ypxdd16_array[0][(i*4)+ j ] =  yellow1x1array[j]}}}; 

//for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) {if (i%8 != 0) {bpxdd8_array[0][(i*4)+ j ] =  blue1x1array[j]}}};  
//for (var i = 0;  i<240; i++) {for (var j=0; j<4; j++) {if (i%16 != 0) {bpxdd16_array[0][(i*4)+ j ] =  blue1x1array[j]}}}; 

//for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) {if (i%8 != 0) {rpxdd8_array[0][(i*4)+ j ] =  red1x1array[j]}}};  
//for (var i = 0;  i<240; i++) {for (var j=0; j<4; j++) {if (i%16 != 0) {rpxdd16_array[0][(i*4)+ j ] =  red1x1array[j]}}}; 

//for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) {if (i%8 != 0) {graypxdd8_array[0][(i*4)+ j ] =  gray1x1array[j]}}};  
//for (var i = 0;  i<240; i++) {for (var j=0; j<4; j++) {if (i%16 != 0) {graypxdd16_array[0][(i*4)+ j ] =  gray1x1array[j]}}}; 


//  Note, for hex rules, the above default may have to be a hex cell rather than a simple colored block!!!
// An easy way to work this:  when the hex cell is set, also set the *pxdd*_array[0] to the hex cell.


var colorinfo = {
    "blue": {   
                pxdd8_array: bpxdd8_array,
                pxid8_array: bpxid8_array,
                pxdd16_array: bpxdd16_array,
                pxid16_array: bpxid16_array,
                color1x1: blue1x1array
             },  // remember to comma or not comma as needed
    "green": {   
                pxdd8_array: gpxdd8_array,
                pxid8_array: gpxid8_array,
                pxdd16_array: gpxdd16_array,
                pxid16_array: gpxid16_array,
                color1x1: green1x1array
             },  // remember to comma or not comma as needed
    "yellow": {   
                pxdd8_array: ypxdd8_array,
                pxid8_array: ypxid8_array,
                pxdd16_array: ypxdd16_array,
                pxid16_array: ypxid16_array,
                color1x1: yellow1x1array
             },  // remember to comma or not comma as needed
    "red": {   
                pxdd8_array: rpxdd8_array,
                pxid8_array: rpxid8_array,
                pxdd16_array: rpxdd16_array,
                pxid16_array: rpxid16_array,
                color1x1: red1x1array
             },  // remember to comma or not comma as needed

    "gray": {   
                pxdd8_array: graypxdd8_array,
                pxid8_array: graypxid8_array,
                pxdd16_array: graypxdd16_array,
                pxid16_array: graypxid16_array,
                color1x1: gray1x1array
             }  // remember to comma or not comma as needed
}



function convert_color_to_text (c) {

  switch (c) {
    case blue: return "blue"; break;
    case green: return "green"; break;
    case yellow: return "yellow"; break;
    case red: return "red"; break;
    case gray: return "gray"; break;
    case background:  return "background"; break;   
   } 
}





function make_tri_array(color, size) {   // this could be make_bisected_shape if small_tri_general or big_tri_general was passed in as a parameter
      color = convert_color_to_text(color)
       if (size == 8) {
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_tri_general[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_tri_general[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_tri_general[i] || 2 == small_tri_general[i])}};
          return  colorinfo[color].pxid8_array       
       } 
       else {
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_tri_general[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_tri_general[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_tri_general[i] || 2 == big_tri_general[i])}};
          return colorinfo[color].pxid16_array     
        }
}

function make_penta_prismatic_array(color, size) {   // another biseected shape
      color = convert_color_to_text(color)
       if (size == 8) {
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_penta_prismatic[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_penta_prismatic[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_penta_prismatic[i] || 2 == small_penta_prismatic[i])}};
          return  colorinfo[color].pxid8_array       
       } 
       else {
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_penta_prismatic[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_penta_prismatic[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_penta_prismatic[i] || 2 == big_penta_prismatic[i])}};
          return colorinfo[color].pxid16_array     
        }
}

function make_rhombus_array(color, size) {    // A trisected shape.
                 // for reference:  cell_left = celdotextra == 1 || celdotextra == 4 || celdotextra == 6 || celdotextra == 7
                 // for reference:  cell_right = celdotextra == 2 || celdotextra == 5 || celdotextra == 6 || celdotextra == 7
                 // for reference:  cell_top = celdotextra == 3 || celdotextra == 4 || celdotextra == 5 || celdotextra == 7

      color = convert_color_to_text(color)

       if (size == 8) {
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_rhombus[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_rhombus[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 3 == small_rhombus[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_rhombus[i] || 3 == small_rhombus[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[5][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_rhombus[i] || 3 == small_rhombus[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[6][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_rhombus[i] || 2 == small_rhombus[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[7][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_rhombus[i] || 2 == small_rhombus[i] || 3 == small_rhombus[i])}};

          return  colorinfo[color].pxid8_array       
       } 
       else {
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_rhombus[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_rhombus[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 3 == big_rhombus[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_rhombus[i] || 3 == big_rhombus[i])}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[5][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_rhombus[i] || 3 == big_rhombus[i])}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[6][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_rhombus[i] || 2 == big_rhombus[i])}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[7][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_rhombus[i] || 2 == big_rhombus[i] || 3 == big_rhombus[i])}};

          return colorinfo[color].pxid16_array     
        }
}

function make_kagome_array(color, size) {    // A trisected shape.
                  // 8 states, background + 7 non-zero .extra values 
                 // top_left = 001 bot_right = 010 middle = 100  topleft&botright = 011 mid&topleft = 101 mid&botright = 110 midtopbot = 111  
                // top_left = 1   bot_right = 2   middlle = 4   top&bot = 3 mid&topleft = 5 mid&botright = 6 midtopbot = 7 

               
      color = convert_color_to_text(color)

       if (size == 8) {
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_kagome[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_kagome[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_kagome[i] || 2 == small_kagome[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 3 == small_kagome[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[5][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_kagome[i] || 3 == small_kagome[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[6][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_kagome[i] || 3 == small_kagome[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[7][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_kagome[i] || 2 == small_kagome[i] || 3 == small_kagome[i])}};

          return  colorinfo[color].pxid8_array       
       } 
       else {
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_kagome[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_kagome[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_kagome[i] || 2 == big_kagome[i])}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 3 == big_kagome[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[5][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_kagome[i] || 3 == big_kagome[i])}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[6][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_kagome[i] || 3 == big_kagome[i])}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[7][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_kagome[i] || 2 == big_kagome[i] || 3 == big_kagome[i])}};

          return colorinfo[color].pxid16_array     
        }
}

function make_trunc_hex_array(color, size) {    // A trisected shape.
                  // 8 states, background + 7 non-zero .extra values 
                 // top_left = 001 bot_right = 010 middle = 100  topleft&botright = 011 mid&topleft = 101 mid&botright = 110 midtopbot = 111  
                // top_left = 1   bot_right = 2   middlle = 4   top&bot = 3 mid&topleft = 5 mid&botright = 6 midtopbot = 7 

               
      color = convert_color_to_text(color)

       if (size == 8) {
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_trunc_hex[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_trunc_hex[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_trunc_hex[i] || 2 == small_trunc_hex[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 3 == small_trunc_hex[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[5][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_trunc_hex[i] || 3 == small_trunc_hex[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[6][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_trunc_hex[i] || 3 == small_trunc_hex[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[7][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_trunc_hex[i] || 2 == small_trunc_hex[i] || 3 == small_trunc_hex[i])}};

          return  colorinfo[color].pxid8_array       
       } 
       else {
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_trunc_hex[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_trunc_hex[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_trunc_hex[i] || 2 == big_trunc_hex[i])}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 3 == big_trunc_hex[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[5][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_trunc_hex[i] || 3 == big_trunc_hex[i])}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[6][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_trunc_hex[i] || 3 == big_trunc_hex[i])}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[7][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_trunc_hex[i] || 2 == big_trunc_hex[i] || 3 == big_trunc_hex[i])}};

          return colorinfo[color].pxid16_array     
        }
}


function make_basketweave_array(color, size) { 
      color = convert_color_to_text(color)
       if (size == 8) {
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_basketweave_lr[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_basketweave_lr[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_basketweave_lr[i] || 2 == small_basketweave_lr[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 4 == small_basketweave_td[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[5][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 5 == small_basketweave_td[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[6][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 4 == small_basketweave_td[i] || 5 == small_basketweave_td[i])}};
          return  colorinfo[color].pxid8_array       
       } 
       else {
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_basketweave_left_and_right[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_basketweave_left_and_right[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_basketweave_left_and_right[i] || 2 == big_basketweave_left_and_right[i])}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 4 == big_basketweave_top_and_down[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[5][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 5 == big_basketweave_top_and_down[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[6][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 4 == big_basketweave_top_and_down[i] || 5 == big_basketweave_top_and_down[i])}};
          return colorinfo[color].pxid16_array     
        }
}


function make_octosquare_array(color, size) {   
      color = convert_color_to_text(color)
       if (size == 8) {
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_4arms[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*(1 == small_8arms[i] )}};
        return  colorinfo[color].pxid8_array       
       } 
       else {
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_4arms[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_8arms[i] )}};
          return colorinfo[color].pxid16_array     
        }
}


function make_elongtri_array (color, size) {
      color = convert_color_to_text(color)
       if (size == 8) {
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_tri_general[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_tri_general[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_tri_general[i] || 2 == small_tri_general[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*(1 == small_8arms[i] )}};  // This is a stand in -- need a block
          return  colorinfo[color].pxid8_array       
       } 
       else {
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_tri_general[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_tri_general[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_tri_general[i] || 2 == big_tri_general[i])}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_8arms[i] )}};
          return colorinfo[color].pxid16_array     
        }
}

function make_snubsquare_array (color, size) {  // uh oh!  I think regular trilife uses backslash trigangles!
      color = convert_color_to_text(color)
       if (size == 8) {
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_tri_general[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[5][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_tri_general[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[6][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_tri_general[i] || 2 == small_tri_general[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_reverse_tri[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_reverse_tri[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_reverse_tri[i] || 2 == small_reverse_tri[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[7][(i*4)+ j ] = colorinfo[color].color1x1[j]*(1 == small_8arms[i] )}};  // This is a stand in -- need a block
          return  colorinfo[color].pxid8_array     

 
       } 
       else {
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_tri_general[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[5][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_tri_general[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[6][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_tri_general[i] || 2 == big_tri_general[i])}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_reverse_tri[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_reverse_tri[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_reverse_tri[i] || 2 == big_reverse_tri[i])}};
         for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[7][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_8arms[i] )}};
          return colorinfo[color].pxid16_array     
        }
}

function make_tetrakis_square_array (color, size) {  // uh oh!  I think regular trilife uses backslash trigangles!
      color = convert_color_to_text(color)
       if (size == 8) {
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_tri_general[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[5][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_tri_general[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[6][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_tri_general[i] || 2 == small_tri_general[i])}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_reverse_tri[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == small_reverse_tri[i] )}};
          for (var i = 0;  i<56; i++) {for (var j=0; j<4; j++) { colorinfo[color].pxdd8_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == small_reverse_tri[i] || 2 == small_reverse_tri[i])}};
          return  colorinfo[color].pxid8_array     

 
       } 
       else {
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[4][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_tri_general[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[5][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_tri_general[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[6][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_tri_general[i] || 2 == big_tri_general[i])}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[1][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_reverse_tri[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[2][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 2 == big_reverse_tri[i] )}};
          for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[3][(i*4)+ j ] = colorinfo[color].color1x1[j]*( 1 == big_reverse_tri[i] || 2 == big_reverse_tri[i])}};
          return colorinfo[color].pxid16_array     
        }
}

function make_pentafloret_array (color, size) {
  color = convert_color_to_text(color)
  if (size == 16) {
     for (var s = 0; s<64; s++) {
       for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[s][(i*4)+ j ] = colorinfo[color].color1x1[j]*( (s >> (big_pentafloret[i] - 1)) & 1   )}}
     }
  }
}

function make_kites_array (color, size) {
  color = convert_color_to_text(color)
  if (size == 16) {
     for (var s = 0; s<64; s++) {
       for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) {colorinfo[color].pxdd16_array[s][(i*4)+ j ] = colorinfo[color].color1x1[j]*( (s >> (big_kites[i] - 1)) & 1   )}}
     }
  }
}




function make_hex_array (color, size) {
 // yellow1x1array[j]*smallhexarraypixels[j]}};
 //yellow1x1array[j]*bighexarraypixels[j]}};
// for (var i = 0;  i<240; i++){for (var j=0; j<4; j++) { ypxdd16[(i*4)+ j ] = yellow1x1array[j]*bighexarraypixels[i]}};

  for (var i = 0;  i<64; i++){ 
   switch (color) {
    case green: 
       if (size == 8) { for (var k = 0;  k<56; k++) { for (var j=0; j<4; j++)  {gpxdd8_array[i][(k*4)+ j ] =  green1x1array[j]*smallhexarraypixels[k]}}; } 
       else { for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++) {gpxdd16_array[i][(k*4)+ j ] =  green1x1array[j]*bighexarraypixels[k]}};  }
     break;
    case yellow:
       if (size == 8) {for (var k = 0;  k<56; k++) {for (var j=0; j<4; j++) {ypxdd8_array[i][(k*4)+ j ] =  yellow1x1array[j]*smallhexarraypixels[k]}}; } 
       else { for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++)  {ypxdd16_array[i][(k*4)+ j ] =  yellow1x1array[j]*bighexarraypixels[k]}};}
      break;
    case blue: 
       if (size == 8) {for (var k = 0;  k<56; k++) { for (var j=0; j<4; j++) {bpxdd8_array[i][(k*4)+ j ] =  blue1x1array[j]*smallhexarraypixels[k]}}; } 
       else { for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++) {bpxdd16_array[i][(k*4)+ j ] =  blue1x1array[j]*bighexarraypixels[k]}}; }
     break;
    case red:
       if (size == 8) {for (var k = 0;  k<56; k++) {for (var j=0; j<4; j++)  {rpxdd8_array[i][(k*4)+ j ] =  red1x1array[j]*smallhexarraypixels[k]}};  } 
       else { for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++)  {rpxdd16_array[i][(k*4)+ j ] =  red1x1array[j]*bighexarraypixels[k]}}; }
      break;
    case gray:
       if (size == 8) {for (var k = 0;  k<56; k++) {for (var j=0; j<4; j++)  {graypxdd8_array[i][(k*4)+ j ] =  gray1x1array[j]*smallhexarraypixels[k]}}; } 
       else { for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++)  {graypxdd16_array[i][(k*4)+ j ] =  gray1x1array[j]*bighexarraypixels[k]}}; }
      break;
   }
  }
 switch (color) {
    case green: 
       if (size == 8) {return gpxid8_array  }  else { return gpxid16_array   }
     break;
    case yellow:
       if (size == 8) {return ypxid8_array  } else { return gpxid16_array}
      break;
    case blue: 
       if (size == 8) { return bpxid8_array } else {return bpxid16_array   }
     break;
    case red:
       if (size == 8) {return rpxid8_array  } else { return rpxid16_array }
      break;
    case gray:
       if (size == 8) { return graypxid8_array }  else { return graypxid16_array  }
      break;
   }

}

                    
function make_block_array(color, size) {   
 for (var i = 0;  i<64; i++){ 
   switch (color) {
    case green: 
       if (size == 8) { for (var k = 0;  k<56; k++) { for (var j=0; j<4; j++) {if (k%8 != 0) {gpxdd8_array[i][(k*4)+ j ] =  green1x1array[j]} else {gpxdd8_array[i][(k*4)+ j ] =  clr1x1array[j]} }}; }  
       else { for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++) {if (k%16 != 0) {gpxdd16_array[i][(k*4)+ j ] =  green1x1array[j]} else {gpxdd16_array[i][(k*4)+ j ] =  clr1x1array[j]}  }}; } 
     break;
    case yellow:
       if (size == 8) {for (var k = 0;  k<56; k++) {for (var j=0; j<4; j++) {if (k%8 != 0) {ypxdd8_array[i][(k*4)+ j ] =  yellow1x1array[j]} else {ypxdd8_array[i][(k*4)+ j ] =  clr1x1array[j]} }}; } 
       else { for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++) {if (k%16 != 0) {ypxdd16_array[i][(k*4)+ j ] =  yellow1x1array[j]} else {ypxdd16_array[i][(k*4)+ j ] =  clr1x1array[j]}   }};}
      break;
    case blue: 
       if (size == 8) {for (var k = 0;  k<56; k++) { for (var j=0; j<4; j++) {if (k%8 != 0) {bpxdd8_array[i][(k*4)+ j ] =  blue1x1array[j]} else {bpxdd8_array[i][(k*4)+ j ] =  clr1x1array[j]}  }}; } 
       else { for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++) {if (k%16 != 0) {bpxdd16_array[i][(k*4)+ j ] =  blue1x1array[j]} else {bpxdd16_array[i][(k*4)+ j ] =  clr1x1array[j]}  }}; } 
     break;
    case red:
       if (size == 8) {for (var k = 0;  k<56; k++) {for (var j=0; j<4; j++) {if (k%8 != 0) {rpxdd8_array[i][(k*4)+ j ] =  red1x1array[j]} else {bpxdd8_array[i][(k*4)+ j ] =  clr1x1array[j]} }}; }  
       else { for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++) {if (k%16 != 0) {rpxdd16_array[i][(k*4)+ j ] =  red1x1array[j]} else {rpxdd16_array[i][(k*4)+ j ] =  clr1x1array[j]}  }}; } 
      break;
    case gray:
       if (size == 8) {for (var k = 0;  k<56; k++) {for (var j=0; j<4; j++) {if (k%8 != 0) {graypxdd8_array[i][(k*4)+ j ] =  gray1x1array[j]} else {graypxdd8_array[i][(k*4)+ j ] =  clr1x1array[j]} }}; }  
       else { for (var k = 0;  k<240; k++) {for (var j=0; j<4; j++) {if (k%16 != 0) {graypxdd16_array[i][(k*4)+ j ] =  gray1x1array[j]} else {graypxdd16_array[i][(k*4)+ j ] =  clr1x1array[j]} }}; } 
      break;
   }
  }
 switch (color) {
    case green: 
       if (size == 8) {return gpxid8_array  }  else { return gpxid16_array   }
     break;
    case yellow:
       if (size == 8) {return ypxid8_array  } else { return ypxid16_array}
      break;
    case blue: 
       if (size == 8) { return bpxid8_array } else {return bpxid16_array   }
     break;
    case red:
       if (size == 8) {return rpxid8_array  } else { return rpxid16_array }
      break;
    case gray:
       if (size == 8) { return graypxid8_array }  else { return graypxid16_array  }
      break;
   }

}

function set_icons (color) {
   // This function doesn't work unless it is only called when magnifcation == 8 or magnifcation == 16
     var color_pixel_array;
     switch (color) {
       case blue:  color_pixel_array = bpixel_array;
       break;
       case green:  color_pixel_array = gpixel_array;
       break;
       case yellow:  color_pixel_array = ypixel_array;
       break;
       case red:  color_pixel_array = rpixel_array;
       break;
       case gray:  color_pixel_array = graypixel_array;
       break;
     }
     switch (rulecode[color]) {
       case 30:  // Trilife radius 2
       case 14:  // Trilife radius 1
                  color_pixel_array = make_tri_array(color,magnification) 
                  break; 

       case 15:    color_pixel_array = make_rhombus_array(color,magnification)
                   break;
       case 51:    color_pixel_array = make_rhombus_array(color,magnification)
                   break;
       case 17:    color_pixel_array = make_penta_prismatic_array(color,magnification) 
                   break;
       case 18:    color_pixel_array =  make_basketweave_array(color,magnification)
                   break;
       case 39:    color_pixel_array =  make_trunc_hex_array(color,magnification)
                   break;
       case 40:    color_pixel_array =  make_kagome_array(color,magnification)
                   break;
       case 41:    color_pixel_array = make_octosquare_array(color,magnification)
                   break;
       case 44:    color_pixel_array = make_elongtri_array(color,magnification)
                   break;
       case 46:     color_pixel_array = make_snubsquare_array(color,magnification)
                   break;
       case 50:     color_pixel_array = make_tetrakis_square_array(color,magnification)
                   break;
       case 20:   if (magnification == 16)  {color_pixel_array = make_kites_array(color, magnification)} 
                  else {color_pixel_array = make_block_array(color, magnification)}
                   break;

       case 21:   if (magnification == 16)  {color_pixel_array = make_pentafloret_array(color, magnification)} 
                  else {color_pixel_array = make_block_array(color, magnification)}
                   break;

       case 3:  // Hex lifelike
       case 4:  // Hex Alternating
       case 5:  // Hex Generations
       case 10: // Hex Weighted  (no hex weighted generations currently?)
       case 11: // Hex Calaahan
                 // The above hex rulecodes don't necessarily make sense, but as long as they are implemented, they provide info that shouldn't be ignored.
                 //  Delete these cases if rulecodes are reassigned.  Hexhood[color] == 1 should be sufficient, if everything is working properly.
                 color_pixel_array = make_hex_array(color, magnification)
                 break;
                

       default:   if (hexhood[color] == 1) {
                      color_pixel_array = make_hex_array(color, magnification)
                              // note: radius2 changeweight code must check to see if the name of the weight includes "hex" to set hexhood, but it doesn't.
                   }
                  else {color_pixel_array = make_block_array(color, magnification)}
      }
}







/*
"FormerYugoslavia.jpg"
 "PIA02879.tiff"
"Io in front of Jupiter.jpg" 
"Snow_Leopard_Server_Wallpaper_by_subuddha.jpg" slower!!!!!
"world_map_color_continents 1011x539.jpg" 
"world_map_color_continents lighterblackocean 1011x539.jpg" 
"scandia-map-continents.png" 
"scandia-map-continents.png" 
m44_ngc2632_cancer_praesepe_hires.jpg -- starscape
09_200825.jpg -- very busy starscape

3-mollweide-projection.png
3-mollweide-projection-dkk-960x640.png
scandia-map-continents.png
smalldark-1.png
glowingedges-Peirce-quincuncial-projection.png
yale8.png
Stars_Basic.png
glowingedges-Peirce-quincuncial-projection.png
yale8.png
20081126020750-HWR-2.png
UniverseMap.png
First_Starmap.jpg
Big_Star_Test.jpg - too bright
Stars_Basic.png
Mercator-bw-world1.jpg
continents_colorNoLabelsMed-tan-bigcrop.png
continents_colorNoLabelsMed-1.png
*/






var mag_options = [1,2,3,4,8,16]
var mag_index = 1;  // Effectively sets the default to magnification = 2 if mag_options = [1,2,3,4,8,16]
var magnification = mag_options[mag_index];

// 960 is divisible  1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 16, 20, 24, 30, 32, 40, 48, 60, 64, 80, 96, 120, 160, 192, 240, 320, 480

var memoryX =  480 // 2000   //480 //2000 // 4000 // Math.floor(960/magnification);   // 960/4=240,  960/3 = 320, 960/2 = 480
var memoryY =  320 // 1000  //640 // Math.floor(memoryX / 1.5); //640 // 320  //Math.floor(memoryX / 1.5);  // for mag 3, 270 works well.   for mag 2, 405 would be equivalent.  for mag 4, 180

c.width =  memoryX*magnification     //c.width = 960;  

// calculating c.height 

//if ((window.innerHeight - 119)>memoryY*magnification ){c.height = memoryY*magnification} else {c.height=window.innerHeight - 119};   
c.height = memoryY*magnification  // temporary line for version 81 while figuring out what's going on.
   
  
cxt.fillStyle=transparent_color1;   
cxt.fillRect(0,0, c.width, c.height);

var layer2 = document.getElementById("layer2");
var ctx2 = layer2.getContext("2d");
layer2.width = c.width;
layer2.height = c.height;

var layer3 = document.getElementById("layer3");
var ctx3 = layer3.getContext("2d");
layer3.width = c.width;
layer3.height = c.height;



//var backdrop = new Image();
//backdrop.src = "./backdrops/continents_colorNoLabelsMed-colors3.png"   
//backdrop.onload = function() {
 //    ctx2.drawImage(backdrop, 0, 0, c.width, c.height);
  // };

// backdrop code moved to after the defnition for change_mag_aux
 


//***************


var delay = 0;     // Note that this is for timing, not generations.  decay != delay
var generation = 0;   // similarly, this has to do with what step it is, not Generations rule like StarWars (345/2/4)
var oddgeneration_p = 0;

var multi_color_mode = "two can be converted" // "2 does not convert" ;  // "2 does not convert" //"two can be converted"
var physicsOn = 1;
var drivingOn = 1;

var Xtopology =    "wraparound" ; // "oasis" // "wraparound" // "wraparound"  // "oasis"  // "wraparound" 
var Ytopology =    "wraparound" ; // "oasis"; // "wraparound" ; // "oasis" // "wraparound" // "oasis"

var random_fill_percentage = 32

function cell(xpos, ypos, color, placeholder_color, kilroy_color, Xspeed, placeholder_Xspeed, Xtally, placeholder_Xtally, Yspeed, placeholder_Yspeed, Ytally, placeholder_Ytally, message, physicsmessage, neighbors, alivecount,decayval, placeholder_decayval, extra, placeholder_extra){
   this.xpos = xpos;
   this.ypos = ypos;
   this.color = color;
   this.placeholder_color = placeholder_color;
   this.kilroy_color = kilroy_color;
   this.Xspeed = Xspeed;
   this.placeholder_Xspeed = placeholder_Xspeed;
   this.Xtally = Xtally;
   this.placeholder_Xtally = placeholder_Xtally;
   this.Yspeed = Yspeed;
   this.placeholder_Yspeed = placeholder_Yspeed;
   this.Ytally = Ytally;
   this.placeholder_Ytally = placeholder_Ytally;
   this.message = message;
   this.physicsmessage = physicsmessage;
   this.neighbors = neighbors;
   this.alivecount = alivecount; // con1
   this.decayval = decayval;
   this.placeholder_decayval = placeholder_decayval;
   this.extra = extra;
   this.placeholder_extra = placeholder_extra;
     
}; 

/*

function print_cell (bart) {
  document.write("Cell with x=" + bart.xpos + " y = " + bart.ypos + " Color = " + bart.color + "  Placeholder_color = " + bart.placeholder_color + "  Xspeed = " + bart.Xspeed + " placeholder_Xspeed = " + bart.placeholder_Xspeed + " Xtally = " + bart.Xtally + " Yspeed =  " + bart.Yspeed +" placeholder_Yspeed = " + bart.placeholder_Yspeed + " Ytally = " + bart.Ytally+ "<br>" ); 
}

function print_list_of_cells (arr) {
  var len = arr.length;
  if (len == 0) {"array has length zero"}
  else {
       for (var i = 0; i<len; i++) {print_cell(arr[i])};
       document.write("<br>");
      }
};


*/


function Create2DArray(rows) {
  var arr = [];
  for (var i=0;i<rows;i++) {
     arr[i] = [];
  }
  return arr;
};


// this should be useful  // but I wonder if it will work for whole cells or if it will have to modified to look for specific fields.
// this might be where assignment by reference is actually helpful.
function contains(arr, value) {
    var i = arr.length;
    while (i--) {
        if (arr[i] == value) return true;
    }
    return false;
}

function contains_or_is(arr, value) {
    if (arr == value) {return true}
    else {
   	 var i = arr.length;
    	while (i--) {
    	    if (arr[i] == value) return true;
  		 }
   	 return false;
   }
};


function contains_these_coords(arr, x,y) {
    var i = arr.length;
    while (i--) {
        if (arr[i].xpos == x && arr[i].ypos == y) return true;
    }
    return false;
}

 

function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places
   return Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
}

// thanks to http://www.mediacollege.com/internet/javascript/number/round.html
//function roundNumber(number, decimals) { // Arguments: number to round, number of decimal places
//	var newnumber = new Number(number+'').toFixed(parseInt(decimals));
//        return newnumber;
//};



/*
//The following functions are obsolte, but they show how the final versions were derived!

function getborderXcoord(Xoffset) {
  if (Xtopology == "oasis")
   { if (Xoffset < 0) {return 0}
     else if (Xoffset > memoryX-1) {return memoryX-1}
     else {return Xoffset}
   } 
   else if (Xtopology == "wraparound")
    {if (Xoffset < 0) {return (memoryX-1) + Xoffset + 1 } // non-superluminal:  {result = memoryX-1}
     else if (Xoffset > memoryX-1){return Xoffset - (memoryX-1) - 1 } // non-superluminal: {result = 0}
     else {return Xoffset}
    };
    return result;
};

	 
function getborderYcoord(Yoffset) {
  var result = 0;
  if (Ytopology == "oasis")
   { if (Yoffset < 0) {return 0}
     else if (Yoffset > memoryY-1) {return memoryY-1}
     else {return Yoffset}
   } 
   else if (Ytopology == "wraparound")
    {if (Yoffset < 0){return (memoryY-1) + Yoffset + 1 }              // non-superluminal:  {result = memoryY-1}
     else if (Yoffset > memoryY-1){return Yoffset - (memoryY-1) - 1 } // non-superluminal: {result = 0}

     else {return Yoffset}
    };
};

*/

/*

// would this be faster?   The idea is to handle the in boundry case first.
//  also, why not have memoryX-1 be a constant, changed whenever memoryX is changed.  Call it MemXm1

function getborderXcoord(Xoffset) {
   if (Xoffset > 0 || Xoffset <= memoryX-1) {return Xoffset}
   else if (Xoffset < 0){return (memoryX-1) + Xoffset + 1  } 
   else {return Xoffset - (memoryX-1) - 1  }
 };

*/



/*
function getborderXcoord(Xoffset) {
  if (Xoffset < 0) {return (memoryX-1) + Xoffset + 1  } 
  else if (Xoffset > memoryX-1) {return Xoffset - (memoryX-1) - 1  }
  else {return Xoffset}
};

function getborderYcoord(Yoffset) {
  if (Yoffset < 0) {return (memoryY-1) + Yoffset + 1  } 
  else if (Yoffset > memoryY-1) {return Yoffset - (memoryY-1) - 1  }
  else {return Yoffset}
};

*/

var getborderXcoord = function (Xoffset) {
  if (Xoffset < 0) {return (memoryX-1) + Xoffset + 1  } 
  else if (Xoffset > memoryX-1) {return Xoffset - (memoryX-1) - 1  }
  else {return Xoffset}
};


var getborderYcoord = function (Yoffset) {
 if (Yoffset < 0){return (memoryY-1) + Yoffset + 1 }        
 else if (Yoffset > memoryY-1){return Yoffset - (memoryY-1) - 1 } 
 else {return Yoffset}
};



/*
// How to switch to oasis mode by redefining function

getborderXcoord = function (Xoffset) {
     if (Xoffset < 0) {return 0}
     else if (Xoffset > memoryX-1) {return memoryX-1}
     else {return Xoffset}
}

getborderYcoord = function (Yoffset) { 
     if (Yoffset < 0) {return 0}
     else if (Yoffset > memoryY-1) {return memoryY-1}
     else {return Yoffset}
}

*/

// ******** MORE GLOBAL VARIABLES and Initialization ***************

var changedcells = [];
var changecount = 0;

var cellsinmotion = [];

var settypecell = new cell(0, 0, background, background,background,0, 0,0,0,0,0,0,0,"hi", "unlisted", [], 0,0,0,0,0,0); // con1

var arr = Create2DArray(memoryX);

for (var i=0;i<memoryX;i++){
 for (var j=0; j<memoryY;j++) {
   arr[i][j] = new cell(i, j, background, background,background,0, 0,0,0,0,0,0,0, "hi", "unlisted", [], 0,0,0,0,0,0); // con1
 };
};

// For radius 1, range = 8, and for radius 2, range = 24.  
//"Range" is a misnomer but it is useful to do a find on "range" to see everything
// related to range or radius.

var range = 8;

function precalculateNeighbors () {
   if (range == 8) {
    for (var i=0;i<memoryX;i++){
     for (var j=0; j<memoryY;j++) {
      arr[i][j].neighbors = [];   // this line only has to be there for REcalculating the neighbors.
       for (var y=-1; y<2; y++) {
          for (var x=-1;x<2;x++) {
           if (!(x == 0 && y == 0)) { 
              var nx = i + x;  
              var ny = j + y;   
              if (nx < 0 || nx >memoryX-1) {nx =  getborderXcoord(nx)};
              if (ny < 0 || ny>memoryY-1) {ny = getborderYcoord(ny)};
              arr[i][j].neighbors.push(arr[nx][ny]);
           }
         }
       }
      }
    }
   }
  else {
   for (var i=0;i<memoryX;i++){
     for (var j=0; j<memoryY;j++) {
      arr[i][j].neighbors = [];   // this line only has to be there for REcalculating the neighbors.
    // Range2 version - changed the order to match user-entered weight - start at the top, scan left, move down, scan left, etc.
      for (var y=-2; y<3; y++) {
         for (var x=-2;x<3;x++) {
           if (!(x == 0 && y == 0)) { 
              var nx = i + x;  
              var ny = j + y;   
              if (nx < 0 || nx >memoryX-1) {nx =  getborderXcoord(nx)};
              if (ny < 0 || ny>memoryY-1) {ny = getborderYcoord(ny)};
              arr[i][j].neighbors.push(arr[nx][ny]);
           }
         }
       }
      }
    }
   }
}





//******************



function detect_single_color(startX, startY, endX, endY) {
  var Y1 = Math.min(startY, endY);
  var Y2 = Math.max(startY, endY);
  var X1 = Math.min(startX, endX); 
  var X2 = Math.max(startX, endX);
    for (var j = Y1; j<Y2; j++) {
       for (var i = X1; i<X2; i++) {
          if (arr[i][j].color == red || arr[i][j].color == yellow ||arr[i][j].color == green ||arr[i][j].blue == red ) {
               return arr[i][j].color
          }
       }
    }
    // if the next line is executed, it means no colors were detected
    return background
}

function condenseRLE (result) {
 var newresult = "";
 var n = 1
 for (var c = 0; c < result.length; c++) {
   if (result[c] == result[c+1]) {
       n = n + 1
   } 
   else {
     if (n>1) {
      if  (!((result[c] == "." || result[c] == "b") && result[c+1] == "$")) {
          newresult = newresult.concat(n.toString() + result[c])
       }
     }
     else {
        newresult = newresult.concat(result[c])
     }
        
     n = 1
    }
 }
 return newresult
};

function condense_dsigns (result) {
 var newresult = "";
 var n = 1
 for (var c = 0; c < result.length; c++) {
   if (result[c] == "$" && result[c+1] == "$") {
       n = n + 1
   } 
   else {
     if (n>1) {
      if  (result[c] == "$") {
          newresult = newresult.concat(n.toString() + result[c])
       }
     }
     else {
        newresult = newresult.concat(result[c])
     }
        
     n = 1
    }
 }
 return newresult
};



   
function save_RLE_patternstring(single_color,startX, startY, endX, endY) {
  var result = "";
  var Y1 = Math.min(startY, endY);
  var Y2 = Math.max(startY, endY);
  var X1 = Math.min(startX, endX); 
  var X2 = Math.max(startX, endX);
    for (var j = Y1; j<Y2; j++) {
       for (var i = X1; i<X2; i++) {
          if (arr[i][j].color != background) {   
           if (uses_dot_extra[single_color]) {result = result.concat(String.fromCharCode(64 + arr[i][j].extra))}
           else if (arr[i][j].decayval > 0)  {result = result.concat(String.fromCharCode(66 + (decayrule[single_color] - arr[i][j].decayval)))}
 
            else  {
                   result = result.concat("A")
                   //var single_color = arr[i][j].color
                 }
           }
          else {result = result.concat(".")}
       }
     result = result.concat("$");
    }
   result = result.concat("!");
   // If the single rule in question is not a Generations rule, use the "o" and "b" RLE format.
      if (decayrule[single_color] == 0 && uses_dot_extra[single_color] == 0) {result = result.replace(/A/g, "o"); result = result.replace(/\./g, "b")};

   // Now, optionally, format the results to 69 character length lines

  /* This didn't work -- it mangles the RLE.  Not sure why
   var formatted_result = "";
   for (var i,j = 0; i<result.length; i++) {
         formatted_result = formatted_result.concat(result[i])
         j = j + 1;
         if (j>60){ formatted_result = formatted_result.concat("\n"); j = 0}
   }
  //return formatted_result;
    */
 // result = condense_dsigns(condenseRLE(result))
 // result = "x = " +  (X2 - X1) + ", y = " + (Y2 - Y1) + ", rule = " + rulename[single_color] + "\n" + result
  return result
};
 

function screensave_single_color_with_decay(single_color,startX, startY, endX, endY) {
  var result = "";
  var Y1 = Math.min(startY, endY);
  var Y2 = Math.max(startY, endY);
  var X1 = Math.min(startX, endX); 
  var X2 = Math.max(startX, endX);
  result = condense_dsigns(condenseRLE(save_RLE_patternstring(single_color,startX, startY, endX, endY) ))
  result = "x = " +  (X2 - X1) + ", y = " + (Y2 - Y1) + ", rule = " + rulename[single_color] + "\n" + result
  return result
}



//function draw () {
// draw game board's old state, from before the time of day

//  for (var i=0;i<memoryX;i++){
//   for (var j=0; j<memoryY;j++) {
//       cxt.fillStyle=convertcolor(arr[i][j].color);  
//       cxt.fillRect(i*magnification,j*magnification, magnification, magnification);
//   };
//  };
//};






//  The default can be the fillRect and clearRect methods, and fall to the default when the size and or color isn't available as ImageData.
//  Also the ImageData method is SLOW with Firefox on the mac (maybe ok on the PC) 
//     so detect which browser is being used, and use fillRect & clearRect if Firefox (only on the mac?) is detected.



 ypxid = ypxid2;
 rpxid = rpxid2;
 gpxid = gpxid2;
 bpxid = bpxid2;
 clrpxid = clrpxid2;
 graypxid = graypxid2;



function draw_normal_only_changed_from_list () {
   var cel;
   
       for (var i=changecount; i--;){
          cel = changedcells[i];

         switch (cel.color) {
            case 0: 
                cxt.putImageData(clrpxid, cel.xpos*magnification, cel.ypos*magnification);
                break;
            case  1:
                 cxt.putImageData(bpxid, cel.xpos*magnification, cel.ypos*magnification);
                break;
            case  16:
                cxt.putImageData(gpxid, cel.xpos*magnification, cel.ypos*magnification);
                break;
            case 256:
                cxt.putImageData(ypxid, cel.xpos*magnification, cel.ypos*magnification);
                break;
            case 4096:
                 cxt.putImageData(rpxid, cel.xpos*magnification, cel.ypos*magnification);
                 break;                
            default:
                cxt.putImageData(graypxid, cel.xpos*magnification, cel.ypos*magnification);
           };
      };
};


function draw_extra_only_changed_from_list () {
   var cel;
   
       for (var i=changecount; i--;){
          cel = changedcells[i];

         switch (cel.color) {
            case 0: 
                cxt.putImageData(clrpxid, cel.xpos*magnification, cel.ypos*magnification);
                break;
            case  1:
                 cxt.putImageData(bpixel_array[cel.extra], cel.xpos*magnification, cel.ypos*magnification);
                break;
            case  16:
                cxt.putImageData(gpixel_array[cel.extra], cel.xpos*magnification, cel.ypos*magnification);
                break;
            case 256:
                cxt.putImageData(ypixel_array[cel.extra], cel.xpos*magnification, cel.ypos*magnification);
                break;
            case 4096:
                 cxt.putImageData(rpixel_array[cel.extra], cel.xpos*magnification, cel.ypos*magnification);
                 break;                
            default:
                cxt.putImageData(graypixel_array[cel.extra], cel.xpos*magnification, cel.ypos*magnification);   
           };
      };
};

// comment on above function -- gray cells may never have .extra vaules, just like background color cells don't.



function draw_normal_withputimagedata () {

  for (var i=0;i<memoryX;i++){
   for (var j=0; j<memoryY;j++) {
          cel = arr[i][j];

         switch (cel.color) {
            case 0: 
                cxt.putImageData(clrpxid, cel.xpos*magnification, cel.ypos*magnification);
                break;
            case  1:
                 cxt.putImageData(bpxid, cel.xpos*magnification, cel.ypos*magnification);
                break;
            case  16:
                cxt.putImageData(gpxid, cel.xpos*magnification, cel.ypos*magnification);
                break;
            case 256:
                cxt.putImageData(ypxid, cel.xpos*magnification, cel.ypos*magnification);
                break;
            case 4096:
                 cxt.putImageData(rpxid, cel.xpos*magnification, cel.ypos*magnification);
                 break;                
            default:
                cxt.putImageData(graypxid, cel.xpos*magnification, cel.ypos*magnification);
           };

   };
  };
};

function draw_extra_withputimagedata () {

  for (var i=0;i<memoryX;i++){
   for (var j=0; j<memoryY;j++) {
          cel = arr[i][j];

         switch (cel.color) {
            case 0: 
                cxt.putImageData(clrpxid, cel.xpos*magnification, cel.ypos*magnification);
                break;
            case  1:
                 cxt.putImageData(bpixel_array[cel.extra], cel.xpos*magnification, cel.ypos*magnification);
                break;
            case  16:
                cxt.putImageData(gpixel_array[cel.extra], cel.xpos*magnification, cel.ypos*magnification);
                break;
            case 256:
                cxt.putImageData(ypixel_array[cel.extra], cel.xpos*magnification, cel.ypos*magnification);
                break;
            case 4096:
                 cxt.putImageData(rpixel_array[cel.extra], cel.xpos*magnification, cel.ypos*magnification);
                 break;                
            default:
                cxt.putImageData(graypixel_array[cel.extra], cel.xpos*magnification, cel.ypos*magnification);
           };

   };
  };
};

//   Assigning default draw function names
draw_only_changed_from_list = draw_normal_only_changed_from_list;
draw_withputimagedata = draw_normal_withputimagedata;




// --------------------------------------------------------------------------------------------------------------------------------------------
//        The following code is with regard to Fillrect vs PutImageData vs other methods


/*
// This version is slower for Chrome and Safari but faster for Firefox
// See seperate file for a discussion of this problem.  The following code may be out of date.   See other files - chrome experiment,etc.

function draw_only_changed_from_list (list_of_changed_cells) {
   var len = list_of_changed_cells.length;
   var c = "";
   
        for (var i=0;i<len;i++) {
          c = list_of_changed_cells[i].color;
          if (c !=background) {
              cxt.fillStyle = c; 

              cxt.fillRect(list_of_changed_cells[i].xpos*magnification,list_of_changed_cells[i].ypos*magnification, magnification, magnification);
          }
          else {
              cxt.clearRect(list_of_changed_cells[i].xpos*magnification ,list_of_changed_cells[i].ypos*magnification  , magnification, magnification);
          };

        };
};   
   
*/



 function superluminal_reckless_doPhysics () {
   var xn = 0;
   var yn = 0;
   var xoffset = 0;
   var yoffset = 0;
   var newcellsinmotion = [];
   var cellstoupdate = [];
   var cel = settypecell;     // coordinates selected just to establish a cell
   var newcell = settypecell;  // coordinates selected just to establish a cell
   
     var len = cellsinmotion.length;
     for (var i=0; i<len;i++) {
        cel = cellsinmotion[i]
        if (cel.color != background) {
         if (roundNumber(cel.Xspeed,3) != 0 || roundNumber(cel.Yspeed,3) !=0) 
         {
          cel.Xtally += cel.Xspeed;
          cel.Ytally += cel.Yspeed;

          
          cel.Xtally = roundNumber(cel.Xtally, 3);
          cel.Ytally = roundNumber(cel.Ytally, 3);

          if (Math.abs(cel.Xtally) < 1 && Math.abs(cel.Ytally) < 1)
           {

            //****reckless***if (contains(newcellsinmotion, cel) == false) {newcellsinmotion.push(cel)};
            newcellsinmotion.push(cel);
            cel.physicsmessage = "listed";
           }
           else // one of the tallies is exceed 1, so we move a cell
            { 
                //***** Superluminally recklessly changing "1" to "10" and "-1" to "-10" -- maybe get rid min and max?
               if (cel.Xtally >=0) 
                    {xoffset=Math.floor( cel.Xtally)}
               else {xoffset=Math.ceil( cel.Xtally)};

               if (cel.Ytally >=0)                   
                    {yoffset=Math.floor( cel.Ytally)}
               else {yoffset=Math.ceil( cel.Ytally)};
 
               xn = cel.xpos + xoffset;
               yn = cel.ypos + yoffset;  
               
               if (xn < 0 || xn >memoryX-1) {xn =  getborderXcoord(xn)};
               if (yn < 0 || yn>memoryY-1) {yn = getborderYcoord(yn)};


               newcell = arr[xn][yn];
               
                              
                //****reckless*** if (contains(cellstoupdate, newcell) == false) {cellstoupdate.push(newcell)};
               cellstoupdate.push(newcell)

              newcell.placeholder_decayval = cel.decayval; // this could be preceeded by "if (cel.color == decaygray) ...."

               newcell.placeholder_color =  cel.color; // this is controversial -- it ignores the possibility of a multi color collision.  
               newcell.placeholder_Xspeed += cel.Xspeed;
               newcell.placeholder_Yspeed += cel.Yspeed;

// ********Changing the next two lines to be more like doDriving where tally = tally - offset instead of tally = 0

          //  if (Math.abs(cel.Xtally)<1) {newcell.placeholder_Xtally = cel.Xtally} else {newcell.placeholder_Xtally = 0};
          //  if (Math.abs(cel.Ytally)<1) {newcell.placeholder_Ytally = cel.Ytally} else {newcell.placeholder_Ytally = 0};
               
              if (Math.abs(cel.Xtally)<1) {newcell.placeholder_Xtally = cel.Xtally} else {newcell.placeholder_Xtally = cel.Xtally - xoffset};
              if (Math.abs(cel.Ytally)<1) {newcell.placeholder_Ytally = cel.Ytally} else {newcell.placeholder_Ytally = cel.Ytally - yoffset};

             if (cel.color != decaygray && cel.color != background) {    // bagel the second clause should be unnnecessary   
            //if (cel.color != decaygray) {           
               	cel.neighbors[0].alivecount -= 1;
		cel.neighbors[1].alivecount -= 1;
                cel.neighbors[2].alivecount -= 1;
	        cel.neighbors[3].alivecount -= 1;
	        cel.neighbors[4].alivecount -= 1;
	        cel.neighbors[5].alivecount -= 1;
                cel.neighbors[6].alivecount -= 1;
	        cel.neighbors[7].alivecount -= 1;
            }
             else {cel.decayval = 0};  // if the cell currently is decaygray, it should get a decayval of zero when it becomes background.
               



                                  






               cel.Xspeed =0; // -= cel.Xspeed; //***********************************************************************
               cel.Yspeed =0; // -= cel.Yspeed;
               cel.color= background;
               
               cel.physicsmessage = "delta-unlisted";

               //if (contains(cellstoupdate, cel) == false) {cellstoupdate.push(cel)};

              // these four make generations rules with velocity turn blue
              //  cel.placeholder_Xspeed = 0;    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
              //  cel.placeholder_Yspeed = 0;   // this one and the one before might be part of the bagel project
              //  cel.placeholder_Xtally = 0; // bagel
              //  cel.placeholder_Ytally = 0; // bagel
 
               cel.Xtally =0; // maybe this means a placeholder_Xtally is needed?  Trying it now!
               cel.Ytally=0;

                if (cel.message != "just changed") //(contains(changedcells, cel) == false) // 
                   {
                     //changedcells.push(cel);
                     changedcells[changecount] = cel;
                     changecount +=1;
                     cel.message = "just changed";  
                     

                  };
            // con1  
          
      		      

             }
           } else {cel.physicsmessage = "alpha-unlisted";
                   //  cel.placeholder_Xtally = 0; // bagel
                   //  cel.placeholder_Ytally = 0; // bagel
                  //   cel.placeholder_Xspeed = 0; // bagel
                  //   cel.placeholder_Yspeed = 0; // bagel
                   //  cel.Xspeed = 0;  // double bagel
                  //  cel.Yspeed = 0; // double bagel
                   //   cel.Xtally = 0; // triple bagel
                  //  cel.Ytally = 0; // triple bagel

                   };
          } else {cel.physicsmessage = "beta-unlisted";
 
            //  cel.placeholder_Xspeed = 0;    //bagel
            //   cel.placeholder_Yspeed = 0;   // bagel
            //   cel.placeholder_Xtally = 0; // bagel
           //  cel.placeholder_Ytally = 0; // bagel
 

                //**********  Added for velcount

                    cel.Xspeed = 0;
                    cel.Yspeed = 0;
                  //  cel.Xtally = 0; // triple bagel
                  //  cel.Ytally = 0; // triple bagel

                  };
      };
      
      // now loop though cellstoupdate, adding to newcellsinmotion or not as appropriate.

      len = cellstoupdate.length;
      for (var i=0; i<len;i++) {

         cel = cellstoupdate[i];

         if ((cel.color == background || cel.color == decaygray) && cel.placeholder_color != decaygray && cel.placeholder_color != background) {  // the last && clause should be unnnecessary
                    // != cel.placeholder_color){ // in collisions, the two do equal each other.  hmmmm.
        cel.neighbors[0].alivecount += 1; 
	cel.neighbors[1].alivecount += 1;
	cel.neighbors[2].alivecount += 1;
	cel.neighbors[3].alivecount += 1;
	cel.neighbors[4].alivecount += 1;
	cel.neighbors[5].alivecount += 1;
	cel.neighbors[6].alivecount += 1;
	cel.neighbors[7].alivecount += 1;
     
           };

// ***** bagel!!!! 
if (cel.placeholder_color == decaygray && (cel.color != decaygray && cel.color != background)) {
    
        cel.neighbors[0].alivecount -= 1; 
	cel.neighbors[1].alivecount -= 1;
	cel.neighbors[2].alivecount -= 1;
	cel.neighbors[3].alivecount -= 1;
	cel.neighbors[4].alivecount -= 1;
	cel.neighbors[5].alivecount -= 1;
	cel.neighbors[6].alivecount -= 1;
	cel.neighbors[7].alivecount -= 1;
     
           };

         cel.color = cel.placeholder_color;
         cel.decayval = cel.placeholder_decayval;
          
// ************ extremely reckless *******    added for disable biology option (and it didn't work)
  //       cel.placeholder_color = background;
//****************************************
         cel.Xspeed = cel.placeholder_Xspeed;
         cel.Yspeed = cel.placeholder_Yspeed;
         cel.Xtally = cel.placeholder_Xtally;
         cel.Ytally = cel.placeholder_Ytally;  

         cel.Xspeed =  roundNumber(cel.Xspeed, 3)
         cel.Yspeed =   roundNumber(cel.Yspeed, 3)
         cel.Xtally =  roundNumber(cel.Xtally, 3)
         cel.Ytally =  roundNumber(cel.Ytally, 3)      

         cel.placeholder_Xtally = 0;
         cel.placeholder_Ytally = 0;
         cel.placeholder_Xspeed = 0;
         cel.placeholder_Yspeed = 0;

         cel.placeholder_decayval = 0;
        
   
  



         //if (cel.color == background) {alert("huh!"); cel.Xspeed = 0; cel.Yspeed = 0; cel.placeholder_Xspeed = 0; cel.placeholder_Yspeed = 0;};

         if (cel.Xspeed == 0 ) {cel.Xtally = 0};
         if (cel.Yspeed == 0) {cel.Ytally = 0};
         if (Math.abs(cel.Xspeed) > 0 || Math.abs(cel.Yspeed) > 0) 
           {
             //****reckless***if (contains(newcellsinmotion, cel) == false) {newcellsinmotion.push(cel)};
 // Maybe test to see if the cel is already on the newcellsinmotion list.   But test carefully after making that change!!!
             newcellsinmotion.push(cel);
             cel.physicsmessage = "listed";
            }
           else {cel.physicsmessage = "unlisted"};
          if (cel.message != "just changed") //(contains(changedcells, cel) == false) //(cel.message != "just changed")
           {
            //changedcells.push(cel);
                     changedcells[changecount] = cel;
                     changecount +=1;
            cel.message = "just changed";
       
            };
      };
     cellsinmotion = newcellsinmotion;
    
};




 

// ********************************Beginning of Getaliveneighbors section

//   GET ALIVE NEIGHBORS  -- the old way

// This follwoing commented-out way is even slower than the way used below.
//aliveneighbors = neighborlist.filter(alivecellp);
//alivecount = aliveneighbors.length;

// silly function for profiling purposes that uses global variables aliveneighbors and alivecount

// Note that getaliveneighbros has two features:
//  1) It stashes its results in the global variable alivecount, and sometimes alivecount is used instead of the value returned by getaliveneighbors. 
//   This can be changed, but be sure that all functions that call getaliveneighbors do the right thing and find the results in the right place.
//  
//  2)  getaliveneighbors completely ignores decaygray -- it treats it like any alive color.  This may be a feature, not a bug, to the functions which call getaliveneighbors.
//      Consider making a getNonDecayingAliveneighbors functionif it is needed.
//  


var aliveneighbors = []; // moved these four variable to global to avoid garbage collection pauses --- memory leak an issue?
var alivecount = 0;
var alive_k = 0;
var alive_ncell = settypecell;


function getaliveneighbors (neighborlist) {
     //var alive_ncell;
     alivecount = 0;
     for (  alive_k=range; alive_k--;) {
          alive_ncell = neighborlist[alive_k];
          if (alive_ncell.color != background) {
               aliveneighbors[alivecount]=alive_ncell; 
               alivecount++
           };
       };
    
            return alivecount
};

// ********************************End of Getaliveneighbors section


// Two neighbor and three neighbor color conversions are not allowed!   Disallowing three neighbor conversions may only speed things up a little bit, but this should be tested.
function con1doLifeRuleToCell2 (cel, len) {
    if (len > 3 || len < 2) { cel.placeholder_color = background;       // or the cell's killroy color
    
                          }

  else if (len == 2)   //{if (multi_color_mode == "2 does not convert")
                    {cel.placeholder_color = cel.color;}
                  // else
                   //  {if (neighborlist[0].color == neighborlist[1].color && cel.color != background) 
                   //    {cel.placeholder_color = neighborlist[0].color} else {cel.placeholder_color = cel.color}
                    // };
                 // }
  else if (len == 3)  {
      if (cel.color != background)  {cel.placeholder_color = cel.color;}  
       else {
                
    {getaliveneighbors (cel.neighbors);
      
     if (aliveneighbors[0].color == aliveneighbors[1].color || aliveneighbors[0].color == aliveneighbors[2].color) {cel.placeholder_color = aliveneighbors[0].color}
      else if ( aliveneighbors[1].color == aliveneighbors[2].color) {cel.placeholder_color =  aliveneighbors[1].color}
      else {cel.placeholder_color = aliveneighbors[Math.floor(Math.random()*3)].color}; // roll a three sided die and pick the corresponding parent
      //if (cel.color == background)       {
       cel.placeholder_Xspeed = roundNumber((aliveneighbors[0].Xspeed + aliveneighbors[1].Xspeed + aliveneighbors[2].Xspeed)/3,3);
       cel.placeholder_Yspeed = roundNumber((aliveneighbors[0].Yspeed + aliveneighbors[1].Yspeed + aliveneighbors[2].Yspeed)/3, 3);
       if (cel.placeholder_Xspeed != 0 || cel.placeholder_Yspeed !=0)
        { cel.placeholder_Xtally = roundNumber((aliveneighbors[0].Xtally + aliveneighbors[1].Xtally + aliveneighbors[2].Xtally)/3, 3);
          cel.placeholder_Ytally =  roundNumber((aliveneighbors[0].Ytally + aliveneighbors[1].Ytally + aliveneighbors[2].Ytally )/3, 3); 
         if  (cel.physicsmessage != "listed")
            {cellsinmotion.push(cel)
             cel.physicsmessage = "listed";
            };

        };
      } 
   
    }; 
  }        
};


/*
function fourcolorsort(i, iname, j, jname, k, kname, l, lname) {
  if (i > j) {
    if (j > k) {
      if (k > l) return [iname,  jname,  kname, lname,i,j,k,l];
      if (j > l) return [iname,  jname,  lname, kname,i,j,l,k];
      if (i > l) return [iname,  lname, jname,  kname, i,l,j,k];
      return [lname, iname,  jname,  kname, l,i,j,k];
    } else if (i > k) {
      if (j > l) return [iname,  kname, jname,  lname,i,k,j,l];
      if (k > l) return [iname,  kname, lname, jname,i,k,l,j];
      if (i > l) return [iname,  lname, kname, jname,i,l,k,j];
      return [lname, iname,  kname, jname,l,i,k,j];
    } else {
      if (j > l) return [kname, iname,  jname,  lname, k,i,j,l];
      if (i > l) return [kname, iname,  lname, jname,k,i,l,j];
      if (k > l) return [kname, lname, iname,  jname,k,l,i,j];
      return [lname, kname, iname,  jname,l,k,i,j];
    }
  } else {
    if (i > k) {
      if (k > l) return [jname,  iname,  kname, lname, j,i,k,l];
      if (i > l) return [jname,  iname,  lname, kname,j,i,l,k];
      if (j > l) return [jname,  lname, iname,  kname, j,l,i,k];
      return [lname, jname,  iname,  kname,l,j,i,k];
    } else if (j > k) {
      if (i > l) return [jname,  kname, iname,  lname,j,k,i,l];
      if (k > l) return [jname,  kname, lname, iname, j,k,l,i];
      if (j > l) return [jname,  lname, kname, iname, j,l,k,i];
      return [lname, jname,  kname, iname,l,j,k,i];
    } else {
      if (i > l) return [kname, jname,  iname,  lname,k,j,i,l];
      if (j > l) return [kname, jname,  lname, iname, k,j,l,i];
      if (k > l) return [kname, lname, jname,  iname, k,l,j,i];
      return [lname, kname, jname,  iname,l,k,j,i];
    }
  }
}


function tiebreaker2 (colorlist) {
  var chosencolor = colorlist[4];
  if (chosencolor != colorlist[5])  {return colorlist[0]}  
  else if (chosencolor != colorlist[6]) {return colorlist[ Math.floor(Math.random()*2)]} 
  else if (chosencolor != colorlist[7]) {return colorlist[Math.floor(Math.random()*3)]} 
  else {return colorlist[Math.floor(Math.random()*4)]};

}
*/


function car_of_fourcolorsort(i, iname, j, jname, k, kname, l, lname) {
  if (i > j) {
    if (j > k) {
      if (k > l) return iname; 
      if (j > l) return iname; 
      if (i > l) return iname; 
      return lname; 
    } else if (i > k) {
      if (j > l) return iname; 
      if (k > l) return iname;  
      if (i > l) return iname;  
      return lname;  
    } else {
      if (j > l) return kname;  
      if (i > l) return kname;  
      if (k > l) return kname; 
      return lname;  
    }
  } else {
    if (i > k) {
      if (k > l) return jname;  
      if (i > l) return jname;  
      if (j > l) return jname;  
      return lname;  
    } else if (j > k) {
      if (i > l) return jname;  
      if (k > l) return jname;  
      if (j > l) return jname; 
      return lname;  
    } else {
      if (i > l) return kname;  
      if (j > l) return kname;  
      if (k > l) return kname; 
      return lname;  
    }
  }
}

var   tempcolortotal = 0
var   tempreds = 0
var   tempyellows = 0
var   tempgreens = 0
var   tempblues = 0


//A for loop is slower than the if-then-else solution below:
  //  tempcolortotal = 0;
 //   for (i=range;i--;) {
 //     tempcolortotal += cellist[i].color
 //   };

function getmajoritycolor(cellist) {

   if (range == 8) {tempcolortotal = cellist[0].color +  cellist[1].color +  cellist[2].color +  cellist[3].color +  cellist[4].color +  cellist[5].color +  cellist[6].color +  cellist[7].color}
    else {          tempcolortotal = cellist[0].color +  cellist[1].color +  cellist[2].color +  cellist[3].color +  cellist[4].color +  cellist[5].color +  cellist[6].color +  cellist[7].color + cellist[8].color +  cellist[9].color +  cellist[10].color +  cellist[11].color +  cellist[12].color +  cellist[13].color +  cellist[14].color +  cellist[15].color + cellist[16].color +  cellist[17].color +  cellist[18].color +  cellist[19].color +  cellist[20].color +  cellist[21].color +  cellist[22].color +  cellist[23].color;}

   tempreds =    ( tempcolortotal & 0xF000) >> 12;
   tempyellows = ( tempcolortotal & 0xF00)  >> 8;
   tempgreens =  ( tempcolortotal & 0xF0)   >> 4;
   tempblues = tempcolortotal & 0xF; // and no shifting is necessary for the rightmost color.
   return car_of_fourcolorsort(tempreds, red, tempyellows, yellow,  tempgreens, green, tempblues, blue);
}
 
//   fourcolorsort prefers the last items -- in a tie of all four colors, the last one wins.
//   in the following example, red wins a tie vote.
//       return car_of_fourcolorsort(tempblues, blue, tempyellows, yellow, tempgreens, green, tempreds, red);
//   in the following example, blue wins a tie vote, followed by green, yellow, and finally red
//      return car_of_fourcolorsort(tempreds, red, tempyellows,yellow,  tempgreens, green,tempblues, blue);
//    If exploding or at least "hotter" rules are made red and yellow,and calmer rules are made green and blue, 
//       then we give a slight advantage to the cooler rules to offset the hotter rules' natural advantage.




// The following function is called only in the case where a cell has one and only one alive neighbor -- the function calculates the color
// The assumption is that the background color = 0 so that the colors are conducive to addition.
function getSingleNeighborColor (cellist) {
  if (range == 8) { return cellist[0].color +  cellist[1].color +  cellist[2].color +  cellist[3].color +  cellist[4].color +  cellist[5].color +  cellist[6].color +  cellist[7].color}
  else { return cellist[0].color +  cellist[1].color +  cellist[2].color +  cellist[3].color +  cellist[4].color +  cellist[5].color +  cellist[6].color +  cellist[7].color + cellist[8].color +  cellist[9].color +  cellist[10].color +  cellist[11].color +  cellist[12].color +  cellist[13].color +  cellist[14].color +  cellist[15].color + cellist[16].color +  cellist[17].color +  cellist[18].color +  cellist[19].color +  cellist[20].color +  cellist[21].color +  cellist[22].color +  cellist[23].color};
  }





// Range2 version

//  The weights menu should be moved to either the top of the document or to an  external javascript file so that it can be easily modified by hand 

var weightsmenu = [
        ["Range2 neighborhood", "Moore Radius2 neighborhood"],
        [[0,1,1,1,0,  1,1,1,1,1,  1,1,1,1,  1,1,1,1,1, 0,1,1,1,0],  "Disc Radius2 neighborhood"],
        [[1,0,1,0,1,  0,1,1,1,0,   1,1,1,1,  0,1,1,1,0, 1,0,1,0,1],  "Star Radius2 neighborhood"],
        [[0,0,1,0,0,  0,1,1,1,0,  1,1,1,1,  0,1,1,1,0, 0,0,1,0,0],  "Diamond Radius2 'hood"],
        [[0,1,0,1,0,  1,0,0,0,1,  0,0,0,0,  1,0,0,0,1,  0,1,0,1,0], "Knightlife neighborhood"],
        [[1,1,1,1,1,  1,0,0,0,1,  1,0,0,1,  1,0,0,0,1,  1,1,1,1,1],  "Perimeter Radius2 'hood"],
        [[0,1,0,0,0,  0,1,0,1,1,  0,0,0,0,  1,1,0,1,0,  0,0,0,1,0],  "Pinwheel Radius2 'hood"],
        [[0,0,1,0,0,  0,0,1,0,0,  1,1,1,1,  0,0,1,0,0,  0,0,1,0,0],   "vonNeuman Radius2 'hood"],

        ["1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1", "|-----------------------|"],

        [[1,1,1,0,0,  1,1,1,1,0,   1,1,1,1,  0,1,1,1,1, 0,0,1,1,1],  "Hex Radius2 neighborhood"],
        [[0,1,0,0,0,  1,1,1,1,0,   0,1,1,0,  0,1,1,1,1, 0,0,0,1,0],  "Hex Star neighborhood"],
        [[0,1,0,0,0,  0,1,1,0,0,   0,1,1,0,  0,1,1,1,1, 0,0,0,0,0],  "Hex Triangle neighborhood"],
        [[0,0,1,0,0,  0,1,1,0,0,   1,1,1,0,  0,0,1,1,0, 0,0,0,0,1],  "Hex BumpyTri neighborhood"],
        [[1,0,1,0,0,  0,1,1,0,0,   1,1,1,1,  0,0,1,1,0, 0,0,1,0,1],  "Hex Asterix neighborhood"],
        [[0,0,1,0,0,  0,0,1,0,0,    1,1,0,0,  0,0,0,1,0, 0,0,0,0,1],  "Hex Tripod Radius2 'hood"],
        ["1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1", "|-----------------------|"],

        ["Trilife Radius2 neighborhood", "Trilife Radius2 neighborhood"],
        ["1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1", "|-----------------------|"],

        [[0,0,1,0,0,  0,1,0,1,0,  1,0,0,1,  0,1,0,1,0,  0,0,1,0,0], "Diagonal Moore neighborhood"],
        [[0,0,0,0,0,  0,1,1,1,0,  0,1,1,0,  0,1,1,1,0, 0,0,0,0,0],  "Radius1 emulated Moore"],

      //  ["PromptForWeight","Enter New Weights"],

        ["1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1", "|-----------------------|"]
       ];

function change_weight (color, choice) {

   switch (choice) {
    case "PromptForWeight":   choice = r2_parse_rule_string(prompt("prompting for weights not implemented yet :"), color);  // note that parse_rule_string has side effects - it sets birthrule[color], etc.
                           
                            var previousred =   document.getElementById("redrule1").selectedIndex;
                            var previousyellow = document.getElementById("yellowrule1").selectedIndex;
                            var previousgreen = document.getElementById("greenrule1").selectedIndex;
                            var previousblue = document.getElementById("bluerule1").selectedIndex;
                              // better for Range2 version
                            rulesmenu.splice(0,0,[choice]);  // add new rule to list of rules
                            putrulesinmenus(); 
                            if (color != red && previousred > 0) {document.getElementById("redrule1").selectedIndex = previousred + 1} else {document.getElementById("redrule1").selectedIndex = 0};
                            if (color != yellow && previousyellow > 0) {document.getElementById("yellowrule1").selectedIndex = previousyellow + 1} else {document.getElementById("yellowrule1").selectedIndex = 0};
                            if (color != green && previousgreen > 0) {document.getElementById("greenrule1").selectedIndex = previousgreen + 1} else {document.getElementById("greenrule1").selectedIndex = 0};
                            if (color != blue && previousblue > 0) {document.getElementById("bluerule1").selectedIndex = previousblue + 1} else {document.getElementById("bluerule1").selectedIndex = 0};

                             break;


    case "Range2 neighborhood": 
                                weightrule[color] = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
                                if (bx2rule[color] == 0) {if (decayrule[color] == 0) {rulecode[color] = 1} else {rulecode[color] = 6}};
                                if (bx2rule[color] == 1) {rulecode[color] = 22}
                                 break;
   case "Trilife Radius2 neighborhood": 
                                weightrule[color] = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];  // unnecessary but don't want it to be undefined
                                rulecode[color] = 30; 

                     
              
                                          uses_dot_extra[color] = 1;  // need to turn this flag on or off for change_weight and change_rule and need to clear .extra whenever changing rulecode




                                 break;
   
      default:                  choicenums = choice.split(",");
                                for (i = 0; i<24; i++) {weightrule[color][i] = parseInt(choicenums[i])};


                               // if (decayrule[color] == 0) {rulecode[color] = 28} else {rulecode[color] = 29};
                               
                               switch (rulecode[color]) {
                                   case 1:  rulecode[color] = 28;
                                            break;
                                   case 6:  rulecode[color] = 29;
                                            break;
                                   case 22: rulecode[color] = 23;
                                            break;
                                   case 30:  rulecode[color] = 28;  // rulecode 30 is a two state rule
                                             uses_dot_extra[color] = 0;
                                            break;
                               }

                                break;

 

 
        }; // end of switch
       //  rulename[color] = choice;
      
        nested_refresh3 ();
         generation += 1 
        oddgeneration_p = (generation % 2);

        draw_withputimagedata ()
 };
   





var birthrule = [];
//**************************************************************************************************************************************************************
//birthrule[background] = [1, 0, 0, 0, 0, 0, 0, 0, 0];   // this is for the benefit of running B0 rules with non-B0 rules, and it may slow things down!!!!!  **************
birthrule[background] = [0, 0, 0, 0, 0, 0, 0, 0, 0];   


//  It does slow things down.  Here are two identical runs, one with zero, the other with one:  
// changedcell list length: 7514Time at stop clock = 2538

// changedcell list length: 5490Time at stop clock = 2084
//**************************************************************************************************************************************************************

birthrule[red] =       [0, 0, 0, 1, 0, 0, 0, 0, 0]; 
birthrule[yellow] =    [0, 0, 0, 1, 0, 0, 0, 0, 0];
birthrule[green] =     [0, 0, 0, 1, 0, 0, 0, 0, 0];    
birthrule[blue] =      [0, 0, 0, 1, 0, 0, 0, 0, 0];
birthrule[decaygray] =  [0, 0, 0, 1, 0, 0, 0, 0, 0];


var survivalrule = [];
survivalrule[red] =    [0, 0, 1, 1, 0, 0, 0, 0, 0];
survivalrule[yellow] = [0, 0, 1, 1, 0, 0, 0, 0, 0];
survivalrule[green] =  [0, 0, 1, 1, 0, 0, 0, 0, 0];
survivalrule[blue] =   [0, 0, 1, 1, 0, 0, 0, 0, 0];



var rulename = [];
rulename[red] =    "B3/S23";
rulename[yellow] = "B3/S23";
rulename[green] =  "B3/S23";
rulename[blue] =   "B3/S23";



var oddbirthrule =  [];
var evenbirthrule = [];
var oddsurvivalrule = [];
var evensurvivalrule= [];

oddbirthrule[red] =       [0, 0, 0, 1, 0, 0, 0, 0, 0]; 
oddbirthrule[yellow] =    [0, 0, 0, 1, 0, 0, 0, 0, 0];
oddbirthrule[green] =     [0, 0, 0, 1, 0, 0, 0, 0, 0];    
oddbirthrule[blue] =      [0, 0, 0, 1, 0, 0, 0, 0, 0];
evenbirthrule[red] =       [0, 0, 0, 1, 0, 0, 0, 0, 0]; 
evenbirthrule[yellow] =    [0, 0, 0, 1, 0, 0, 0, 0, 0];
evenbirthrule[green] =     [0, 0, 0, 1, 0, 0, 0, 0, 0];    
evenbirthrule[blue] =      [0, 0, 0, 1, 0, 0, 0, 0, 0];
oddsurvivalrule[red] =    [0, 0, 1, 1, 0, 0, 0, 0, 0];
oddsurvivalrule[yellow] = [0, 0, 1, 1, 0, 0, 0, 0, 0];
oddsurvivalrule[green] =  [0, 0, 1, 1, 0, 0, 0, 0, 0];
oddsurvivalrule[blue] =   [0, 0, 1, 1, 0, 0, 0, 0, 0];
evensurvivalrule[red] =    [0, 0, 1, 1, 0, 0, 0, 0, 0];
evensurvivalrule[yellow] = [0, 0, 1, 1, 0, 0, 0, 0, 0];
evensurvivalrule[green] =  [0, 0, 1, 1, 0, 0, 0, 0, 0];
evensurvivalrule[blue] =   [0, 0, 1, 1, 0, 0, 0, 0, 0];


rulecode = [];
rulecode[red] = 1;
rulecode[yellow] = 1;
rulecode[green] = 1;
rulecode[blue] = 1;
rulecode[decaygray] = 7;

var hexhood = [];
hexhood[red] = 0;
hexhood[yellow] = 0;
hexhood[green] = 0;
hexhood[blue] = 0;

var bx2rule = []
bx2rule[red] = 0;
bx2rule[yellow] = 0;
bx2rule[green] = 0;
bx2rule[blue] = 0;



var generations_rule = [];
generations_rule[background] = 0;
generations_rule[red] = 0;
generations_rule[yellow] = 0;
generations_rule[green] = 0;
generations_rule[blue] = 0;

var decayrule = [];
decayrule[background] = 0;
decayrule[red] = 0;
decayrule[yellow] = 0;
decayrule[green] = 0;
decayrule[blue] = 0;

var weightrule = []
weightrule[red]   =   [1,1,1,1,1,1,1,1];
weightrule[yellow] = [1,1,1,1,1,1,1,1];
weightrule[green] =  [1,1,1,1,1,1,1,1];
weightrule[blue] =   [1,1,1,1,1,1,1,1];


var B0_rule_p = 0;

var uses_dot_extra = [];
uses_dot_extra[background] = 0;
uses_dot_extra[red] = 0;
uses_dot_extra[yellow] = 0;
uses_dot_extra[green] = 0;
uses_dot_extra[blue] = 0;

var m_or_vn_weight = []  // Used for the exotic geometries where it would be simpler to just have a Von Neuman vs Moore flag instead of a weighted life scheme
m_or_vn_weight[background] = 1
m_or_vn_weight[red] = 1
m_or_vn_weight[yellow] = 1
m_or_vn_weight[green] = 1
m_or_vn_weight[blue] = 1


      /* 
         From liferules.cpp in the Golly source code,

         Use David Eppstein's idea to change the current rule depending on gen parity.
         If original rule has B0 but not S8:
      
         For even generations, whenever the original rule has a Bx or Sx, omit that 
         bit from the modified rule, and whenever the original rule is missing a
         Bx or Sx, add that bit to the modified rule.
         eg. B03/S23 => B1245678/S0145678.
      
         For odd generations, use Bx if and only if the original rule has S(8-x)
         and use Sx if and only if the original rule has B(8-x).
         eg. B03/S23 => B56/S58.
      
         If original rule has B0 and S8:
         
         Such rules don't strobe, so we just want to invert all the cells.
         The trick is to do both changes: invert the bits, and swap Bx for S(8-x).
         eg. B03/S238 => B123478/S0123467 (for ALL gens).
      */


function parse_rule_string (inputrulestring, color) {
	var original_inputrulestring = inputrulestring
        inputrulestring = inputrulestring.toUpperCase();

	weightrule[color] = [1,1,1,1,1,1,1,1]
        m_or_vn_weight[color] = 1  // used only for exotic geometries where a whole weightrule would be confusing
                                   // also allows "VN" to set weightrule for standard 4 of 8 neigbor VN without worrying about exotic VN definitions.
        uses_dot_extra[color] = 0;

	if (inputrulestring.match("H"))  {
                hexhood[color] = 1;
                weightrule[color] = [1,1,0,1,1,0,1,1]
         } 
         else {hexhood[color] = 0};  // note this disallows alternating between hex and non-hex.  Must test for H in even and odd to do that.

        if (inputrulestring.match("X2")) {   // note this disallows alternating between bx2 and non-bx2.  Must test for x2 in even and odd to do that.
                  bx2rule[color] = 1; 
                  inputrulestring = inputrulestring.replace("X2","");  // it is important to remove the "X2" so that the 2 isn't parsed as the birth rule B2. 
           }
         else {bx2rule[color] = 0}
        

	var tworules = inputrulestring.split("+")

	var rule1 = tworules[0];
	var rule2 = tworules[1]; // this will be "undefined" if there isn't a "+" in the rulestring.  


	var rule1slashedparts = rule1.split("/");
	var birth1;
	var survive1;
	var decaynum1;
        var birth2;
        var survive2;
        // alternating generations rules aren't implemented yet, so no "decaynum2" is needed yet.

	if (rule1slashedparts[0].match("B") != null) {
	   birth1 = rule1slashedparts[0];
           survive1 = rule1slashedparts[1];
           decaynum1 = rule1slashedparts[2];
 	  }
	 else {
           birth1 = rule1slashedparts[1];
           survive1 = rule1slashedparts[0];
    	   decaynum1 = rule1slashedparts[2];
 	  };

       

	evenbirthrule[color] =     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];   
           // for weighted life, this doesn't work - may need more than 36 spaces
	evensurvivalrule[color] =  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];  
	var newdecaynum = 0;

        birth1 = birth1.split(",");
        survive1 = survive1.split(",");



	for (var i = 0; i<birth1[0].length; i++) {
           var x = parseInt( birth1[0][i]);
  	   if (x >= 0 && x <= 9) {evenbirthrule[color][x] = 1};
	}
        
       // Then parse the rest as B,10,19,20,24
      	for (var i = 1; i<birth1.length; i++) {
           var x = parseInt( birth1[i]);
  	   if (!isNaN(x) ){evenbirthrule[color][x] = 1};
	}
        



	for (var i = 0; i<survive1[0].length; i++) {
	   var x = parseInt( survive1[0][i]);
	   if (x >= 0 && x <= 9) {evensurvivalrule[color][x] = 1};
	}

      	for (var i = 1; i<survive1.length; i++) {
           var x = parseInt( survive1[i]);
  	   if (!isNaN(x) ){evensurvivalrule[color][x] = 1};
	}
       



       if (decaynum1 == undefined) {newdecaynum = 0} else {newdecaynum = parseInt(decaynum1.replace("C", " "))};
       if (newdecaynum < 3) {newdecaynum = 0};  // the third number in generations rules must be 3 or greater.

       if (bx2rule[color] == 1) {

                rulecode[color] = 13;
                uses_dot_extra[color] = 1;

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
            }
       else if (inputrulestring.match("TRILIFE"))  {
                rulecode[color] = 14;
                uses_dot_extra[color] = 1;

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
     else if (inputrulestring.match("KITESVN"))  {
                rulecode[color] = 20;
                uses_dot_extra[color] = 1;
                 m_or_vn_weight[color] = 0;  
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
     else if (inputrulestring.match("KITE"))  {
                rulecode[color] = 20;
                uses_dot_extra[color] = 1;
                 m_or_vn_weight[color] = 1;  // this is the default, but lets be explicit

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
     else if (inputrulestring.match("FLORETSVN"))  {
                rulecode[color] = 21;
                uses_dot_extra[color] = 1;
                 m_or_vn_weight[color] = 0;  
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }

     else if (inputrulestring.match("FLORET"))  {
                rulecode[color] = 21;
                uses_dot_extra[color] = 1;
                 m_or_vn_weight[color] = 1;  // this is the default, but lets be explicit

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
     else if (inputrulestring.match("PRISM"))  {
                rulecode[color] = 17;
                uses_dot_extra[color] = 1;

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }

     else if (inputrulestring.match("BASKETWEAVEVN"))  {   // Maybe a convention like "-VN-" would cover all cases
                rulecode[color] = 18;
                uses_dot_extra[color] = 1;
                 m_or_vn_weight[color] = 0;  

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];

         }
     else if (inputrulestring.match("WEAVE") || inputrulestring.match("BASKET"))  {
                rulecode[color] = 18;
                uses_dot_extra[color] = 1;
                 m_or_vn_weight[color] = 1;  // this is the default, but lets be explicit
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }


     else if (inputrulestring.match("RHOMBUS-VN-RTWO"))  { 

                rulecode[color] = 51;
                uses_dot_extra[color] = 1;
                     m_or_vn_weight[color] = 0;  

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }

     else if (inputrulestring.match("QBERTVN") ||inputrulestring.match("RHOMBUSVN"))  { // Maybe a convention like "-VN-" would cover all cases

                rulecode[color] = 15;
                uses_dot_extra[color] = 1;
                     m_or_vn_weight[color] = 0;  

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
     else if (inputrulestring.match("QBERT") ||inputrulestring.match("RHOMBUS"))  {
                rulecode[color] = 15;
                uses_dot_extra[color] = 1;
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
     else if (inputrulestring.match("TRUNC-HEX"))  {
                rulecode[color] = 39;
                uses_dot_extra[color] = 1;
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
     else if (inputrulestring.match("KAGOME"))  {
                rulecode[color] = 40;
                uses_dot_extra[color] = 1;
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
    else if (inputrulestring.match("OCTOGON"))  {
                rulecode[color] = 41;
                uses_dot_extra[color] = 1;  
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
    else if (inputrulestring.match("RHOMBITRIHEXAGONAL-VN") || inputrulestring.match("RHOMBITRIHEXAGONALVN"))  {
                rulecode[color] = 42;
                uses_dot_extra[color] = 1;  
                 m_or_vn_weight[color] = 0;  

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
    else if (inputrulestring.match("RHOMBITRIHEXAGONAL"))  {
                rulecode[color] = 42;
                uses_dot_extra[color] = 1;  
                 m_or_vn_weight[color] = 1;  // this is the default, but lets be explicit

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
    else if (inputrulestring.match("TRUNCATED-TRIHEX"))  {
                rulecode[color] = 43;
                uses_dot_extra[color] = 1;  
                 m_or_vn_weight[color] = 1;  // this is the default, but lets be explicit

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }

    else if (inputrulestring.match("ELONGTRI"))  {
                rulecode[color] = 44;
                uses_dot_extra[color] = 1;  
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
    else if (inputrulestring.match("SNUBSQUAREVN"))  {
                rulecode[color] = 46;
                uses_dot_extra[color] = 1;  
                     m_or_vn_weight[color] = 0;  

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }

    else if (inputrulestring.match("SNUBSQUARE"))  {
                rulecode[color] = 46;
                uses_dot_extra[color] = 1;  
                 m_or_vn_weight[color] = 1;  // this is the default, but lets be explicit

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }

    else if (inputrulestring.match("SNUBHEXAGONAL"))  {
                rulecode[color] = 55;
                uses_dot_extra[color] = 1;  
                 m_or_vn_weight[color] = 1;  // this is the default, but lets be explicit

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }

    else if (inputrulestring.match("KISRHOMB"))  {
                rulecode[color] = 56;
                uses_dot_extra[color] = 1;  
                 m_or_vn_weight[color] = 1;  // this is the default, but lets be explicit

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }


    else if (inputrulestring.match("TETRAKISSQUARE"))  {
                rulecode[color] = 50;
                uses_dot_extra[color] = 1;  
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
    else if (inputrulestring.match("HEXPENT"))  {
                rulecode[color] = 48;
                uses_dot_extra[color] = 1;  
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }

   else if (inputrulestring.match("PENTA-ALTPEACE"))  {
                rulecode[color] = 57;
                uses_dot_extra[color] = 1;  
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }

   else if (inputrulestring.match("ALTPENT"))  {
                rulecode[color] = 49;
                uses_dot_extra[color] = 1;  
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
     else if (inputrulestring.match("PENTA-TYPE9-VN"))  {   // Maybe a convention like "-VN-" would cover all cases
                rulecode[color] = 52;
                uses_dot_extra[color] = 1;
                 m_or_vn_weight[color] = 0;  
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];

         }

   else if (inputrulestring.match("PENTA-TYPE9"))  {
                rulecode[color] = 52;
                uses_dot_extra[color] = 1;  
                 m_or_vn_weight[color] = 1;  

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }
   
   else if (inputrulestring.match("PENTA-TYPE-E"))  {
                rulecode[color] = 53;
                uses_dot_extra[color] = 1;  
                 m_or_vn_weight[color] = 1;  

                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }

 else if (inputrulestring.match("TETRAKISTRIANGULAR"))  {
                rulecode[color] = 54;
                uses_dot_extra[color] = 1;  
                birthrule[color] = evenbirthrule[color];
                survivalrule[color] = evensurvivalrule[color];
         }




             


                       

//  If the rule is lifelike, hex lifelike, generations, or hex generations, cover those four cases below:

       else if  (evenbirthrule[color][0] == 0 && hexhood[color] == 0 && newdecaynum == 0 && rule2 == undefined) {
                  rulecode[color] = 1; // this line is unnecessary if rulecode == 1 is the default, but it adds clarity to this code to leave it in.
                  birthrule[color] = evenbirthrule[color];
                  survivalrule[color] = evensurvivalrule[color];
         }

        else if  (evenbirthrule[color][0] == 0 && hexhood[color] == 1 && newdecaynum == 0 && rule2 == undefined) {
                  rulecode[color] = 3; 
                  birthrule[color] = evenbirthrule[color];
                  survivalrule[color] = evensurvivalrule[color];
         }
 
        else if  (evenbirthrule[color][0] == 0 && hexhood[color] == 0 && newdecaynum >= 3  && rule2 == undefined) {

                           rulecode[color] = 6;                           
                           generations_rule[color] = 1; 
                           birthrule[color] = evenbirthrule[color];
                           survivalrule[color] = evensurvivalrule[color];
                           decayrule[color] = newdecaynum;
         }

        else if  (evenbirthrule[color][0] == 0 && hexhood[color] == 1 && newdecaynum >= 3  && rule2 == undefined) {

                           rulecode[color] = 5;                           
                           generations_rule[color] = 1; 
                           birthrule[color] = evenbirthrule[color];
                           survivalrule[color] = evensurvivalrule[color];
                           decayrule[color] = newdecaynum;
         }

//  Handle the case of alternating rules of the form "B2357/S01467+B5/S2568" below:

     else if( rule2 != undefined) {
         var rule2slashedparts = rule2.split("/");
        if (rule2slashedparts[0].match("B") != null) {
	   birth2 = rule2slashedparts[0];
           survive2 = rule2slashedparts[1];
           //  Alternating Generations rules not implemented but if they were, code would be:  decaynum2 = rule2slashedparts[2];
 	  }
	 else {
           birth2 = rule2slashedparts[1];
           survive2 = rule2slashedparts[0];
           //  Alternating Generations rules not implemented but if they were, code would be:  decaynum2 = rule2slashedparts[2];
 	  };

 	oddbirthrule[color] =     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];   
           // for weighted life, this doesn't work - may need more than 36 spaces
	oddsurvivalrule[color] =  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];  
	

          birth2 = birth2.split(",");
        survive2 = survive2.split(",");



	for (var i = 0; i<birth2[0].length; i++) {
           var x = parseInt( birth2[0][i]);
  	   if (x >= 0 && x <= 9) {oddbirthrule[color][x] = 1};
	}
        
       // Then parse the rest as B,10,19,20,24
      	for (var i = 1; i<birth2.length; i++) {
           var x = parseInt( birth2[i]);
  	   if (!isNaN(x) ){oddbirthrule[color][x] = 1};
	}
        



	for (var i = 0; i<survive2[0].length; i++) {
	   var x = parseInt( survive2[0][i]);
	   if (x >= 0 && x <= 9) {oddsurvivalrule[color][x] = 1};
	}

      	for (var i = 1; i<survive2.length; i++) {
           var x = parseInt( survive2[i]);
  	   if (!isNaN(x) ){oddsurvivalrule[color][x] = 1};
	}

        //  Alternating Generations rules not implemented but if they were, code would be:
       //if (decaynum2 == undefined) {newdecaynum2 = 0} else {newdecaynum = parseInt(decaynum1.replace("C", " "))};
       //if (newdecaynum2 < 3) {newdecaynum2 = 0};  // the third number in generations rules must be 3 or greater.



        if  (hexhood[color] == 0 ) {

                           rulecode[color] = 2;                           
                           birthrule[color] = [1, 0, 0, 0, 0, 0, 0, 0, 0];
                           survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
         }

        if  (hexhood[color] == 1 ) {

                           rulecode[color] = 4;                           
                           birthrule[color] = [1, 0, 0, 0, 0, 0, 0, 0, 0];
                           survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
         }

     } // ends the if statement for rule2 != undefined


 /*

       // calculate Moore Neighborhood B0 rules
if (evenbirthrule[color][0] == 1 && hexrule_p == 0) {
   if (evensurvivalrule[color][8] != 1) {
    // calculate  Moore B0-not-S8
   }
   else {
     // calculate Moore B0-and-s8
    }
  }
 
// calculate Hexogonal Neighborhood B0 rules

if (evenbirthrule[color][0] == 1 && hexrule_p ==1) {
   if (evensurvivalrule[color][6] != 1) {
    // calculate  Hexogonal B0-not-S6
   }
   else {
     // calculate Hexongnal B0-and-s6
    }
  }


// Set decaynum only if rule is not a B0 rule.

// Set rule2 if it doesn't equal "undefined" and if it isn't a B0 rule and if decaynum = 0.

*/

return original_inputrulestring;  //  Instead of the raw inputrulestring, the function should return a "pretty" version of it derived from what was just parsed.
}  // end of the  parse_rule_string function



function r2_parse_rule_string (inputrulestring, color) {
         
         uses_dot_extra[color] = 0;   //   HEY!  Is this the right default
 
        var original_inputrulestring = inputrulestring

        inputrulestring = inputrulestring.toUpperCase();


      if (inputrulestring.match("X2")) {   // note this disallows alternating between bx2 and non-bx2.  Must test for x2 in even and odd to do that.
                  bx2rule[color] = 1; 
                  inputrulestring = inputrulestring.replace("X2","");  // it is important to remove the "X2" so that the 2 isn't parsed as the birth rule B2. 
           }
         else {bx2rule[color] = 0}

        alert(inputrulestring)
	var rule1slashedparts = inputrulestring.split("/");
        
	var birth1;
	var survive1;
	var decaynum1;
        var birth2;
        var survive2;
        // alternating generations rules aren't implemented yet, so no "decaynum2" is needed yet.

	if (rule1slashedparts[0].match("B") != null) {
	   birth1 = rule1slashedparts[0];
           survive1 = rule1slashedparts[1];
           decaynum1 = rule1slashedparts[2];
 	  }
	 else {
           birth1 = rule1slashedparts[1];
           survive1 = rule1slashedparts[0];
    	   decaynum1 = rule1slashedparts[2];
 	  };
                // Using 36 + 1 positions instead of 24 + 1, because of Radius2-Trilife's 36 neighbors
	evenbirthrule[color] =     [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];   
	evensurvivalrule[color] =  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];  
	var newdecaynum = 0;
        

        birth1 = birth1.split(",");
        survive1 = survive1.split(",");
        

        // First parse the pre-comma section as B368
	for (var i = 0; i<birth1[0].length; i++) {
           var x = parseInt( birth1[0][i]);
  	   if (x >= 0 && x <= 9) {evenbirthrule[color][x] = 1};
	}
        
       // Then parse the rest as B,10,19,20,24
      	for (var i = 1; i<birth1.length; i++) {
           var x = parseInt( birth1[i]);
  	   if (!isNaN(x) ){evenbirthrule[color][x] = 1};
	}
        



	for (var i = 0; i<survive1[0].length; i++) {
	   var x = parseInt( survive1[0][i]);
	   if (x >= 0 && x <= 9) {evensurvivalrule[color][x] = 1};
	}

      	for (var i = 1; i<survive1.length; i++) {
           var x = parseInt( survive1[i]);
  	   if (!isNaN(x) ){evensurvivalrule[color][x] = 1};
	}
        

       if (decaynum1 == undefined) {newdecaynum = 0} else {newdecaynum = parseInt(decaynum1.replace("C", " "))};
       if (newdecaynum < 3) {newdecaynum = 0};  // the third number in generations rules must be 3 or greater.

       if (bx2rule[color] == 1) {
                  if (rulecode[color] == 1 || rulecode[color] == 6 || rulecode == 22) {rulecode[color] = 22} else {rulecode[color] = 23};
                  birthrule[color] = evenbirthrule[color]; 
                  survivalrule[color] = evensurvivalrule[color];  
                  uses_dot_extra[color] = 1; 
                
         }



       else  if  (evenbirthrule[color][0] == 0 && newdecaynum == 0) {
                  if (rulecode[color] != 30) {
                     if (rulecode[color] == 1 || rulecode[color] == 6 || rulecode[color] == 22) {rulecode[color] = 1} else {rulecode[color] = 28}  // Bug: what if rulecode was 23?  Answer:  use dummy rulecode 22
                  } 
                  if (rulecode[color] == 30) {uses_dot_extra[color] = 1;}

                  birthrule[color] = evenbirthrule[color];
                  survivalrule[color] = evensurvivalrule[color];
                  decayrule[color] = 0 // probably redundant
                  generations_rule[color] = 0;
         }

    
       else if  (evenbirthrule[color][0] == 0  && newdecaynum >= 3 ) {

                          if (rulecode[color] == 1 || rulecode[color] == 6|| rulecode[color] == 22) {rulecode[color] = 6} else {rulecode[color] = 29}
                           generations_rule[color] = 1;   // these aren't redundant, but they should be made redundant, and then eliminated.
                           birthrule[color] = evenbirthrule[color];
                           survivalrule[color] = evensurvivalrule[color];
                           decayrule[color] = newdecaynum;
         }


 /*

       // calculate Range2 Neighborhood B0 rules
if (evenbirthrule[color][0] == 1 ) {
   if (evensurvivalrule[color][24] != 1) {
    // calculate  Moore B0-not-S24
   }
   else {
     // calculate Moore B0-and-s24
    }
  }
 



// Set decaynum only if rule is not a B0 rule.

// Set rule2 if it doesn't equal "undefined" and if it isn't a B0 rule and if decaynum = 0.

*/

return original_inputrulestring;  //  Instead of the raw inputrulestring, the function should return a "pretty" version of it derived from what was just parsed.
}  // end of the  r2_parse_rule_string function


//  The rules menu should be moved to either the top of the document or an external javascript file so that it can be easily modified by hand 
var rulesmenu = [ 
       ["B3/S23","Conway's Life (B3/S23)"],

       ["PromptForRule","Enter Your Own Rule"],
            ["Qbert-test", "Qbert-test"],
            ["B1/S", "B1/S"],
            ["B1/S1", "B1/S1"],
            ["Hex-B1/S", "Hex-B1/S1"],

       ["B36/S23","HighLife (B36/S23)"],
        ["B37/S23","DryLife (B37/S23)"],
       ["B3678/S34678","Day & Night (B3678/S34678)"],    
       ["B368/S245","Morley/Move ( B368/S245)"], 
       ["B36/S245","Low Morley (B36/S245)"], 
       ["B36/S125","2x2 Life (B36/S125)"], 
        ["B3678/S1258","2x2 2 (B3678/S1258)"], 
        ["B367/S1258","B367/S1258"], 
        ["B368/S12578","HotRep B368/S12578"], 
        ["B3/S24"],
        ["B3/S245"],
        ["B3/S2456"],
        ["B3/S02456"],
        ["B3/S135"],
        ["B367/S35678","B367/S35678 Quench"],
        ["B36/S2456","B36/S2456 Explodes c/93"], 
        ["B2/S","Seeds (B2/S) Explodes"], 
        ["B3/S023","DotLife (B3/S023)"], 
        ["B356/S23"],
        ["B357/S238"],  
         ["B013468/S02","B013468/S02"], 
         ["B013468/S023","B013468/S023"], 

         ["B026/S1","B026/S1"],
        ["JustFriends","Just Friends"],
        ["Hex: B36/S1245H+B25/S346H","HexRake"],
        ["Hex B2/S3","Hex B2/S3"],
       ["Hex-B2oS2m34","HexCallahan-B2oS2m34"],
 ["Experiment1","Experiment1"],
 ["B2357/S01467+B5/S2568","B2357/S01467+B5/S2568"],
 ["345/2/4","StarWars"],
 ["StarWarsC>4","StarWars C>4"],
 ["Transers","Transers"],
 ["Brian's Brain","Brian's Brain"],
  ["Wanderers","Wanderers"],
  ["SediMental","SediMental"],
   ["2356/357/4","5c/12 Bullets(2356/357/4)"],
      ["Hex Inv Y_Chromosome","Hex Inv Y_Chromosome"], 
      ["Fleas","Fleas"],
            ["Simple Inverse Fire","Simple Inverse Fire"],
            ["Hex Inverse Fire","Hex Inverse Fire"],
            ["Bricks","Bricks"],
            ["Rule110-Horizontal", "Rule110-Horizontal"],
            ["Tripod-B123x2/S13", "Tripod-B123x2/S13"],
            ["VN-B1x2/S23", "VN-B1x2/S23"],
            ["VN-B14x2/S23", "VN-B14x2/S23"],
            ["VNdiag-B1x2/S23", "VNdiag-B1x2/S23"],
            ["B1x2/S23", "B1x2/S23"],
            ["Trilife-B3/S278", "Trilife-B3/S278"],
            ["Trilife-B1/S", "Trilife-B1/S"],
            ["TriLife-B39/S278abc", "TriLife-B39/S278abc"],
            ["Qbert-B3/S24", "Qbert-B3/S24"],
            ["Rhombus-VN-Rtwo-B1/S", "Rhombus-VN-Rtwo-B1/S"],
            ["PentaPrismatic-B346/S23","PentaPrismatic-B346/S23"],

            ["PentaPrismatic-B1/S","PentaPrismatic-B1/S"],

               ["PentaPrismatic-B2/S","PentaPrismatic-B2/S"],
               ["PentaPrismatic-B34/S123","PentaPrismatic-B34/S123"],
               ["PentaBasketweave-B1/S","PentaBasketweave-B1/S"],
               ["PentaBasketweave-B2/S24","PentaBasketweave-B2/S24"],

               ["PentaBasketweave-B346/S23","PentaBasketweave-B346/S23"],
               ["Kites-B1/S","Kites-B1/S"],
               ["Kites-B2/S","Kites-B2/S"],

               ["Kites-Test","Kites-Test"],
               ["PentaFlorets-B1/S","PentaFlorets-B1/S"],
               ["PentaFlorets-B2/S","PentaFlorets-B2/S"],

               ["PentaFlorets-Test","PentaFlorets-Test"],
               ["Kagome-B1/S","Kagome-B1/S"],
               ["Kagome-B2/S","Kagome-B2/S"],
               ["Kagome-B3/S23","Kagome-B3/S23"],
               ["Trunc-Hex-B1/S","Trunc-Hex-B1/S"],
               ["Trunc-Hex-B2/S2","Trunc-Hex-B2/S2"],
               ["Trunc-Hex-B2/S346","Trunc-Hex-B2/S346"],  // Note that calling it "Trunc-Hex" raises problems for the parser.  Dodeca-Tri? (dodecagons-&-triangles)
               ["Octogon-Square-B1/S", "Octogon-Square-B1/S"],
               ["Octogon-Square-B2/S346", "Octogon-Square-B2/S346"],
               ["ElongTri-B1/S", "ElongTri-B1/S"],
               ["SnubSquare-B1/S", "SnubSquare-B1/S"],
               ["SnubSquare-B39/S23", "SnubSquare-B39/S23"],
               ["TetrakisSquare-B1/S", "TetrakisSquare-B1/S"],

               ["Rhombitrihexagonal-B1/S", "Rhombitrihexagonal-B1/S"],
               ["Rhombitrihexagonal-B2/S", "Rhombitrihexagonal-B2/S"],
               ["Rhombitrihexagonal-B3/S24", "Rhombitrihexagonal-B3/S24"],

               ["Truncated-Trihex-B1/S", "Truncated-Trihex-B1/S"],
               ["Truncated-Trihex-B2/S", "Truncated-Trihex-B2/S"],
               ["Truncated-Trihex-B2/S2", "Truncated-Trihex-B2/S2"],

               ["HEXPENT-B1/S", "HEXPENT-B1/S"],  // topologically equivalent to Hexagonal honeycomb tiling
                ["ALTPENT-B1/S", "ALTPENT-B1/S"],
                ["ALTPENT-B2/S", "ALTPENT-B2/S"],
                ["ALTPENT-B3/S23", "ALTPENT-B3/S23"],
                ["Penta-Type9-B1/S", "Penta-Type9-B1/S"],
                ["Penta-Type9-VN-B1/S", "Penta-Type9-VN-B1/S"],
                ["Penta-Type-E-B1/S", "Penta-Type-E-B1/S"],
                ["TETRAKISTRIANGULAR-B1/S", "TETRAKISTRIANGULAR-B1/S"],
                ["SnubHexagonal-B1/S", "SnubHexagonal-B1/S"],
                ["SnubHexagonal-B2/S", "SnubHexagonal-B2/S"],
                ["SnubHexagonal-B3/S23", "SnubHexagonal-B3/S23"],
                ["Kisrhomb-B1/S", "Kisrhomb-B1/S"],
                ["Kisrhomb-B2/S", "Kisrhomb-B2/S"],
                ["Kisrhomb-B3/S23", "Kisrhomb-B3/S23"],
                ["Penta-altpeace-B1/s", "Penta-altpeace-B1/s"],


  
            ["--Non Multirule Rules--"],
            ["Knightlife", "Knightlife"],
            ["Troplyium", "Troplyium"],
            ["Horned VN", "Horned VN"],
            ["12 cell ring", "12 cell ring"],
            ["testB1x2/S23V", "testB1x2/S23V"],

            ["Bugs experiment", "Bugs experiment"]
     ];

var r2_rulesmenu = [ 
       ["B4/S4","B4/S4"],
       ["PromptForRule","Enter Your Own Rule"],
            ["B1/S", "B1/S"],
            ["B1/S1", "B1/S1"],
       ["B34/S5678/C3","G's Brain(B34/S5678/C3)"],
       ["B2/S/C3","B's Brain"],
       ["B2/S/C5","B2/S/C5"],
       ["--Evan's LTL Rules--"],
       ["B67/S567","B67/S567"],

       ["--Edit me--"],

       ["B2/S/C3","B2/S/C3"],
       ["B2/S/C3","B2/S/C3"],
       ["B2/S/C3","B2/S/C3"]
];

function change_rule (color, choice) {
  // I'm not sure that the following defaults should remain, but some of them don't apply to the Range2 explorer mode because of the interaction with the weight menus
 if (range == 8) {
  hexhood [color] = 0;
  generations_rule[color] = 0;
  rulecode[color] = 1;   // this is the default unless rulecode 0 (all life or at least b3 rules) is implemented

 }
  decayrule[color] = 0;

  rulecode[background] = -1;  // fake rulecode as a default so that background doesn't trigger a rule/
  switch (choice) {
    case "PromptForRule":   choice = parse_rule_string(prompt("Enter rule:", rulename[color]), color);  // note that parse_rule_string has side effects - it sets birthrule[color], etc.
                           
                            var previousred =   document.getElementById("redrule1").selectedIndex;
                            var previousyellow = document.getElementById("yellowrule1").selectedIndex;
                            var previousgreen = document.getElementById("greenrule1").selectedIndex;
                            var previousblue = document.getElementById("bluerule1").selectedIndex;

                            rulesmenu.splice(2,0,[choice]);  // add new rule to list of rules
                            putrulesinmenus(); 
                            if (previousred > 0) {document.getElementById("redrule1").selectedIndex = previousred + 1};
                            if (previousyellow > 0) {document.getElementById("yellowrule1").selectedIndex = previousyellow + 1};
                            if (previousgreen > 0) {document.getElementById("greenrule1").selectedIndex = previousgreen + 1};
                            if (previousblue > 0) {document.getElementById("bluerule1").selectedIndex = previousblue + 1};

                        
                            
           break;
/*
    case "B3/S23":       birthrule[color] =      [0, 0, 0, 1, 0, 0, 0, 0, 0];
                         survivalrule[color] =   [0, 0, 1, 1, 0, 0, 0, 0, 0];
          break; 
    case "B36/S23":       birthrule[color] =    [0, 0, 0, 1, 0, 0, 1, 0, 0];
                           survivalrule[color] = [0, 0, 1, 1, 0, 0, 0, 0, 0];
          break; 
    case  "B3678/S34678": birthrule[color] =     [0, 0, 0, 1, 0, 0, 1, 1, 1];
                          survivalrule[color] =  [0, 0, 0, 1, 1, 0, 1, 1, 1];
          break; 
    case  "B368/S245":     birthrule[color] =    [0, 0, 0, 1, 0, 0, 1, 0, 1];
                           survivalrule[color] = [0, 0, 1, 0, 1, 1, 0, 0, 0];
          break; 

    case  "B36/S245":      birthrule[color] =    [0, 0, 0, 1, 0, 0, 1, 0, 0];
                           survivalrule[color] = [0, 0, 1, 0, 1, 1, 0, 0, 0];
          break; 

    case   "B36/S125":     birthrule[color] =    [0, 0, 0, 1, 0, 0, 1, 0, 0];
                           survivalrule[color] = [0, 1, 1, 0, 0, 1, 0, 0, 0];
          break; 

    case   "B37/S23":      birthrule[color] =    [0, 0, 0, 1, 0, 0, 0, 1, 0];
                           survivalrule[color] = [0, 0, 1, 1, 0, 0, 0, 0, 0];
          break; 


    case   "B368/S12578":     birthrule[color] =    [0, 0, 0, 1, 0, 0, 1, 0, 1];
                              survivalrule[color] = [0, 1, 1, 0, 0, 1, 0, 1, 1];
          break; 


    case   "B3/S24":       birthrule[color] =    [0, 0, 0, 1, 0, 0, 0, 0, 0];
                           survivalrule[color] = [0, 0, 1, 0, 1, 0, 0, 0, 0];
          break; 

 
    case   "B3/S245":      birthrule[color] =    [0, 0, 0, 1, 0, 0, 0, 0, 0];
                           survivalrule[color] = [0, 0, 1, 0, 1, 1, 0, 0, 0];
          break; 


    case   "B3/S2456":     birthrule[color] =    [0, 0, 0, 1, 0, 0, 0, 0, 0];
                           survivalrule[color] = [0, 0, 1, 0, 1, 1, 1, 0, 0];
          break; 

 case   "B3/S02456":       birthrule[color] =    [0, 0, 0, 1, 0, 0, 0, 0, 0];
                           survivalrule[color] = [1, 0, 1, 0, 1, 1, 1, 0, 0];
          break; 




    case   "B3/S135":      birthrule[color] =    [0, 0, 0, 1, 0, 0, 0, 0, 0];
                           survivalrule[color] = [0, 1, 0, 1, 0, 1, 0, 0, 0];
          break; 


    case   "B367/S35678":      birthrule[color] =    [0, 0, 0, 1, 0, 0, 1, 1, 0];
                               survivalrule[color] = [0, 0, 0, 1, 0, 1, 1, 1, 1];
          break; 


    case   "B36/S2456":     birthrule[color] =    [0, 0, 0, 1, 0, 0, 1, 0, 0];
                            survivalrule[color] = [0, 0, 1, 0, 1, 1, 1, 0, 0];
          break; 

    case   "B2/S":          birthrule[color] =    [0, 0, 1, 0, 0, 0, 1, 0, 0];
                            survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
          break; 


     case "B3/S023":        birthrule[color] =    [0, 0, 0, 1, 0, 0, 0, 0, 0];
                            survivalrule[color] = [1, 0, 1, 1, 0, 0, 0, 0, 0];
          break; 





    case   "B3678/S1258":      birthrule[color] =    [0, 0, 0, 1, 0, 0, 1, 1, 1];
                               survivalrule[color] = [0, 1, 1, 0, 0, 1, 0, 0, 1];
          break; 


    case   "B367/S1258":      birthrule[color] =    [0, 0, 0, 1, 0, 0, 1, 1, 0];
                              survivalrule[color] = [0, 1, 1, 0, 0, 1, 0, 0, 1];
          break; 


    case   "B356/S23":      birthrule[color] =    [0, 0, 0, 1, 0, 1, 1, 0, 0];
                            survivalrule[color] = [0, 0, 1, 1, 0, 0, 0, 0, 0];
          break; 

    case   "B357/S238":     birthrule[color] =    [0, 0, 0, 1, 0, 1, 0, 1, 0];
                            survivalrule[color] = [0, 0, 1, 1, 0, 0, 0, 0, 1];
          break; 
// B2357/S01467+B5/S2568
 case "B2357/S01467+B5/S2568":   
                            rulecode[color] = 2;
                            birthrule[color] =    [1, 0, 1, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
                            oddbirthrule[color] = [0,0,1,1,0,1,0,1,0];
                            evenbirthrule[color] = [0,0,0,0,0,1,0,0,0];
                            oddsurvivalrule[color] = [1,1,0,0,1,0,1,1,0];
                            evensurvivalrule[color] = [0,0,1,0,0,1,1,0,1];
                           break;
// hexrake rule 
// odd generations:  B25/S346
// even generations: B36/S1245
// Hex B36/S1245H+B25/S346H

 
  case "HexRake":           hexhood[color] = 1;  // this may be redundant due to rulecode[color] = 4;
                            rulecode[color] = 4;

                            birthrule[color] =    [1, 0, 0, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 1, 0, 0, 0, 0, 0, 0];
                            oddbirthrule[color] = [0,0,1,0,0,1,0,0,0];
                            evenbirthrule[color] = [0,0,0,1,0,0,1,0,0];
                            oddsurvivalrule[color] = [0,0,0,1,1,0,1,0,0];
                            evensurvivalrule[color] = [0,1,1,0,1,1,0,0,0];

            break;
   case "Hex B2/S3":          hexhood[color] = 1;
                              rulecode[color] = 3;
                               birthrule[color] =    [0, 0, 1, 0, 0, 0, 0, 0, 0];
                               survivalrule[color] = [0, 0, 0, 1, 0, 0, 0, 0, 0];
              break;



*/

// BeeZeroRule    B013468/S02 
// For odd generations:   b68/s024578
// For even generations:  b257/s1345678


    case "B013468/S02":     birthrule[color] =    [1, 1, 0, 1, 1, 0, 1, 0, 1];
                            survivalrule[color] = [1, 0, 1, 0, 0, 0, 0, 0, 0];
                            oddbirthrule[color] = [0,0,0,0,0,0,1,0,1];
                            evenbirthrule[color] = [0,0,1,0,0,1,0,1,0];
                            oddsurvivalrule[color] = [1,0,1,0,1,1,0,1,1];
                            evensurvivalrule[color] = [0,1,0,1,1,1,1,1,1];
                            rulecode[color] = 2;
            break;

//  for BeeZeroRule+S3:
//   For odd generations:   b568/s024578
//  For even generations:   b257/s145678

    case "B013468/S023":    birthrule[color] =    [1, 1, 0, 1, 1, 0, 1, 0, 1];
                            survivalrule[color] = [1, 0, 1, 1, 0, 0, 0, 0, 0];
                            oddbirthrule[color] = [0,0,0,0,0,1,1,0,1];
                            evenbirthrule[color] = [0,0,1,0,0,1,0,1,0];
                            oddsurvivalrule[color] = [1,0,1,0,1,1,0,1,1];
                            evensurvivalrule[color] = [0,1,0,0,1,1,1,1,1];
                            rulecode[color] = 2;
            break;
   case "B026/S1":          birthrule[color] =    [1, 0, 1, 0, 0, 0, 1, 0, 0];
                            survivalrule[color] = [0, 1, 0, 0, 0, 0, 0, 0, 0];
                            oddbirthrule[color] = [0,0,0,0,0,0,0,1,0];
                            evenbirthrule[color] = [0,1,0,1,1,1,0,1,1];
                            oddsurvivalrule[color] = [0,0,1,0,0,0,1,0,1];
                            evensurvivalrule[color] = [1,0,1,1,1,1,1,1,1];
                            rulecode[color] = 2;
            break;
  
  case "JustFriends":      rulecode[color] = 12;
                            birthrule[color] =    [0, 0, 1, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 1, 1, 0, 0, 0, 0, 0, 0];
            break;



    case "Hex-B2oS2m34":   hexhood[color] = 1;
                           rulecode[color] = 11;
                               birthrule[color] =    [0, 0, 1, 0, 0, 0, 0, 0, 0];
                               survivalrule[color] = [0, 0, 1, 1, 1, 0, 0, 0, 0];
 
             break;

    case "Hex Inv Y_Chromosome":  hexhood[color] = 1;
                              rulecode[color] = 5;
                              generations_rule[color] = 1; 
                              decayrule[color] = 3;
                              // Y_Chromosome  NW1,NN1,NE0,WW1, ME0,EE1,SW0,SS1,SE1,HI3,RS2,RB2 as weighted life from MCell
                              //birthrule[color] =    [0, 0, 1, 0, 0, 0, 0, 0, 0];
                              //survivalrule[color] = [0, 0, 1, 0, 0, 0, 0, 0, 0];
                             birthrule[color] =    [0, 0, 1, 0, 0, 1, 1, 0, 0];
                             survivalrule[color] = [0, 0, 1, 0, 1, 1, 1, 0, 0];

             break;

                              
 case "Experiment1":        rulecode[color] = 2;
                            birthrule[color] =    [1, 0, 1, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
                            oddbirthrule[color] = [0,0,1,0,0,0,0,0,0];
                            evenbirthrule[color] = [0,0,0,0,0,0,0,0,0];
                            oddsurvivalrule[color] = [0,0,0,0,0,0,0,0,0];
                            evensurvivalrule[color] = [0,0,1,1,1,1,1,1,1];
              break;
/*
   case "StarWars":       birthrule[color] =    [0, 0 , 1, 0, 0, 0, 0, 0, 0];
                           survivalrule[color] = [0, 0, 0, 1, 1, 1, 0, 0, 0];
                           decayrule[color] = 4;

                           rulecode[color] = 6;                           
                           generations_rule[color] = 1; 
                           break;
*/
    case "Transers":       birthrule[color] =    [0, 0 , 1, 0, 0, 0, 1, 0, 0];
                           survivalrule[color] = [0, 0, 0, 1, 1, 1, 0, 0, 0];
                           decayrule[color] = 5;

                           rulecode[color] = 6;                           

                           generations_rule[color] = 1; 
                           break;

   case "StarWarsC>4":   birthrule[color] =    [0, 0 , 1, 0, 0, 0, 0, 0, 0];
                           survivalrule[color] = [0, 0, 0, 1, 1, 1, 0, 0, 0];
                           decayrule[color] = 14;

                           rulecode[color] = 6;                           

                           generations_rule[color] = 1; 
                           break;
  case "Brian's Brain":    birthrule[color] =    [0, 0 , 1, 0, 0, 0, 0, 0, 0];
                           survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
                           decayrule[color] = 3;  

                           rulecode[color] = 6;                           

                           generations_rule[color] = 1; 
                           break;
   case "Wanderers":    birthrule[color] =    [0, 0 , 0, 1, 1, 0, 1, 1, 1];
                        survivalrule[color] = [0, 0, 0, 1, 1, 1, 0, 0, 0];
                        decayrule[color] = 5;  

               // S345/B34678/5
                           rulecode[color] = 6;                           

                           generations_rule[color] = 1; 
                           break;

   case "2356/357/4":    birthrule[color] =    [0, 0 , 0, 1, 0, 1, 0, 1, 0];
                           survivalrule[color] =  [0, 0 , 1, 1, 0, 1, 1, 0, 0];
                           decayrule[color] = 4;  

                           generations_rule[color] = 1; 
                           rulecode[color] = 6;                           

                           break;
   case "SediMental":  //45678/25678/4
                          birthrule[color] =    [0, 0 , 1, 0, 0, 1, 1, 1, 1];
                           survivalrule[color] =  [0, 0 , 0, 0, 1, 1, 1, 1, 1];
                           decayrule[color] = 4;  

                           generations_rule[color] = 1; 
                           rulecode[color] = 6;  
                           break;                         


    case "Fleas":          birthrule[color]  =    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
                           survivalrule[color] =  [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0];
                           // NW5,NN1,NE5,WW1,ME0,EE1,SW5,SS1,SE5,HI0,RS2,RS3,RS6,RS7,RS10,RS11,RS15,RS20,RB2,RB11
                           weightrule[color] =     [5, 1, 5, 1 ,1, 5, 1, 5]
                           rulecode[color] = 8;
                           break;

 
   case "Simple Inverse Fire": birthrule[color] =    [0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1];
                               survivalrule[color] = [0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1];
                               // NW5,NN1,NE5,WW1, ME0,EE1,SW5,SS1,SE5,HI0,   
                               // RS1,RS5,RS9,RS13, RS17,RS18,RS19,RS21, RS23,RS24, 
                               // RB2,RB4,RB8,RB9,RB10,RB12,RB13, RB14,RB16,RB17,RB18, RB20,RB21,RB22,RB24

                               weightrule[color] =   [5, 1, 5, 1, 1, 5, 1, 5];
                               rulecode[color] = 8;
                               break;

    case "Hex Inverse Fire":      birthrule[color] =    [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1];
                                  survivalrule[color] = [0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1];
                                  weightrule[color] =   [4, 1, 0, 1, 4, 0, 4, 1];
                                  // NW4,NN1,NE0,WW1,ME0,EE4,SW0,SS4,SE1,HI0, 
                                 //  RS2,RS3,RS6,RS7,RS8,RS9,RS11, RS12,RS13,RS14,RS15,  
                                //   RB5,RB10,RB11,RB14,RB15

                                  rulecode[color] = 10;
                                  break;

     case "Bricks":              birthrule [color] =   [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0];
                                 survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0];
                                 weightrule[color] =   [5, 2, 5, 2, 2, 5, 2, 5] ;
                                 //NW5,NN2,NE5,WW2,ME0,EE2,SW5,SS2,SE5,HI3,  RS10,RS12,RS14,RS16,  RB7,RB13
                                 generations_rule[color] = 1; 
                                  decayrule[color] = 3;
                                  rulecode[color]  = 9; 
                                  break;
        case "Rule110-Horizontal": birthrule[color] =    [0, 1, 0, 1];
                               survivalrule[color] = [1, 1, 1, 0];
                               //NW0,NN0,NE0,WW2,ME0,EE1,SW0,SS0,SE0,HI0,RS0,RS1,RS2,RB1,RB3   
                               weightrule[color] =   [0, 0, 0, 2, 1, 0, 0, 0];
                               rulecode[color] = 8;
                               break;
/* old and out of date --- candidate for deletion -------
      case "Knightlife":           rulecode[color] = 17;
                                   rulecode[background] = 17; // this should make Larger Than Life possible, 
                                                              // but it slows down everyone else.
                                   decayrule[color] = 5;
                                 break;

      case "Troplyium":           rulecode[color] = 18;
                                   rulecode[background] = 18; // this should make Larger Than Life possible, 
                                                              // but it slows down everyone else.
                                 //  decayrule[color] = 5;
                                 break;
      case "Horned VN":           rulecode[color] = 19;
                                   rulecode[background] = 19; // this should make Larger Than Life possible, 
                                                              // but it slows down everyone else.
                                   decayrule[color] = 3;
                                 break;
      case "12 cell ring":           rulecode[color] = 20;
                                   rulecode[background] = 20; // this should make Larger Than Life possible, 
                                                              // but it slows down everyone else.
                                  // decayrule[color] = 3;
                                 break;
---- end candidate for deletion    
 */                                            
 
 // NW4,NN1,NE0,WW1,ME0,EE4,SW0,SS4,SE1,
     case "Tripod-B123x2/S13":      weightrule[color] =   [0, 1, 0, 1, 0, 0, 0, 1];
                            birthrule[color] =    [0, 1, 1, 1, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 1, 0, 1, 0, 0, 0, 0, 0];
                            rulecode[color] = 13;
                            uses_dot_extra[color] = 1;
                            break;
     case "Trilife-B3/S278":     
                          
                            birthrule[color] =    [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0];
                            rulecode[color] = 14;
                            uses_dot_extra[color] = 1;
                                                 m_or_vn_weight[color] = 1;  


                            break;
     case "Trilife-B1/S":     
                            birthrule[color] =    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0];
                            rulecode[color] = 14;
                            uses_dot_extra[color] = 1;
                                                 m_or_vn_weight[color] = 1;  


                            break;
     case "TriLife-B39/S278abc":
                            birthrule[color] =    [0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0];
                            survivalrule[color] = [0, 0, 1, 0, 0, 0, 0, 1, 1,  0, 1, 1, 1];
                            rulecode[color] = 14;
                            uses_dot_extra[color] = 1;
                                                 m_or_vn_weight[color] = 1;  


                            break;

     case "Qbert-B3/S24":
                            birthrule[color] =    [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 1, 0, 1, 0, 0, 0, 0,  0, 0];
                            rulecode[color] = 15;
                            uses_dot_extra[color] = 1;
                                                 m_or_vn_weight[color] = 1;  
                            break;
     case "Qbert-test":
                            birthrule[color] =    [0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0];
                            rulecode[color] = 15;
                            uses_dot_extra[color] = 1;
                                                 m_or_vn_weight[color] = 1;  
                            break;

         case "VN-B1x2/S23": weightrule[color] =   [0, 1, 0, 1, 1, 0, 1, 0];
                            birthrule[color] =    [0, 1, 0, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 1, 1, 0, 0, 0, 0, 0];
                            rulecode[color] = 13;
                            uses_dot_extra[color] = 1;

                            break;

        case "VN-B14x2/S23": weightrule[color] =   [0, 1, 0, 1, 1, 0, 1, 0];
                            birthrule[color] =    [0, 1, 0, 0, 1, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 1, 1, 0, 0, 0, 0, 0];
                            rulecode[color] = 13;
                            uses_dot_extra[color] = 1;
                            break;


     case "VNdiag-B1x2/S23": weightrule[color] =   [1, 0, 1, 0, 0, 1, 0, 1];
                            birthrule[color] =    [0, 1, 0, 0, 1, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 1, 1, 0, 0, 0, 0, 0];
                            rulecode[color] = 13;
                            uses_dot_extra[color] = 1;
                            break;

        case "B1x2/S23":       weightrule[color] =   [1, 1, 1, 1, 1, 1, 1, 1];
                            birthrule[color] =    [0, 1, 0, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 1, 1, 0, 0, 0, 0, 0];
                            rulecode[color] = 13; 
                            uses_dot_extra[color] = 1;
                            break;





//   Pentalife-Prismatic-B346/S23

            case "PentaPrismatic-B346/S23":
                            birthrule[color] =    [0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0];
                            rulecode[color] = 17;
                            uses_dot_extra[color] = 1;
                                                 m_or_vn_weight[color] = 1;  


                            break;

           case "PentaPrismatic-B1/S":
                            birthrule[color] =    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
                            rulecode[color] = 17;
                            uses_dot_extra[color] = 1;

                                                 m_or_vn_weight[color] = 1;  

                            break;

           case "PentaPrismatic-B2/S":
                            birthrule[color] =    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
                            rulecode[color] = 17;
                            uses_dot_extra[color] = 1;
                                                 m_or_vn_weight[color] = 1;  


                            break;

            //  B3/S123 has a puffer.  B34/S123 is similar but more interesting.  
            case "PentaPrismatic-B34/S123":
                            birthrule[color] =    [0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0];
                            rulecode[color] = 17;
                            uses_dot_extra[color] = 1;
                                                 m_or_vn_weight[color] = 1;  

                            break;

      
             case "PentaBasketweave-B1/S":
                            birthrule[color] =    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
                            rulecode[color] = 18;
                            uses_dot_extra[color] = 1;
                                                 m_or_vn_weight[color] = 1;  

                            break;

             case "PentaBasketweave-B2/S24":
                            birthrule[color] =    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0];
                            rulecode[color] = 18;
                            uses_dot_extra[color] = 1;
                                                 m_or_vn_weight[color] = 1;  


                            break;
             case "PentaBasketweave-B346/S23":
                            birthrule[color] =    [0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0];
                            rulecode[color] = 18;
                            uses_dot_extra[color] = 1;
                                                 m_or_vn_weight[color] = 1;  

                            break;




               // Kites-B34/S23 has nice osc, but no ships, B34/S25 has long lived chaos, B34/S24 has promising chaos
            case "Kites-Test":
                            birthrule[color] =    [0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0];
                            rulecode[color] = 20;
                            uses_dot_extra[color] = 1;
                             m_or_vn_weight[color] = 1;  


                            break;

            // PentaFlorets-B34/S134 has promising chaos
            case "PentaFlorets-Test":
                            birthrule[color] =    [0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0];
                            rulecode[color] = 21;
                            uses_dot_extra[color] = 1;
                              m_or_vn_weight[color] = 1;  

                            break;
   /*
           case "Kagome-B1/S":
                            birthrule[color] =    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
                            rulecode[color] = 40;
                            uses_dot_extra[color] = 1;

                            break;

            case "Kagome-B2/S":
                            birthrule[color] =    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
                            rulecode[color] = 40;
                            uses_dot_extra[color] = 1;

                            break;
            case "Kagome-B3/S23":
                            birthrule[color] =    [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0];
                            survivalrule[color] = [0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0];
                            rulecode[color] = 40;
                            uses_dot_extra[color] = 1;

                            break;
  */
  
      default:                   parse_rule_string(choice, color);
 

 
   };
       rulename[color] = choice;
 
       if (decayrule[color] > 0) {decayrule[color] -= 2}; //  This means that Brian's Brain B2/S/3 has one decay state (3 - 2 = 1) 
                                                          //  and, of course, the other two states are "alive" and "background".

       if (birthrule[color][0] != 1 ) {  
    						   // rulecode[color] might be taken into account here, but note 
    						  //  there are multiple alternating codes and multiple non-alternating codes
                                        oddbirthrule[color] =   evenbirthrule[color]     = birthrule[color];
                                        oddsurvivalrule[color] = evensurvivalrule[color] = survivalrule[color];
                                      };

        //*******************************************************************************************
        // This next part is important, even if it is badly implemented.  
        // It speeds things up when there are no B0 rules currently in use.
        // the following assumes only four colors - it should be generalized by refering to a list of all available colors
       if (birthrule[red][0] || birthrule[yellow][0] || birthrule [green][0] || birthrule[blue][0])  {
              birthrule[background] = [1, 0, 0, 0, 0, 0, 0, 0, 0];   // this is for the benefit of running B0 rules with non-B0 rules, and it slows things down!!!!!  **************
              B0_rule_p = 1
       } 
       else {
             birthrule[background] = [0, 0, 0, 0, 0, 0, 0, 0, 0];   
             B0_rule_p = 0;
            } 

              
        if (magnification == 8 || magnification == 16) {set_icons (color)}
           
        nested_refresh3 ();
         generation += 1 
        oddgeneration_p = (generation % 2);

        draw_withputimagedata ()
        putpatternsinmenu();
        

      // draw();
    //draw_only_changed_from_list ();



};
   


function r2_change_rule (color, choice) {

 // hexhood [color] = 0;
//   generations_rule[color] = 0;
//   decayrule[color] = 0;

// Range2 version -- no default rulecode!
//  rulecode[color] = 1;   // this is the default unless rulecode 0 (all life or at least b3 rules) is implemented

  rulecode[background] = -1;  // fake rulecode as a default so that background doesn't trigger a rule/
  switch (choice) {
    case "PromptForRule":   choice = r2_parse_rule_string(prompt("Enter rule:", rulename[color]), color);  // note that parse_rule_string has side effects - it sets birthrule[color], etc.
                           
                            var previousred =   document.getElementById("r2_redrule1").selectedIndex;
                            var previousyellow = document.getElementById("r2_yellowrule1").selectedIndex;
                            var previousgreen = document.getElementById("r2_greenrule1").selectedIndex;
                            var previousblue = document.getElementById("r2_bluerule1").selectedIndex;

                            r2_rulesmenu.splice(2,0,[choice]);  // add new rule to list of rules
                            r2_putrulesinmenus(); 
                            if (previousred > 0) {document.getElementById("r2_redrule1").selectedIndex = previousred + 1};
                            if (previousyellow > 0) {document.getElementById("r2_yellowrule1").selectedIndex = previousyellow + 1};
                            if (previousgreen > 0) {document.getElementById("r2_greenrule1").selectedIndex = previousgreen + 1};
                            if (previousblue > 0) {document.getElementById("r2_bluerule1").selectedIndex = previousblue + 1};




                        
                            
           break;




     case "Bricks":              birthrule [color] =   [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0];
                                 survivalrule[color] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0];
                                 weightrule[color] =   [5, 2, 5, 2, 2, 5, 2, 5] ;
                                 //NW5,NN2,NE5,WW2,ME0,EE2,SW5,SS2,SE5,HI3,  RS10,RS12,RS14,RS16,  RB7,RB13
                                 generations_rule[color] = 1; 
                                  decayrule[color] = 3;
                                  rulecode[color]  = 9; 
                                  break;

      default:                   r2_parse_rule_string(choice, color);
 

 
   };
       rulename[color] = choice;
 
       if (decayrule[color] > 0) {decayrule[color] -= 2}; //  This means that Brian's Brain B2/S/3 has one decay state (3 - 2 = 1) 
                                                          //  and, of course, the other two states are "alive" and "background".

       if (birthrule[color][0] != 1 ) {  
    						   // rulecode[color] might be taken into account here, but note 
    						  //  there are multiple alternating codes and multiple non-alternating codes
                                        oddbirthrule[color] =   evenbirthrule[color]     = birthrule[color];
                                        oddsurvivalrule[color] = evensurvivalrule[color] = survivalrule[color];
                                      };

        //*******************************************************************************************
        // This next part is important, even if it is badly implemented.  
        // It speeds things up when there are no B0 rules currently in use.
        // the following assumes only four colors - it should be generalized by refering to a list of all available colors
       if (birthrule[red][0] || birthrule[yellow][0] || birthrule [green][0] || birthrule[blue][0])  {
              birthrule[background] = [1, 0, 0, 0, 0, 0, 0, 0, 0];   // this is for the benefit of running B0 rules with non-B0 rules, and it slows things down!!!!!  **************
              B0_rule_p = 1
       } 
       else {
             birthrule[background] = [0, 0, 0, 0, 0, 0, 0, 0, 0];   
             B0_rule_p = 0;
            } 
              
        if (magnification == 8 || magnification == 16) {set_icons (color)}

           
        nested_refresh3 ();
         generation += 1 
        oddgeneration_p = (generation % 2);

        draw_withputimagedata ()
        // Range2 version
        //putpatternsinmenu();

        

 

};
   








var majcolor = 0;

var temp1;
var temp2;

function twoAdjacent_JF_neighbors(cel, neighborlist) {
    getaliveneighbors (neighborlist);
  // if (alivecount !=  2) {return false} 
  //  else {
       temp1 = Math.abs(aliveneighbors[1].ypos - aliveneighbors[0].ypos) 
       temp2 = Math.abs(aliveneighbors[1].xpos - aliveneighbors[0].xpos) 
     if 
      ((aliveneighbors[1].xpos == aliveneighbors[0].xpos  && (temp1  == 1 || temp1 == memoryY - 1)) || 
       (aliveneighbors[1].ypos == aliveneighbors[0].ypos  && (temp2  == 1 || temp2 == memoryX - 1))
       ) {return true} else {return false}
   // }
};
 
     
    //  I think twoAdjacent_JF_neighbors was unnecessarily checking if alivecount != 2





function HexCalSurvive(cel) {
   cellist = cel.neighbors;
  if 
     ((cellist[0].color != background && (cellist[6].color != background || cellist[4].color  != background)) || 
      (cellist[3].color  != background && (cellist[7].color  != background || cellist[1].color  != background)) || 
      (cellist[1].color  != background && cellist[7].color  != background) ||  
      (cellist[6].color  != background && cellist[4].color  != background)) {return true} else {return false};
  
}

function HexCalnotBorn(cel) {
   cellist = cel.neighbors;
  if 
     ((cellist[3].color  != background && (cellist[6].color  != background || cellist[0].color  != background)) || 
      (cellist[1].color  != background && (cellist[4].color  != background || cellist[0].color  != background)) || 
      (cellist[7].color  != background && (cellist[6].color  != background || cellist[4].color  != background))) {return false} else {return true};
}



//  function errorcheckchangelist () {for (i = 0; i<changecount; i++) { if (changedcells[i].alivecount < 0 || changedcells[i].alivecount > 8) {return i} }}

//  Should make another one that error checks the entire arr array.

//  Regarding alivecount errors:
//  if generations/decay rules and alternating rules aren't compatible with velocity, disable velocity menus for those rules, set pencil velocities to zero, 
//  and also watch out for drivable patterns (the forward key).


// Here are some variables for Trilife and Rhombile (Qbert) and various pentalifes

var nw_neigh, n_neigh , ne_neigh, w_neigh,e_neigh,se_neigh, s_neigh, sw_neigh;

var cell_left,cell_right ,cell_top, cell_bottom, cell_middle
var nw_left, nw_right, nw_bottom, nw_top
var n_left, n_right, n_top, n_bottom
var ne_left, ne_bottom, ne_top
var e_left, e_right, e_top, e_bottom
var se_left,se_right, se_top
var s_left, s_right,  s_top
var sw_right, sw_top, sw_left
var w_left, w_right, w_top,  w_bottom


var rightcount, leftcount, topcount, bottomcount
var newcell_left, newcell_right, newcell_top , newcell_bottom

var  cell_top_left , cell_top_right ,cell_mid_left ,cell_mid_right ,cell_bot_left , cell_bot_right,  nw_bot_left , nw_bot_right , w_bot_right , w_mid_right , n_mid_left , n_bot_left , e_top_left , e_mid_left, se_top_right ,se_top_left,s_mid_right,s_top_right, newcell_top_left, newcell_top_right, newcell_mid_left, newcell_mid_right, newcell_bot_left, newcell_bot_right, newcell_middle, n_middle, ne_middle, e_middle, s_middle, sw_middle, w_middle

// Here are some variables for Radius2-Trilife:
var n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20, n21, n22, n23,
                       n0_left, n1_left, n2_left, n3_left, n4_left, n5_left, n6_left, n7_left, n8_left, n9_left, n10_left, n11_left, 
                       n12_left, n13_left, n14_left, n15_left, n16_left, n17_left, n18_left, n19_left, n20_left, n21_left, n22_left, n23_left,
                       n0_right, n1_right, n2_right, n3_right, n4_right, n5_right, n6_right, n7_right, n8_right, n9_right, n10_right, n11_right, 
                       n12_right, n13_right, n14_right, n15_right, n16_right, n17_right, n18_right, n19_right, n20_right, n21_right, n22_right, n23_right;
// Here are some variables for snub square 
var ne_square, nw_square , se_square ,sw_square ,n_square ,e_square ,s_square ,w_square 
var n_backleft, n_backright, ne_backleft, ne_backright, nw_backleft, nw_backright, e_backright, e_backleft, w_backright, w_backleft, sw_backleft, sw_backright, s_backleft, s_backright, se_backleft, se_backright


// ************* This next line is important and should be moved somewhere more stable!

var ready = 0;

// ************* 

var unweighted_len = 0;

/*
1 Lifelike
2 Alternating lifelike (including BO-not-S8) - requires testing if generation is odd or even.
3 Hex lifelike   - requires subtracting away two cellist cells.  // it currently treats decaygray like a normal color.
4 Hex Alternating                                               // it currently treats decaygray like a normal color.
5 Hex Generations (Hex with decay)
(No need for Hex Weighted because weighted easily works as hex).  --> No, wait, because of HexVelocityBirth, it may need its own rulecode.
6 Genenerations
7 Gray decay cells
(Generations Alternating not covered)
(Covered above:  Generations Hex )
8 Weighted
9 Weighted Generations (Weighted with Decay)
10 Weighted Hex
(See note above about possible need for Weighted Hex rulecodes due to HexVelocityBirth

11 Callahan // Note that the HexCalsurviave and HexCalnotborn functions don't know about decaygray - they treat decaygray  like a normal color.

12 Just Friends  // JustFriends relies on getaliveneighbors which also doesn't know about decaygray - it treates decaygray like a normal color
13 Bx2 radius 1

14 Trilife (triangular tiles, 2 states in theory, 4 states in practice)
15 Rhombus tiles
16 A .extra way to do Bx2 rules (radius 1) 
17 Prismatic Pentalife
18 Basketweave Pentalife
19 Cairo (same as basketweave but looks pentagonal)
20 Deltoidal TriHexagonal (kites, not pentagons)
21 Floret Pentagonal
22 Bx2 radius 2 unweighted (dummy flag - falls through to 23)
23 Bx2 radius 2
26  emulated radius 1 moore neighborhood.
1 and 6 will be reused with radius 2
28  Radius 2 weighted
29  Radius 2 weighted with decay
30  Radius 2 Trilife (triangular tiles)
39  Truncated_Hex (Kagome with the triangles having only 3 neighbors -- could use weighted kagome instead)
40  Kagome (radius 1)
41  Octogons and squares (Truncated square tiling) (truncated quadrille)  (octogons and squares)
42 Rhombitrihexagonal
43 Truncated Trihexagonal
44 Elongated Triangular tiling, using alternating cells
45 reserved for non-alternating elongated triangular tiling
46 Snub Square tiling, using alternating cells
47 reserved for non-alternating snub square tiling
48 Type Six-Six alternating splithex pentagons
49 Type 5-8 alternating split pentagons
50 Tetrakis Square tiling (quad triangles using alternating tiles)
51 Rhombus-VN-Radiustwo
52 Penta-Type9
53 Penta-Type14 ("Penta-type-E")
54 Tetrakis Triangular tiling (rhombus tiling with each rhombus bisected into two triangles)
55 Snub Hexagonal (19 states)
56 Kisrhombile

Also try:
--  Octogons and triangles?
--  Octogons and Squares done with triangles?


--
0  Life with no multi-rule (or only other exclusively B3 rules)
14 ruletable?

// Other codes, like one specifically for knightlife, could be used to reduce the number of weights applied


// consider using cellsinmotion (cellsinmotionr != 0) instead of physicsOn

//
*/

var celdotcolor = 0;

function algo2_rulecodes (cel, len) {   // maybe make celdotcolor a paramenter since it gets used so much
   celdotcolor = cel.color
   if (celdotcolor != background) {
      switch (rulecode[celdotcolor]) {
        case 1:   if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor} else {cel.placeholder_color = background};
                   break;

        case 2:   if (oddgeneration_p) {
                     if (oddsurvivalrule[celdotcolor][len]) { cel.placeholder_color = celdotcolor} 
                     else {cel.placeholder_color = background}
                  } 
                  else {
                     if (evensurvivalrule[celdotcolor][len]) { cel.placeholder_color = celdotcolor} 
                     else {cel.placeholder_color = background}
                  };
                  break;

        case 3:    if (cel.neighbors[2].color != background && cel.neighbors[2].color != decaygray) {len -= 1};  // what about decay??????
                   if (cel.neighbors[5].color != background && cel.neighbors[5].color != decaygray) {len -= 1};
                   if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor} else {cel.placeholder_color = background};
                   break;
         case 4:   if (cel.neighbors[2].color != background && cel.neighbors[2].color != decaygray) {len -= 1};  // what about decay??????
                   if (cel.neighbors[5].color != background && cel.neighbors[5].color != decaygray) {len -= 1};
                   if (oddgeneration_p) {
                     if (oddsurvivalrule[celdotcolor][len]) { cel.placeholder_color = celdotcolor} 
                     else {cel.placeholder_color = background}
                  } 
                  else {
                     if (evensurvivalrule[celdotcolor][len]) { cel.placeholder_color = celdotcolor} 
                     else {cel.placeholder_color = background}
                  };
                  break;
         case 5:   if (cel.neighbors[2].color != background && cel.neighbors[2].color != decaygray) {len -= 1}; 
                   if (cel.neighbors[5].color != background && cel.neighbors[5].color != decaygray) {len -= 1};
                   //if (cel.neighbors[2].color != background ) {len -= 1}; 
                   //if (cel.neighbors[5].color != background ) {len -= 1};
                     // identical to case 6 from here on out -- should fall through.
                   if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor}  
                 else {
                        cel.placeholder_color = decaygray; 
                        cel.decayval = decayrule[celdotcolor] ;
                 };
                 break;         
          case 6:  if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor}
                 else {
                        cel.placeholder_color = decaygray; 
                        cel.decayval = decayrule[celdotcolor] ;
                 };
                 break;
        case 7:    cel.decayval -= 1;
                   if (cel.decayval > ready) {cel.placeholder_color = decaygray}  else {cel.placeholder_color = background};
                   break;



        case 8:    cellist = cel.neighbors;
                   
                   len = weightrule[celdotcolor][0]*c1(cellist[0]) + weightrule[celdotcolor][1]*c1(cellist[1]) + weightrule[celdotcolor][2]*c1(cellist[2]) 
                         + weightrule[celdotcolor][3]*c1(cellist[3]) + weightrule[celdotcolor][4]*c1(cellist[4]) + weightrule[celdotcolor][5]*c1(cellist[5]) 
                         + weightrule[celdotcolor][6]*c1(cellist[6]) + weightrule[celdotcolor][7]*c1(cellist[7]) ;
                    if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor} else {cel.placeholder_color = background};
                   break;
                    
         case 9:   cellist = cel.neighbors;
                   len = weightrule[celdotcolor][0]*c1(cellist[0]) + weightrule[celdotcolor][1]*c1(cellist[1]) + weightrule[celdotcolor][2]*c1(cellist[2]) 
                         + weightrule[celdotcolor][3]*c1(cellist[3]) + weightrule[celdotcolor][4]*c1(cellist[4]) + weightrule[celdotcolor][5]*c1(cellist[5]) 
                         + weightrule[celdotcolor][6]*c1(cellist[6]) + weightrule[celdotcolor][7]*c1(cellist[7]) ;
                   if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor}
                   else {
                        cel.placeholder_color = decaygray; 
                        cel.decayval = decayrule[celdotcolor];
                   };
                   break;
       case 10:  cellist = cel.neighbors;
                       
                   len = weightrule[celdotcolor][0]*c1(cellist[0]) + weightrule[celdotcolor][1]*c1(cellist[1]) + weightrule[celdotcolor][2]*c1(cellist[2]) 
                         + weightrule[celdotcolor][3]*c1(cellist[3]) + weightrule[celdotcolor][4]*c1(cellist[4]) + weightrule[celdotcolor][5]*c1(cellist[5]) 
                         + weightrule[celdotcolor][6]*c1(cellist[6]) + weightrule[celdotcolor][7]*c1(cellist[7]) ;
                    if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor} else {cel.placeholder_color = background};
                   break;



        case 11:   if (cel.neighbors[2].color != background) {len -= 1};
                   if (cel.neighbors[5].color != background) {len -= 1};
                   //** if len == 2 was removed from the surviverule array, survival[celdotcolor][len] could be used.   and celdotcolor ought to be a var.

                   if  ((len == 2 && HexCalSurvive(cel)) || len == 3 || len == 4)  
                       { cel.placeholder_color = celdotcolor} 
                  else {cel.placeholder_color = background}
                  break;
        case 12:    if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor} else {cel.placeholder_color = background};
                      // identical to case 1.  But switches work faster when the cases are in numeric order.  So change the rulecode?
                   break;

        case 13:    cellist = cel.neighbors;
                    len = weightrule[celdotcolor][0]*bx2(cellist[0]) + weightrule[celdotcolor][1]*bx2(cellist[1]) + weightrule[celdotcolor][2]*bx2(cellist[2]) 
                          + weightrule[celdotcolor][3]*bx2(cellist[3]) + weightrule[celdotcolor][4]*bx2(cellist[4]) + weightrule[celdotcolor][5]*bx2(cellist[5]) 
                          + weightrule[celdotcolor][6]*bx2(cellist[6]) + weightrule[celdotcolor][7]*bx2(cellist[7]) ;

                     if (cel.extra ==  1) { 
                             if (birthrule[celdotcolor][len]) {
                                 cel.placeholder_color = celdotcolor; 
                                 cel.placeholder_extra = 2;
                             }
                            else {
                                cel.placeholder_color = background; 
                                cel.placeholder_extra = 0
                            }
                     }
                     else if (cel.extra == 2) {
                             if (survivalrule[celdotcolor][len]) {
                                 cel.placeholder_color = celdotcolor; 
                                 cel.placeholder_extra = 2
                                
                              } 
                            else {
                                cel.placeholder_color = background; 
                                cel.placeholder_extra = 0
                            }
                      }
                 break;
        //  scroll down for cases 14, 15, 16 (they should be moved up here so that the switch statement has cases in order
         
        case 22:
        case 23:    cellist = cel.neighbors;
                    len = weightrule[celdotcolor][0]*bx2(cellist[0]) + weightrule[celdotcolor][1]*bx2(cellist[1]) + weightrule[celdotcolor][2]*bx2(cellist[2]) 
                         + weightrule[celdotcolor][3]*bx2(cellist[3]) + weightrule[celdotcolor][4]*bx2(cellist[4]) + weightrule[celdotcolor][5]*bx2(cellist[5]) 
                         + weightrule[celdotcolor][6]*bx2(cellist[6]) + weightrule[celdotcolor][7]*bx2(cellist[7]) + weightrule[celdotcolor][8]*bx2(cellist[8]) 
                         + weightrule[celdotcolor][9]*bx2(cellist[9]) + weightrule[celdotcolor][10]*bx2(cellist[10]) + weightrule[celdotcolor][11]*bx2(cellist[11]) 
                         + weightrule[celdotcolor][12]*bx2(cellist[12]) + weightrule[celdotcolor][13]*bx2(cellist[13]) + weightrule[celdotcolor][14]*bx2(cellist[14]) 
                         + weightrule[celdotcolor][15]*bx2(cellist[15]) 
                         + weightrule[celdotcolor][16]*bx2(cellist[16]) + weightrule[celdotcolor][17]*bx2(cellist[17]) + weightrule[celdotcolor][18]*bx2(cellist[18]) 
                         + weightrule[celdotcolor][19]*bx2(cellist[19]) + weightrule[celdotcolor][20]*bx2(cellist[20]) + weightrule[celdotcolor][21]*bx2(cellist[21]) 
                         + weightrule[celdotcolor][22]*bx2(cellist[22]) + weightrule[celdotcolor][23]*bx2(cellist[23]);

                     if (cel.extra ==  1) { 
                             if (birthrule[celdotcolor][len]) {
                                 cel.placeholder_color = celdotcolor; 
                                 cel.placeholder_extra = 2;
                             }
                            else {
                                cel.placeholder_color = background; 
                                cel.placeholder_extra = 0
                            }
                     }
                     else if (cel.extra == 2) {
                             if (survivalrule[celdotcolor][len]) {
                                 cel.placeholder_color = celdotcolor; 
                                 cel.placeholder_extra = 2
                                
                              } 
                            else {
                                cel.placeholder_color = background; 
                                cel.placeholder_extra = 0
                            }
                      }
                 break;




                 break;

        case 28:    cellist = cel.neighbors;
                   
                   len = weightrule[celdotcolor][0]*c1(cellist[0]) + weightrule[celdotcolor][1]*c1(cellist[1]) + weightrule[celdotcolor][2]*c1(cellist[2]) 
                         + weightrule[celdotcolor][3]*c1(cellist[3]) + weightrule[celdotcolor][4]*c1(cellist[4]) + weightrule[celdotcolor][5]*c1(cellist[5]) 
                         + weightrule[celdotcolor][6]*c1(cellist[6]) + weightrule[celdotcolor][7]*c1(cellist[7]) + weightrule[celdotcolor][8]*c1(cellist[8]) 
                         + weightrule[celdotcolor][9]*c1(cellist[9]) + weightrule[celdotcolor][10]*c1(cellist[10]) + weightrule[celdotcolor][11]*c1(cellist[11]) 
                         + weightrule[celdotcolor][12]*c1(cellist[12]) + weightrule[celdotcolor][13]*c1(cellist[13]) + weightrule[celdotcolor][14]*c1(cellist[14]) 
                         + weightrule[celdotcolor][15]*c1(cellist[15]) 
                         + weightrule[celdotcolor][16]*c1(cellist[16]) + weightrule[celdotcolor][17]*c1(cellist[17]) + weightrule[celdotcolor][18]*c1(cellist[18]) 
                         + weightrule[celdotcolor][19]*c1(cellist[19]) + weightrule[celdotcolor][20]*c1(cellist[20]) + weightrule[celdotcolor][21]*c1(cellist[21]) 
                         + weightrule[celdotcolor][22]*c1(cellist[22]) + weightrule[celdotcolor][23]*c1(cellist[23]);

                    if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor} else {cel.placeholder_color = background};
                   break;

          //     Weighted Generations (ie weighted with decay)      
         case 29:   cellist = cel.neighbors;
                  len = weightrule[celdotcolor][0]*c1(cellist[0]) + weightrule[celdotcolor][1]*c1(cellist[1]) + weightrule[celdotcolor][2]*c1(cellist[2]) 
                         + weightrule[celdotcolor][3]*c1(cellist[3]) + weightrule[celdotcolor][4]*c1(cellist[4]) + weightrule[celdotcolor][5]*c1(cellist[5]) 
                         + weightrule[celdotcolor][6]*c1(cellist[6]) + weightrule[celdotcolor][7]*c1(cellist[7]) + weightrule[celdotcolor][8]*c1(cellist[8]) 
                         + weightrule[celdotcolor][9]*c1(cellist[9]) + weightrule[celdotcolor][10]*c1(cellist[10]) + weightrule[celdotcolor][11]*c1(cellist[11]) 
                         + weightrule[celdotcolor][12]*c1(cellist[12]) + weightrule[celdotcolor][13]*c1(cellist[13]) + weightrule[celdotcolor][14]*c1(cellist[14]) 
                         + weightrule[celdotcolor][15]*c1(cellist[15]) 
                         + weightrule[celdotcolor][16]*c1(cellist[16]) + weightrule[celdotcolor][17]*c1(cellist[17]) + weightrule[celdotcolor][18]*c1(cellist[18]) 
                         + weightrule[celdotcolor][19]*c1(cellist[19]) + weightrule[celdotcolor][20]*c1(cellist[20]) + weightrule[celdotcolor][21]*c1(cellist[21]) 
                         + weightrule[celdotcolor][22]*c1(cellist[22]) + weightrule[celdotcolor][23]*c1(cellist[23]);

                   if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor}
                   else {
                        cel.placeholder_color = decaygray; 
                        cel.decayval = decayrule[celdotcolor];
                   };
                   break;

         case 14: 
                   cellist = cel.neighbors;

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                   // codes for Trilife: in a square cell,  left triangle only = 1, right  triange only = 2, both triangles = 3

                   cell_left =  cel.extra == 1 || cel.extra == 3;
                   cell_right = cel.extra == 2 || cel.extra == 3;

                   nw_left =  nw_neigh  == 1 || nw_neigh  == 3;
                   nw_right = nw_neigh  == 2 || nw_neigh == 3;

                   n_left =  n_neigh == 1 || n_neigh == 3;
                   n_right = n_neigh  == 2 || n_neigh == 3;

                   ne_left =  ne_neigh == 1 || ne_neigh == 3;

                   e_left =  e_neigh == 1 || e_neigh == 3;
                   e_right = e_neigh  == 2 || e_neigh == 3;

                   se_left =  se_neigh == 1 || se_neigh == 3;
                   se_right = se_neigh  == 2 || se_neigh == 3;

                   s_left =  s_neigh == 1 || s_neigh == 3;
                   s_right = s_neigh  == 2 || s_neigh == 3;

                   sw_right =  sw_neigh == 2 || sw_neigh == 3; 

                   w_left =  w_neigh == 1 || w_neigh == 3;
                   w_right = w_neigh  == 2 || w_neigh == 3;

                   rightcount = cell_left + nw_left + nw_right + n_left+ n_right + ne_left + e_left + e_right + se_left + se_right + s_right + w_right
                   leftcount =  cell_right + nw_left + nw_right + n_left + e_left + se_left + se_right + s_left + s_right + sw_right + w_left + w_right

                 // If we know the entire cell is empty then this:
                 //  newcell_left = birthrule[celdotcolor][leftcount]
                 //  newcell_right = birthrule[celdotcolor][rightcount]
                   
                   if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} else {newcell_left = birthrule[celdotcolor][leftcount]}
                   if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} else {newcell_right = birthrule[celdotcolor][rightcount]}

// either way:

                   if (newcell_right == 1) {
                     if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                     else {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;}
                   }
                   else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;}
                         else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                   };
                  break;

  case 17:       // Pentagonal Prismatic Tesselation

                   cellist = cel.neighbors;

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;


                   // codes for Trilife: in a square cell,  left triangle only = 1, right  triange only = 2, both triangles = 3

                   cell_left =  cel.extra == 1 || cel.extra == 3;
                   cell_right = cel.extra == 2 || cel.extra == 3;

                   nw_left = nw_neigh  == 1 || nw_neigh == 3;
                   nw_right = nw_neigh  == 2 || nw_neigh == 3;

                   n_left =  n_neigh == 1 || n_neigh == 3;

                   e_left =  e_neigh == 1 || e_neigh == 3;

                   se_left =  se_neigh == 1 || se_neigh == 3;
                   se_right =  se_neigh == 2 || se_neigh == 3;

                   s_right = s_neigh  == 2 || s_neigh == 3;

                   w_right = w_neigh  == 2 || w_neigh == 3;

                   rightcount = cell_left + nw_left + nw_right + n_left + e_left + se_left + se_right
                   leftcount =  cell_right + s_right + se_left + se_right + w_right + nw_left + nw_right
// ************

                 // If we know the entire cell is empty then this:
                 //  newcell_left = birthrule[celdotcolor][leftcount]
                 //  newcell_right = birthrule[celdotcolor][rightcount]
                   
                   if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} else {newcell_left = birthrule[celdotcolor][leftcount]}
                   if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} else {newcell_right = birthrule[celdotcolor][rightcount]}

// either way:

                   if (newcell_right == 1) {
                     if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                     else {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;}
                   }
                   else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;}
                         else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                   };
                  break;

   case 18:    
            // Basketweave Pentalife
            // States:   left = 1, right = 2, left&right = 3, top = 4, bottom = 5, top & bottom = 6

                   cellist = cel.neighbors;

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                       // I wonder if wrap-around is a problem???!!!!  Might be a strong reason to switch to quartered hexagons!!!
                       // I wonder if simply enforcing an even number for memoryX and memoryY, regardless of the window configuration, would suffice.
                       // might only be a problem for the fill window function.
                      // tested:  sure enough, for cell size = 3 (memoryY = 213, the glider stopped at the border and didn't wrap around.


                if ((cel.xpos % 2 == 0 && cel.ypos % 2 == 0) || (cel.xpos % 2 == 1 && cel.ypos % 2 == 1)) {
                      // then cel is a left-right type of cell.

                      cell_left =  cel.extra == 1 || cel.extra == 3;

                      cell_right = cel.extra == 2 || cel.extra == 3;
                      nw_right = nw_neigh == 2 || nw_neigh == 3
                      n_bottom = n_neigh  == 5 || n_neigh == 6;
                      ne_left = ne_neigh == 1 || ne_neigh == 3;
                      e_top = e_neigh == 4  || e_neigh == 6;
                      e_bottom = e_neigh == 5  || e_neigh == 6;
                      se_left = se_neigh == 1 || se_neigh == 3;
                      s_top = s_neigh == 4 || s_neigh == 6;
                      sw_right = sw_neigh == 2 || sw_neigh == 3;
                      w_top = w_neigh == 4 || w_neigh == 6;
                      w_bottom = w_neigh == 5 || w_neigh == 6;

                      rightcount = cell_left +  n_bottom  + e_top + e_bottom + s_top  + m_or_vn_weight[celdotcolor] *(se_left +  ne_left) ;                  
                      leftcount =  cell_right + n_bottom  + w_top + w_bottom + s_top +  m_or_vn_weight[celdotcolor] *(sw_right  + nw_right) ;   

                       // If we know the entire cell is empty then this:
                       //  newcell_left = birthrule[celdotcolor][leftcount]
                       //  newcell_right = birthrule[celdotcolor][rightcount]
                   
                      if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};

                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


               }  //end section for left-right cells


                else {  // begin section for top-down cells

                       cell_top = cel.extra == 4 || cel.extra == 6;
                       cell_bottom = cel.extra == 5 || cel.extra == 6;
                       nw_bottom = nw_neigh == 5 || nw_neigh == 6;
                       n_left = n_neigh == 1 || n_neigh == 3;
                       n_right = n_neigh == 2 || n_neigh == 3;
                       ne_bottom = ne_neigh == 5 || ne_neigh == 6;
                       e_left = e_neigh == 1 || e_neigh == 3;
                       se_top = se_neigh == 4 || se_neigh == 6;
                       s_left = s_neigh == 1 || s_neigh == 3;
                       s_right = s_neigh == 2 || s_neigh == 3;
                       sw_top = sw_neigh == 4 || sw_neigh == 6;
                       w_right = w_neigh == 2 || w_neigh == 3;

                       topcount = cell_bottom + n_left + n_right + e_left + w_right + m_or_vn_weight[celdotcolor] * (ne_bottom  + nw_bottom) ;   
                       bottomcount = cell_top + e_left + w_right  + s_left + s_right +  m_or_vn_weight[celdotcolor] * (se_top + sw_top);

                    // If we know the entire cell is empty then this:
                       //  newcell_top = birthrule[celdotcolor][topcount]
                       //  newcell_bottom = birthrule[celdotcolor][bottomcount]
                   
                      if (cell_top == 1) {newcell_top = survivalrule[celdotcolor][topcount]} 
                               else {newcell_top = birthrule[celdotcolor][topcount]};
                      if (cell_bottom == 1) {newcell_bottom = survivalrule[celdotcolor][bottomcount]} 
                              else {newcell_bottom = birthrule[celdotcolor][bottomcount]};

                      // either way:

                      if (newcell_bottom == 1) {
                        if (newcell_top == 1) {cel.placeholder_extra = 6; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_top == 1) {cel.placeholder_extra = 4; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                      };
                } // end section for top-bottom cells

             break;

         case 20:  // Deltoidal TriHexagonal (Kites) (Radius 1)
                  
                   // binary code for the six cellular subdivisions in the hexagon
                   // 000001 = top_left, 000010 = top_right, 000100 = mid_left, 001000 = mid_right, 010000 = bot_left, 100000 = bot_right
                  // So, for example, bot_right and top_left would be 100001


                   cellist = cel.neighbors;


                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   // ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   // sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;



                   celdotextra = cel.extra
                   cell_top_left = celdotextra & 1
                   cell_top_right = (celdotextra >> 1) & 1
                   cell_mid_left = (celdotextra >> 2) & 1
                   cell_mid_right = (celdotextra >> 3) & 1
                   cell_bot_left = (celdotextra >> 4) & 1
                   cell_bot_right = (celdotextra >> 5) & 1

                   nw_bot_left = (nw_neigh >> 4) & 1
                   nw_bot_right = (nw_neigh >> 5) & 1
                   w_bot_right  = (w_neigh >> 5) & 1
                   w_mid_right = (w_neigh >> 3) & 1  
                   n_mid_left = (n_neigh >> 2) & 1
                   n_bot_left = (n_neigh >> 4) & 1
                   e_top_left = e_neigh & 1
                   e_mid_left = (e_neigh >> 2) & 1
                   se_top_right  = (se_neigh >> 1) & 1
                   se_top_left  = se_neigh & 1
                   s_mid_right  = (s_neigh >> 3) & 1
                   s_top_right = (s_neigh >> 1) & 1

    

                  top_leftcount = cell_top_right + cell_mid_left + w_mid_right + nw_bot_left 
                                  + m_or_vn_weight[celdotcolor] *(nw_bot_right + cell_mid_right + cell_bot_left + cell_bot_right +  w_bot_right) 



                  top_rightcount = cell_top_left + cell_mid_right + n_mid_left + nw_bot_right
                                  + m_or_vn_weight[celdotcolor] *(nw_bot_left   + n_bot_left + cell_bot_right + cell_bot_left + cell_mid_left) 

                  mid_rightcount = cell_top_right + cell_bot_right + n_bot_left + e_top_left
                                  + m_or_vn_weight[celdotcolor] *(n_mid_left  + e_mid_left  + cell_bot_left + cell_mid_left + cell_top_left)


                  bot_rightcount = cell_mid_right + cell_bot_left + e_mid_left + se_top_right
                                  + m_or_vn_weight[celdotcolor] *( e_top_left  + se_top_left +  + cell_mid_left + cell_top_left + cell_top_right)



                  bot_leftcount =  cell_mid_left + cell_bot_right + s_mid_right + se_top_left
                                  + m_or_vn_weight[celdotcolor] *(  se_top_right + s_top_right  + cell_top_right + cell_top_left + cell_mid_right)



                  mid_leftcount =  cell_top_left + cell_bot_left + s_top_right + w_bot_right
                                  + m_or_vn_weight[celdotcolor] *(  cell_top_right + cell_mid_right + cell_bot_right  + s_mid_right  + w_mid_right)




/*  Non VN version

                   top_leftcount  = nw_bot_left + nw_bot_right + cell_top_right + cell_mid_right + cell_bot_left + cell_bot_right + cell_mid_left + w_bot_right + w_mid_right

                   top_rightcount = nw_bot_left + nw_bot_right + n_mid_left + n_bot_left + cell_mid_right + cell_bot_right + cell_bot_left + cell_mid_left + cell_top_left

                   mid_rightcount = n_mid_left + n_bot_left + e_top_left + e_mid_left + cell_bot_right + cell_bot_left + cell_mid_left + cell_top_left + cell_top_right

                   bot_rightcount = cell_mid_right + e_top_left + e_mid_left + se_top_right + se_top_left + cell_bot_left + cell_mid_left + cell_top_left + cell_top_right 

                   bot_leftcount = cell_bot_right  + se_top_left + se_top_right + s_mid_right + s_top_right + cell_mid_left + cell_top_right + cell_top_left + cell_mid_right 

                   mid_leftcount = cell_top_left + cell_top_right + cell_mid_right + cell_bot_right + cell_bot_left + s_mid_right + s_top_right + w_bot_right + w_mid_right
*/

                      if (cell_top_left == 1) {newcell_top_left = survivalrule[celdotcolor][top_leftcount]} 
                               else {newcell_top_left = birthrule[celdotcolor][top_leftcount]};

                     if (cell_top_right == 1) {newcell_top_right = survivalrule[celdotcolor][top_rightcount]} 
                               else {newcell_top_right = birthrule[celdotcolor][top_rightcount]};

                     if (cell_mid_left == 1) {newcell_mid_left = survivalrule[celdotcolor][mid_leftcount]} 
                               else {newcell_mid_left = birthrule[celdotcolor][mid_leftcount]};

                     if (cell_mid_right == 1) {newcell_mid_right = survivalrule[celdotcolor][mid_rightcount]} 
                               else {newcell_mid_right = birthrule[celdotcolor][mid_rightcount]};

                     if (cell_bot_left == 1) {newcell_bot_left = survivalrule[celdotcolor][bot_leftcount]} 
                               else {newcell_bot_left = birthrule[celdotcolor][bot_leftcount]};

                     if (cell_bot_right == 1) {newcell_bot_right = survivalrule[celdotcolor][bot_rightcount]} 
                               else {newcell_bot_right = birthrule[celdotcolor][bot_rightcount]};






                      cel.placeholder_extra = newcell_top_left + (newcell_top_right << 1) + (newcell_mid_left << 2) + (newcell_mid_right << 3) + (newcell_bot_left << 4) + (newcell_bot_right << 5)
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = celdotcolor} 
                      else {cel.placeholder_color = background}
                  break;


         case 21:  // Floret Pentagonal (Radius 1)
                  
                   // binary code for the six cellular subdivisions in the hexagon
                   // 000001 = top_left, 000010 = top_right, 000100 = mid_left, 001000 = mid_right, 010000 = bot_left, 100000 = bot_right
                  // So, for example, bot_right and top_left would be 100001


                   cellist = cel.neighbors;


                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   // ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   // sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;



                   celdotextra = cel.extra
                   cell_top_left = celdotextra & 1
                   cell_top_right = (celdotextra >> 1) & 1
                   cell_mid_left = (celdotextra >> 2) & 1
                   cell_mid_right = (celdotextra >> 3) & 1
                   cell_bot_left = (celdotextra >> 4) & 1
                   cell_bot_right = (celdotextra >> 5) & 1

                   nw_bot_left = (nw_neigh >> 4) & 1
                   nw_bot_right = (nw_neigh >> 5) & 1
                   w_bot_right  = (w_neigh >> 5) & 1
                   w_mid_right = (w_neigh >> 3) & 1  
                   n_mid_left = (n_neigh >> 2) & 1
                   n_bot_left = (n_neigh >> 4) & 1
                   e_top_left = e_neigh & 1
                   e_mid_left = (e_neigh >> 2) & 1
                   se_top_right  = (se_neigh >> 1) & 1
                   se_top_left  = se_neigh & 1
                   s_mid_right  = (s_neigh >> 3) & 1
                   s_top_right = (s_neigh >> 1) & 1
/*

Original Non-VN version:


                   top_leftcount  = nw_bot_left + nw_bot_right + cell_top_right + cell_mid_right + cell_bot_left + cell_bot_right + cell_mid_left + w_mid_right // no + w_bot_right 
                   top_rightcount = nw_bot_right + n_mid_left + n_bot_left + cell_mid_right + cell_bot_right + cell_bot_left + cell_mid_left + cell_top_left // no  nw_bot_left 
                   mid_rightcount = n_bot_left + e_top_left + e_mid_left + cell_bot_right + cell_bot_left + cell_mid_left + cell_top_left + cell_top_right // no n_mid_left + 
                   bot_rightcount = cell_mid_right + e_mid_left + se_top_right + se_top_left + cell_bot_left + cell_mid_left + cell_top_left + cell_top_right // no  + e_top_left
                   bot_leftcount = cell_bot_right  + se_top_left + s_mid_right + s_top_right + cell_mid_left + cell_top_right + cell_top_left + cell_mid_right // no   se_top_right
                   mid_leftcount = cell_top_left + cell_top_right + cell_mid_right + cell_bot_right + cell_bot_left  + s_top_right + w_bot_right + w_mid_right  // no  + s_mid_right


*/

                   top_leftcount  = nw_bot_left + nw_bot_right + cell_top_right + cell_mid_left + w_mid_right + m_or_vn_weight[celdotcolor] *( cell_bot_left + cell_bot_right + cell_mid_right)
                   top_rightcount = nw_bot_right + n_mid_left + n_bot_left + cell_mid_right  + cell_top_left  + m_or_vn_weight[celdotcolor] *(  cell_bot_right + cell_bot_left + cell_mid_left)
                   mid_rightcount = n_bot_left + e_top_left + e_mid_left + cell_bot_right  + cell_top_right + m_or_vn_weight[celdotcolor] *(cell_bot_left + cell_mid_left + cell_top_left)
                   bot_rightcount = cell_mid_right + e_mid_left + se_top_right + se_top_left + cell_bot_left + m_or_vn_weight[celdotcolor] *( cell_mid_left + cell_top_left + cell_top_right)
                   bot_leftcount = cell_bot_right  + se_top_left + s_mid_right + s_top_right + cell_mid_left  + m_or_vn_weight[celdotcolor] *(cell_top_right + cell_top_left + cell_mid_right)
                   mid_leftcount = cell_top_left + cell_bot_left  + s_top_right + w_bot_right + w_mid_right  + m_or_vn_weight[celdotcolor] *( cell_top_right + cell_mid_right + cell_bot_right)


                      if (cell_top_left == 1) {newcell_top_left = survivalrule[celdotcolor][top_leftcount]} 
                               else {newcell_top_left = birthrule[celdotcolor][top_leftcount]};

                     if (cell_top_right == 1) {newcell_top_right = survivalrule[celdotcolor][top_rightcount]} 
                               else {newcell_top_right = birthrule[celdotcolor][top_rightcount]};

                     if (cell_mid_left == 1) {newcell_mid_left = survivalrule[celdotcolor][mid_leftcount]} 
                               else {newcell_mid_left = birthrule[celdotcolor][mid_leftcount]};

                     if (cell_mid_right == 1) {newcell_mid_right = survivalrule[celdotcolor][mid_rightcount]} 
                               else {newcell_mid_right = birthrule[celdotcolor][mid_rightcount]};

                     if (cell_bot_left == 1) {newcell_bot_left = survivalrule[celdotcolor][bot_leftcount]} 
                               else {newcell_bot_left = birthrule[celdotcolor][bot_leftcount]};

                     if (cell_bot_right == 1) {newcell_bot_right = survivalrule[celdotcolor][bot_rightcount]} 
                               else {newcell_bot_right = birthrule[celdotcolor][bot_rightcount]};






                      cel.placeholder_extra = newcell_top_left + (newcell_top_right << 1) + (newcell_mid_left << 2) + (newcell_mid_right << 3) + (newcell_bot_left << 4) + (newcell_bot_right << 5)
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = celdotcolor} 
                      else {cel.placeholder_color = background}
                  break;

         case 39: // Truncated Hex - This is just like Kagome except that triangles have only three neighobrs!
                  // 8 states, background + 7 non-zero .extra values 
                 // top_left = 001 bot_right = 010 middle = 100  topleft&botright = 011 mid&topleft = 101 mid&botright = 110 midtopbot = 111  
                // top_left = 1   bot_right = 2   middlle = 4   top&bot = 3 mid&topleft = 5 mid&botright = 6 midtopbot = 7 

                      cellist = cel.neighbors;
                      nw_neigh = cellist[0].extra;
                      n_neigh = cellist[1].extra;
                      ne_neigh = cellist[2].extra;
                      w_neigh = cellist[3].extra;
                      e_neigh = cellist[4].extra;
                      sw_neigh = cellist[5].extra;
                      s_neigh = cellist[6].extra;
                      se_neigh = cellist[7].extra;
                      celdotextra = cel.extra

                      cell_top_left  = celdotextra & 1
                      cell_bot_right = (celdotextra >> 1) & 1
                      cell_middle = (celdotextra >> 2) & 1


                      n_middle = (n_neigh >> 2) & 1
                      ne_middle = (ne_neigh >> 2) & 1
                      e_middle = (e_neigh >> 2) & 1
                      s_middle = (s_neigh >> 2) & 1
                      sw_middle  = (sw_neigh >> 2) & 1
                      w_middle = (w_neigh >> 2) & 1

                      n_bot_right = (n_neigh >> 1) & 1
                      nw_bot_right = (nw_neigh >> 1) & 1
                      w_bot_right = (w_neigh >> 1) & 1

                      s_top_left = s_neigh  & 1
                      se_top_left = se_neigh & 1
                      e_top_left = e_neigh & 1



                      top_leftcount = n_middle + cell_middle + w_middle // (the hex neighbors)
                                      // commented out for Truncated Hex instaad of Kagome + nw_bot_right + n_bot_right +w_bot_right // (the tri neighbors)
                
                      middle_count = n_middle + ne_middle + e_middle + s_middle + sw_middle + w_middle // (the hex neighbors)
                                   + n_bot_right + e_top_left + cell_bot_right + s_top_left + w_bot_right + cell_top_left // (the tri neighbors)

                      bot_rightcount = cell_middle + e_middle + s_middle // (the hex neighbors)
                                      // commented out for Truncated Hex instaad of Kagome  + e_top_left + se_top_left + s_top_left // (the tri neighbors)


                      if (cell_top_left == 1) {newcell_top_left = survivalrule[celdotcolor][top_leftcount]} 
                               else {newcell_top_left = birthrule[celdotcolor][top_leftcount]};

                     if (cell_bot_right == 1) {newcell_bot_right = survivalrule[celdotcolor][bot_rightcount]} 
                               else {newcell_bot_right = birthrule[celdotcolor][bot_rightcount]};

                     if (cell_middle == 1) {newcell_middle = survivalrule[celdotcolor][middle_count]} 
                               else {newcell_middle = birthrule[celdotcolor][middle_count]};


                      cel.placeholder_extra = newcell_top_left + (newcell_bot_right << 1) + (newcell_middle << 2)                           
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = celdotcolor} 
                      else {cel.placeholder_color = background}
                  break;     

         case 40: // Kagome Lattice (Hexagons and Triangles)
                  // 8 states, background + 7 non-zero .extra values 
                 // top_left = 001 bot_right = 010 middle = 100  topleft&botright = 011 mid&topleft = 101 mid&botright = 110 midtopbot = 111  
                // top_left = 1   bot_right = 2   middlle = 4   top&bot = 3 mid&topleft = 5 mid&botright = 6 midtopbot = 7 

                      cellist = cel.neighbors;
                      nw_neigh = cellist[0].extra;
                      n_neigh = cellist[1].extra;
                      ne_neigh = cellist[2].extra;
                      w_neigh = cellist[3].extra;
                      e_neigh = cellist[4].extra;
                      sw_neigh = cellist[5].extra;
                      s_neigh = cellist[6].extra;
                      se_neigh = cellist[7].extra;
                      celdotextra = cel.extra

                      cell_top_left  = celdotextra & 1
                      cell_bot_right = (celdotextra >> 1) & 1
                      cell_middle = (celdotextra >> 2) & 1


                      n_middle = (n_neigh >> 2) & 1
                      ne_middle = (ne_neigh >> 2) & 1
                      e_middle = (e_neigh >> 2) & 1
                      s_middle = (s_neigh >> 2) & 1
                      sw_middle  = (sw_neigh >> 2) & 1
                      w_middle = (w_neigh >> 2) & 1

                      n_bot_right = (n_neigh >> 1) & 1
                      nw_bot_right = (nw_neigh >> 1) & 1
                      w_bot_right = (w_neigh >> 1) & 1

                      s_top_left = s_neigh  & 1
                      se_top_left = se_neigh & 1
                      e_top_left = e_neigh & 1



                      top_leftcount = n_middle + cell_middle + w_middle // (the hex neighbors)
                                     + nw_bot_right + n_bot_right +w_bot_right // (the tri neighbors)
                
                      middle_count = n_middle + ne_middle + e_middle + s_middle + sw_middle + w_middle // (the hex neighbors)
                                   + n_bot_right + e_top_left + cell_bot_right + s_top_left + w_bot_right + cell_top_left // (the tri neighbors)

                      bot_rightcount = cell_middle + e_middle + s_middle // (the hex neighbors)
                                       + e_top_left + se_top_left + s_top_left // (the tri neighbors)


                      if (cell_top_left == 1) {newcell_top_left = survivalrule[celdotcolor][top_leftcount]} 
                               else {newcell_top_left = birthrule[celdotcolor][top_leftcount]};

                     if (cell_bot_right == 1) {newcell_bot_right = survivalrule[celdotcolor][bot_rightcount]} 
                               else {newcell_bot_right = birthrule[celdotcolor][bot_rightcount]};

                     if (cell_middle == 1) {newcell_middle = survivalrule[celdotcolor][middle_count]} 
                               else {newcell_middle = birthrule[celdotcolor][middle_count]};


                      cel.placeholder_extra = newcell_top_left + (newcell_bot_right << 1) + (newcell_middle << 2)                           
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = celdotcolor} 
                      else {cel.placeholder_color = background}
                  break;

       case 41:    // Squares and Octogons (a mix of VN and Moore)
         if ((cel.xpos % 2 == 0 && cel.ypos % 2 == 0) || (cel.xpos % 2 == 1 && cel.ypos % 2 == 1)) {
                   if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                        cel.placeholder_extra = 1
                   }  
                   else {cel.placeholder_color = background;
                         cel.placeholder_extra = 0
                   };
             }
             else {
                     cellist = cel.neighbors;
                   
                   len = c1(cellist[1]) + c1(cellist[3]) +  c1(cellist[4]) + c1(cellist[6])  // North, East, West, South respectively
                  if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor;
                                                       cel.placeholder_extra = 2
                  } 
                  else {cel.placeholder_color = background; 
                        cel.placeholder_extra = 0                       };
              }
              break;


case 42:  // Rombitrihexagonal Tiling  -- survival case

                  cellist = cel.neighbors;
                  celdotextra = cel.extra
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

 

   // 9 states:
   // 0 000 = background
   // 1 001 = upward_right
   // 2 010 = upward__left
   // 3 011 = upward_split_both
   // 4 100 = Dodecagon
   // 5 101 = downward_right
   // 6 110 = downward_left
   // 7 111 = downward_split_both
   // 8 1000 = middle square     

   // middle squares
   if ((cel.ypos % 4 == 0 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 2 && cel.xpos % 2 == 1))  {
      n_right = n_neigh == 5 || n_neigh == 7
      n_left = n_neigh == 6 || n_neigh == 7
      ne_left = ne_neigh == 2 || ne_neigh == 3
      se_left = se_neigh == 6 || se_neigh == 7
      s_right = s_neigh == 1 || s_neigh == 3
      s_left = s_neigh == 2 || s_neigh == 3
      
      mycount = n_right  + (e_neigh == 4) + (w_neigh == 4)  + s_right + m_or_vn_weight[celdotcolor] * (n_left + ne_left + se_left + s_left)
               
                  if (survivalrule[celdotcolor][mycount]) {cel.placeholder_color = celdotcolor; cel.placeholder_extra = 8} 
                  else {cel.placeholder_color = background; cel.placeholder_extra = 0};
   }

   // Hexagons
   else if ((cel.ypos % 4 == 2 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 0 && cel.xpos % 2 == 1))  {
     n_left = n_neigh == 2 || n_neigh == 3
     n_right = n_neigh == 1 || n_neigh == 3
     ne_left = ne_neigh == 6 || ne_neigh == 7
     ne_right = ne_neigh == 5 || ne_neigh == 7
     se_left = se_neigh == 2 || se_neigh == 3
     se_right = se_neigh == 1 || se_neigh == 3
     s_right = s_neigh == 5 || s_neigh == 7
     s_left = s_neigh == 6 || s_neigh == 7
     sw_right = sw_neigh == 1 || sw_neigh == 3
     nw_right = nw_neigh == 5 || nw_neigh == 7


     
      mycount = n_left + n_right + ne_left + ne_right + (e_neigh == 8) + se_left + se_right + s_right + s_left  + sw_right  + (w_neigh == 8) + nw_right

                      
                  if (survivalrule[celdotcolor][mycount]) {cel.placeholder_color = celdotcolor; cel.placeholder_extra = 4} 
                  else {cel.placeholder_color = background; cel.placeholder_extra = 0};

      } // end section for Dodecagons

   // Upwards left-right cell
   else if ((cel.ypos % 4 == 1 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 3 && cel.xpos % 2 == 1))  {

      cell_left = celdotextra == 2 || celdotextra == 3
      cell_right = celdotextra == 1 || celdotextra == 3
      e_left = e_neigh == 6 || e_neigh == 7
      w_right = w_neigh == 5 || w_neigh == 7
      w_left = w_neigh == 6 || w_neigh == 7
      
      rightcount =  (n_neigh == 8) + cell_left + e_left + m_or_vn_weight[celdotcolor] *((nw_neigh == 4) + (ne_neigh == 4)  + (s_neigh == 4))  // triangle
      leftcount =  (nw_neigh == 4) + cell_right  + (s_neigh == 4)  + w_right  + m_or_vn_weight[celdotcolor] *((n_neigh == 8) + (sw_neigh == 8) + e_left + w_left ) // Square
    

          // Apply Birth and Survive rules to each side of the cell
                   
 
                   
                      if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};


                    // Now return the final cell value for left-right cells


                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


                } // end section for upwards left-right cells



   // Downwards left-right cell
   if ((cel.ypos % 4 == 3 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 1 && cel.xpos % 2 == 1))  {

 
      cell_left = celdotextra == 6 || celdotextra == 7
      cell_right = celdotextra == 5 || celdotextra == 7
      e_left = e_neigh == 2 || e_neigh == 3
      w_right = w_neigh == 1 || w_neigh == 3
      w_left = w_neigh == 2 || w_neigh == 3
      
      rightcount =   e_left + (s_neigh == 8) + cell_left + m_or_vn_weight[celdotcolor] *( (sw_neigh == 4) + (n_neigh == 4)  + (se_neigh == 4) )


// Triangle
      leftcount =    (n_neigh == 4)  + cell_right  + (sw_neigh == 4) +  w_right + m_or_vn_weight[celdotcolor] *( w_left  + e_left + (nw_neigh == 8) + (s_neigh == 8) ) // Square
  

         //Apply Birth and Survive rules to each side of the cell
                   
 
                   
                      if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};


                     // Now return the final cell value for left-right cells


                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 7; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 6; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


                } // end section for downwards left-rightcells

            break;









case 43:  // Truncated Trihexagonal Tiling  -- survival case

                  cellist = cel.neighbors;

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

 

   // 9 states:
   // 0 000 = background
   // 1 001 = upward_right
   // 2 010 = upward__left
   // 3 011 = upward_split_both
   // 4 100 = Dodecagon
   // 5 101 = downward_right
   // 6 110 = downward_left
   // 7 111 = downward_split_both
   // 8 1000 = middle square     

   // middle squares
   if ((cel.ypos % 4 == 0 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 2 && cel.xpos % 2 == 1))  {
      n_right = n_neigh == 5 || n_neigh == 7
      s_right = s_neigh == 1 || s_neigh == 3
      mycount = n_right  + (e_neigh == 4) + (w_neigh == 4)  + s_right                     
                  if (survivalrule[celdotcolor][mycount]) {cel.placeholder_color = celdotcolor; cel.placeholder_extra = 8} 
                  else {cel.placeholder_color = background; cel.placeholder_extra = 0};
   }

   // Dodecagons
   else if ((cel.ypos % 4 == 2 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 0 && cel.xpos % 2 == 1))  {
     n_left = n_neigh == 2 || n_neigh == 3
     n_right = n_neigh == 1 || n_neigh == 3
     ne_left = ne_neigh == 6 || ne_neigh == 7
     ne_right = ne_neigh == 5 || ne_neigh == 7
     se_left = se_neigh == 2 || se_neigh == 3
     se_right = se_neigh == 1 || se_neigh == 3
     s_right = s_neigh == 5 || s_neigh == 7
     s_left = s_neigh == 6 || s_neigh == 7
     sw_right = sw_neigh == 1 || sw_neigh == 3
     nw_right = nw_neigh == 5 || nw_neigh == 7


     //mycount = (n_neigh in [2, 3]) + (n_neigh in [1, 3]) + (ne_neigh in [6, 7]) + (ne_neigh in [5,7]) + (e_neigh == 8) + (se_neigh in [2,3]) 
      //         + (se_neigh in [1,3]) + (s_neigh in [5,7]) + (s_neigh in [6,7])  + (sw_neigh in [1,3]) + (w_neigh == 8) + (nw_neigh in [5,7])
      mycount = n_left + n_right + ne_left + ne_right + (e_neigh == 8) + se_left + se_right + s_right + s_left  + sw_right  + (w_neigh == 8) + nw_right

                      
                  if (survivalrule[celdotcolor][mycount]) {cel.placeholder_color = celdotcolor; cel.placeholder_extra = 4} 
                  else {cel.placeholder_color = background; cel.placeholder_extra = 0};

      } // end section for Dodecagons

   // Upwards left-right cell
   else if ((cel.ypos % 4 == 1 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 3 && cel.xpos % 2 == 1))  {

      cell_left = cel.extra == 2 || cel.extra == 3
      cell_right = cel.extra == 1 || cel.extra == 3
      e_left = e_neigh == 6 || e_neigh== 7
      w_right = w_neigh == 5 || w_neigh == 7
      
      rightcount = (nw_neigh == 4) + (n_neigh == 8) + (ne_neigh == 4) + cell_left + e_left + (s_neigh == 4) // Hexagon
      leftcount =  (nw_neigh == 4) + cell_right  + (s_neigh == 4)  + w_right  // Square

          // Apply Birth and Survive rules to each side of the cell
                   
 
                   
                      if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};


                    // Now return the final cell value for left-right cells


                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


                } // end section for upwards left-right cells



   // Downwards left-right cell
   if ((cel.ypos % 4 == 3 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 1 && cel.xpos % 2 == 1))  {

      cell_left = cel.extra == 6 || cel.extra == 7
      cell_right = cel.extra == 5 || cel.extra == 7
      e_left = e_neigh == 2 || e_neigh == 3
      w_right = w_neigh == 1 || w_neigh == 3
      
      rightcount =  (n_neigh == 4) +  e_left  + (se_neigh == 4) + (s_neigh == 8) + (sw_neigh == 4) + cell_left // Hexagon
      leftcount =    (n_neigh == 4)  + cell_right  + (sw_neigh == 4) +  w_right   // Square


         //Apply Birth and Survive rules to each side of the cell
                   
 
                   
                      if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};


                     // Now return the final cell value for left-right cells


                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 7; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 6; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


                } // end section for downwards left-rightcells

            break;







        case 44: //  Elongated Triangular  (using alternating square method)
                // States: in a square cell,  left triangle only = 1, right  triange only = 2, both triangles = 3, full square = 4

                   cellist = cel.neighbors;

               if (cel.ypos % 2 == 0) {  // if it is an even row
                   cell_left =  cel.extra == 1 || cel.extra == 3;
                   cell_right = cel.extra == 2 || cel.extra == 3;
 
                   nw_neigh = cellist[0].extra == 4
                   n_neigh = cellist[1].extra == 4
                   ne_neigh = cellist[2].extra == 4

                   w_neigh = cellist[3].extra;
                   w_left =  w_neigh == 1 || w_neigh == 3;
                   w_right = w_neigh  == 2 || w_neigh == 3;
                   
                   e_neigh = cellist[4].extra;
                   e_left =  e_neigh == 1 || e_neigh == 3;
                   e_right = e_neigh  == 2 || e_neigh == 3;

                   
                   sw_neigh = cellist[5].extra == 4
                   s_neigh = cellist[6].extra == 4
                   se_neigh = cellist[7].extra == 4

                    rightcount = cell_left  + e_left + n_neigh + nw_neigh + ne_neigh + e_right + s_neigh + se_neigh + w_right  // first three are VN
                    leftcount =  cell_right + w_right + s_neigh + sw_neigh  + se_neigh + w_left  + nw_neigh + n_neigh + e_left // first three are VN

                   if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} else {newcell_left = birthrule[celdotcolor][leftcount]}
                   if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} else {newcell_right = birthrule[celdotcolor][rightcount]}

                   if (newcell_right == 1) {
                     if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                     else {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;}
                   }
                   else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;}
                         else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                   };
            } // end even row handling
           else {  // else it is an odd row....
                  // in squares, nw_right, n_right, s_right, se_right, not ne_right!
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   //w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                  // This isn't used -  candidate for deletion - cell_full = cel.extra == 4

                   n_left = n_neigh == 1 || n_neigh == 3
                   n_right = n_neigh  == 2 || n_neigh == 3;
                   ne_left = ne_neigh == 1 || ne_neigh == 3;
                   e_neigh = cellist[4].extra == 4
                   se_left = se_neigh == 1 || se_neigh == 3
                   se_right = se_neigh  == 2 || se_neigh == 3;
                   s_left = s_neigh == 1 || s_neigh == 3
                   s_right = s_neigh  == 2 || s_neigh == 3;
                   sw_right = sw_neigh  == 2 || sw_neigh == 3;
                   w_neigh = cellist[3].extra == 4
                   nw_left = nw_neigh == 1 || nw_neigh == 3
                   nw_right = nw_neigh  == 2 || nw_neigh == 3;

                   len =  n_left + e_neigh + w_neigh + s_right +  n_right + ne_left+ se_left + se_right + s_left + sw_right + nw_left + nw_right // first four: VN
                   
                   if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; cel.placeholder_extra = 4} 
                   else {cel.placeholder_color = background; cel.placeholder_extra = 0};
               }
    
                   break;


     case 46:   // Snub Square Tiling 
  // as implemented in 8 states as alternating left and right triangles,
  //                                           reverse triangles (backleft and backright), 
  //                                       and full squares.
            // States:   left = 1, right = 2, left&right = 3, backleft = 4, backright = 5, backleft & backright = 6, alivesquare = 7

                   cellist = cel.neighbors;

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                      

                if (cel.xpos % 2 == 0 && cel.ypos % 2 == 0) {
                      // then cel is a left-right type of cell.

                      cell_left =  cel.extra == 1 || cel.extra == 3;
                      cell_right = cel.extra == 2 || cel.extra == 3;
                      nw_backleft = nw_neigh == 4 || nw_neigh == 6;
                      nw_backright = nw_neigh == 5 || nw_neigh == 6;
                      ne_backleft = ne_neigh == 4 || ne_neigh == 6;


                      se_backleft = se_neigh == 4 || se_neigh == 6;
                      se_backright = se_neigh == 5 || se_neigh == 6;
                      sw_backright = sw_neigh == 5 || sw_neigh == 6;
                      if (n_neigh == 7) {n_square = 1} else {n_square = 0}
                      if (e_neigh == 7) {e_square = 1} else {e_square = 0}
                      if (s_neigh == 7) {s_square = 1} else {s_square = 0}
                      if (w_neigh == 7) {w_square = 1} else {w_square = 0}

  
                      rightcount = cell_left + e_square + s_square + m_or_vn_weight[celdotcolor] * (n_square + ne_backleft + se_backleft + se_backright + sw_backright + w_square)
                      leftcount =  cell_right + w_square + n_square + m_or_vn_weight[celdotcolor] * (ne_backleft + e_square + s_square + sw_backright + nw_backleft + nw_backright)
                   
                      
                   
                      if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};

                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


               }  //end section for left-right cells


                else if (cel.xpos % 2 == 1 && cel.ypos % 2 == 1) {  // begin section for backleft-backright cells

                      cell_backleft = cel.extra == 4 || cel.extra == 6;
                      cell_backright = cel.extra == 5 || cel.extra == 6;

                      if (n_neigh == 7) {n_square = 1} else {n_square = 0}
                      if (e_neigh == 7) {e_square = 1} else {e_square = 0}
                      if (s_neigh == 7) {s_square = 1} else {s_square = 0}
                      if (w_neigh == 7) {w_square = 1} else {w_square = 0}


                      nw_right = nw_neigh == 2 || nw_neigh == 3

                      ne_left = ne_neigh == 1 || ne_neigh == 3
                      ne_right = ne_neigh == 2 || ne_neigh == 3

                      se_left = se_neigh == 1 || se_neigh == 3

                      sw_left = sw_neigh == 1 || sw_neigh == 3
                      sw_right = sw_neigh == 2 || sw_neigh == 3

                     rightcount = cell_backleft + n_square + e_square + m_or_vn_weight[celdotcolor] * (ne_left + ne_right + se_left + s_square + w_square + nw_right)  // for cell_backright
                     leftcount =  cell_backright + s_square + w_square + m_or_vn_weight[celdotcolor] * (n_square + e_square + se_left + sw_left + sw_right + nw_right) // for cell_backleft

                   
                      if (cell_backleft == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_backright == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};

                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 6; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 4; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


                } // end section for backleft-backright cells
              else {  // begin section for full cells

                     n_backleft =  n_neigh == 4 || n_neigh == 6
                     n_left = n_neigh == 1 || n_neigh == 3

                     e_left =      e_neigh == 1 || e_neigh == 3
                     e_backleft = e_neigh == 4 || e_neigh == 6

                     s_right = s_neigh == 2 || s_neigh == 3
                     s_backright = s_neigh == 5 || s_neigh == 6

                     w_right =     w_neigh == 2 || w_neigh == 3
                     w_backright = w_neigh == 5 || w_neigh == 6

                     n_backright = n_neigh == 5 || n_neigh == 6
                     n_right = n_neigh == 2 || n_neigh == 3

                     e_right = e_neigh == 2 || e_neigh == 3
                     e_backright = e_neigh == 5 || e_neigh == 6

                     s_backleft = s_neigh == 4 || s_neigh == 6
                     s_left = s_neigh == 1 || s_neigh == 3

                     w_backleft =  w_neigh == 4 || w_neigh == 6
                     w_left =  w_neigh == 1 || w_neigh == 3
                      if (ne_neigh == 7) {ne_square = 1} else {ne_square = 0}
                      if (nw_neigh == 7) {nw_square = 1} else {nw_square = 0}
                      if (se_neigh == 7) {se_square = 1} else {se_square = 0}
                      if (sw_neigh == 7) {sw_square = 1} else {sw_square = 0}

                  
   

                        // Need to rearrange the following and then insert m_or_vn_weight[celdotcolor] * ()
                    //  mycount = n_backleft + n_left + e_left + e_backleft + s_backright + s_right + w_right + w_backright + n_backright + n_right + ne_square + e_right + e_backright + se_square + s_backleft + s_left + sw_square + w_left + w_backleft + nw_square 



                    mycount = n_backleft + n_right + e_left + e_backleft + s_backright   + w_right + w_backright  + s_left   
                    + m_or_vn_weight[celdotcolor] * (n_left + s_right +  n_backright  + ne_square  + e_right  
                      + e_backright + se_square + s_backleft   + sw_square +  w_left + nw_square   + w_backleft  )


                   
                      
                     if (survivalrule[celdotcolor][mycount]) {cel.placeholder_color = celdotcolor; cel.placeholder_extra = 7} 
                     else {cel.placeholder_color = background; cel.placeholder_extra = 0};
                 }


                 
             break;

   case 48:
                   // six-six alternating splithex pentagons
                   // states:  1 = left, 2 = right, 3 = left & right, 4 = top, 5 = bottom, 6 = top & bottom
                   cellist = cel.neighbors;

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                  // ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                  // sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;  

               // lets say left-right cells occupy even columns and top-down cells occupy odd columns
                 
               if (cel.xpos % 2 == 0) {

                      // then cel is a left-right type of cell.

                      cell_left =  cel.extra == 1 || cel.extra == 3;
                      cell_right = cel.extra == 2 || cel.extra == 3;


                      nw_bottom =  nw_neigh == 5 || nw_neigh == 6
                      n_left = n_neigh == 1 || n_neigh == 3
                      w_top =   w_neigh == 4 || w_neigh == 6
                      w_bottom = w_neigh == 5 || w_neigh == 6
                      s_right = s_neigh == 2 || s_neigh == 3
                      se_top =  se_neigh == 4 || se_neigh == 6
                      e_top = e_neigh == 4 || e_neigh == 6
                      e_bottom = e_neigh == 5 || e_neigh == 6
                      
                     leftcount = cell_right + w_top + w_bottom + nw_bottom + se_top + s_right
                     rightcount = cell_left + nw_bottom + se_top + e_top + e_bottom + n_left

                                      
                      if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};

                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      }
                      
                    }  //end section for left-right cells

                else {    // then cel is a top-bottom type of cell.
                      cell_top =  cel.extra == 4 || cel.extra == 6;
                      cell_bottom = cel.extra == 5 || cel.extra == 6;
                      nw_left = nw_neigh == 1 || nw_neigh == 3
                      nw_right = nw_neigh == 2 || nw_neigh == 3
                      n_bottom = n_neigh == 5 || n_neigh == 6
                      e_left = e_neigh == 1 || e_neigh == 3
                      se_left = se_neigh == 1 || se_neigh == 3
                      se_right  = se_neigh == 2 || se_neigh == 3
                      s_top = s_neigh == 4 || s_neigh == 6
                      w_right = w_neigh == 2 || w_neigh == 3

                      bottomcount = cell_top + e_left + se_left + se_right + s_top + w_right
                      topcount = cell_bottom + e_left  + w_right + nw_left + nw_right + n_bottom

                    // If we know the entire cell is empty then this:
                       //  newcell_top = birthrule[celdotcolor][topcount]
                       //  newcell_bottom = birthrule[celdotcolor][bottomcount]
                   
                      if (cell_top == 1) {newcell_top = survivalrule[celdotcolor][topcount]} 
                               else {newcell_top = birthrule[celdotcolor][topcount]};
                      if (cell_bottom == 1) {newcell_bottom = survivalrule[celdotcolor][bottomcount]} 
                              else {newcell_bottom = birthrule[celdotcolor][bottomcount]};

                      // either way:

                      if (newcell_bottom == 1) {
                        if (newcell_top == 1) {cel.placeholder_extra = 6; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_top == 1) {cel.placeholder_extra = 4; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                      };
                } // end section for top-bottom cells
              break;

    case 49:   // survival case

                  // 5-8 alternating splithex pentagons
                  // states:  1 = left, 2 = right, 3 = left & right, 4 = top, 5 = bottom, 6 = top & bottom


                   cellist = cel.neighbors;

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;
                if ((cel.xpos % 2 == 0 && cel.ypos % 2 == 0) || (cel.xpos % 2 == 1 && cel.ypos % 2 == 1)) {
                      // then cel is a left-right type of cell.
                      cell_left =  cel.extra == 1 || cel.extra == 3;
                      cell_right = cel.extra == 2 || cel.extra == 3;
                      nw_left = nw_neigh == 1 || nw_neigh == 3
                      nw_right = nw_neigh == 2 || nw_neigh == 3
                      n_bottom = n_neigh == 5 || n_neigh == 6
                      e_top = e_neigh == 4 || e_neigh == 6
                      e_bottom = e_neigh == 5 || e_neigh == 6
                      se_left = se_neigh == 1 || se_neigh == 3
                      se_right = se_neigh == 2 || se_neigh == 3
                      s_top = s_neigh == 4 || s_neigh == 6
                      w_top = w_neigh == 4 || w_neigh == 6

                      right_count = cell_left + nw_right + n_bottom + e_top + e_bottom + se_right  + se_left  + nw_left // last two: VN
                      left_count = cell_right + nw_left + w_top + w_bottom + s_top + se_left   + se_right + nw_right // last two: VN
                                            if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};

                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      }
                      
                    }  //end section for left-right cells

                else {    // then cel is a top-bottom type of cell.
                        cell_top = cel.extra == 4 || cel.extra == 6
                        cell_bottom = cel.extra == 5 || cel.extra == 6
                        nw_bottom = nw_neigh == 5 || nw_neigh == 6
                        n_left = n_neigh == 1 || n_neigh == 3
                        w_right = w_neigh == 2 || w_neigh == 3
                        e_left = e_neigh == 1 || e_neigh == 3
                        se_top = se_neigh == 4 || se_neigh == 6
                        s_right = s_neigh == 2 || s_neigh == 3

                      topcount = cell_bottom + nw_bottom + n_left + e_left + w_right
                      bottom_count = cell_top + w_right + e_left + se_top + s_right
                    // If we know the entire cell is empty then this:
                       //  newcell_top = birthrule[celdotcolor][topcount]
                       //  newcell_bottom = birthrule[celdotcolor][bottomcount]
                   
                      if (cell_top == 1) {newcell_top = survivalrule[celdotcolor][topcount]} 
                               else {newcell_top = birthrule[celdotcolor][topcount]};
                      if (cell_bottom == 1) {newcell_bottom = survivalrule[celdotcolor][bottomcount]} 
                              else {newcell_bottom = birthrule[celdotcolor][bottomcount]};

                      // either way:

                      if (newcell_bottom == 1) {
                        if (newcell_top == 1) {cel.placeholder_extra = 6; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_top == 1) {cel.placeholder_extra = 4; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                      };
                } // end section for top-bottom cells
              break;
  
   case 50:   //Tetrakis Square Tiling -- survival

             // States:   left = 1, right = 2, left&right = 3, backleft = 4, backright = 5, backleft & backright = 6, 

                   cellist = cel.neighbors;

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                if ((cel.xpos % 2 == 0 && cel.ypos % 2 == 0) || (cel.xpos % 2 == 1 && cel.ypos % 2 == 1)) {


                   cell_backleft = cel.extra == 4 || cel.extra == 6
                   cell_backright = cel.extra == 5 || cel.extra == 6
                   nw_backleft = nw_neigh == 4 || nw_neigh == 6
                   nw_backright = nw_neigh == 5 || nw_neigh == 6
                   n_left = n_neigh == 1 || n_neigh == 3
                   n_right = n_neigh == 2 || n_neigh == 3
                   e_left = e_neigh == 1 || e_neigh == 3
                   e_right = e_neigh == 2 || e_neigh == 3
                   se_backleft  = se_neigh == 4 || se_neigh == 6
                   se_backright = se_neigh == 5 || se_neigh == 6
                   s_left = s_neigh == 1 || s_neigh == 3
                   s_right = s_neigh == 2 || s_neigh == 3
                   sw_backright = sw_neigh == 5 || sw_neigh == 6
                   w_left = w_neigh == 1 || w_neigh == 3
                   w_right = w_neigh == 2 || w_neigh == 3
                   ne_backleft = ne_neigh == 4 || ne_neigh == 6

                   leftcount = cell_backright + nw_backleft + nw_backright + n_left + n_right + e_left + e_right + se_backleft + se_backright + s_left + s_right + sw_backright + w_left + w_right

                   rightcount = cell_backleft + nw_backleft + nw_backright + n_left + n_right +  ne_backleft + e_left + e_right + se_backleft + se_backright + s_left + s_right +  w_left + w_right

                   
                      if (cell_backleft == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_backright == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};

                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 6; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 4; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


               }  //end section for backleft-backright cells
               else {
                     cell_left = cel.extra == 1 || cel.extra == 3
                     cell_right = cel.extra == 2 || cel.extra == 3
                     nw_right = nw_neigh == 2 || nw_neigh == 3
                     n_backleft = n_neigh == 4 || n_neigh == 6
                     n_backright = n_neigh == 5 || n_neigh == 6
                     ne_left = ne_neigh == 1 || ne_neigh == 3
                     ne_right = ne_neigh == 2 || ne_neigh == 3
                     e_backleft = e_neigh == 4 || e_neigh == 6
                     e_backright = e_neigh == 5 || e_neigh == 6
                     se_left = se_neigh == 1 || se_neigh == 3
                     s_backleft = s_neigh == 4 || s_neigh == 6
                     s_backright = s_neigh == 5 || s_neigh == 6
                     sw_left = sw_neigh == 1 || sw_neigh == 3
                     sw_right = sw_neigh == 2 || sw_neigh == 3
                     w_backleft = w_neigh == 4 || w_neigh == 6
                     w_backright = w_neigh == 5 || w_neigh == 6


                     leftcount = cell_right + nw_right + n_backleft + n_backright + ne_left + ne_right + e_backleft + e_backright + s_backleft + s_backright + sw_left + sw_right + w_backleft + w_backright

                     rightcount =  cell_left + n_backleft + n_backright + ne_left + ne_right + e_backleft + e_backright + se_left +  s_backleft + s_backright + sw_left + sw_right + w_backleft + w_backright

                   
                      if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};

                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


               }  //end section for left-right cells

               break;
  
                              


            // Radius2-Trilife
          case 30:  
                  cellist = cel.neighbors;
                   n0 = cellist[0].extra

                   n1 = cellist[1].extra
                   n2 = cellist[2].extra
                   n3 = cellist[3].extra


                   //n4 = cellist[4].extra  // unused!
                   n5 = cellist[5].extra
                   n6 = cellist[6].extra
                   n7 = cellist[7].extra
                   n8 = cellist[8].extra
                   n9 = cellist[9].extra

                   n10 = cellist[10].extra
                   n11 = cellist[11].extra
                   n12 = cellist[12].extra
                   n13 = cellist[13].extra
                   n14 = cellist[14].extra
                   n15 = cellist[15].extra
                   n16 = cellist[16].extra
                   n17 = cellist[17].extra
                   n18 = cellist[18].extra

                   //n19 = cellist[19].extra  // unused!
                   n20 = cellist[20].extra
                   n21 = cellist[21].extra
                   n22 = cellist[22].extra
                   n23 = cellist[23].extra

                   cell_left =  cel.extra == 1 || cel.extra == 3;
                   cell_right = cel.extra == 2 || cel.extra == 3;

                   n0_left =  n0  == 1 || n0  == 3;
                   n0_right = n0  == 2 || n0 == 3;

                   n1_left =  n1 == 1 || n1 == 3;
                   n1_right = n1  == 2 || n1 == 3;

                   n2_left =  n2 == 1 || n2 == 3;
                   n2_right = n2  == 2 || n2 == 3;


                   n3_left =  n3 == 1 || n3 == 3;
                   // no n4
                   n5_left =  n5 == 1 || n5 == 3;
                   n5_right = n5  == 2 || n5 == 3;

                   n6_left =  n6 == 1 || n6 == 3;
                   n6_right = n6  == 2 || n6 == 3;

                   n7_left =  n7 == 1 || n7 == 3;
                   n7_right = n7  == 2 || n7 == 3;

                   n8_left =  n8 == 1 || n8 == 3;
                   n8_right = n8  == 2 || n8 == 3;

                   n9_left =  n9 == 1 || n9 == 3;


                   n10_left =  n10 == 1 || n10 == 3;
                   n10_right = n10  == 2 || n10 == 3;

                   n11_left =  n11 == 1 || n11 == 3;
                   n11_right = n11  == 2 || n11 == 3;

                   n12_left =  n12 == 1 || n12 == 3;
                   n12_right = n12  == 2 || n12 == 3;

                   n13_left =  n13 == 1 || n13 == 3;
                   n13_right = n13  == 2 || n13 == 3;


                   n14_right = n14 == 2 || n14 == 3;


                   n15_left =  n15 == 1 || n15 == 3;
                   n15_right = n15  == 2 || n15 == 3;

                   n16_left =  n16 == 1 || n16 == 3;
                   n16_right = n16  == 2 ||n16 == 3;

                   n17_left =  n17 == 1 || n17 == 3;
                   n17_right = n17  == 2 || n17 == 3;

                   n18_left =  n18 == 1 || n18 == 3;
                   n18_right = n18 == 2 || n18 == 3;

                   // no n19

                   n20_right = n20 == 2 || n20 == 3;

                   
                   n21_left =  n21 == 1 || n21 == 3;
                   n21_right = n21  == 2 || n21 == 3;


                   n22_left =  n22 == 1 || n22 == 3;
                   n22_right = n22  == 2 ||n22 == 3;


                   n23_left =  n23 == 1 || n23== 3;
                   n23_right = n23  == 2 || n23 == 3;




                   rightcount = cell_left + n0_left + n0_right  + n1_left + n1_right+ n2_left + n2_right + n3_left+ n5_left + n5_right + n6_left + n6_right + n7_left + n7_right + n8_left + n8_right + n9_left + n10_right + n11_left + n11_right + n12_left + n12_right + n13_left + n13_right  + n15_right + n16_left + n16_right + n17_left + n17_right + n18_left + n18_right  + n21_right + n22_left + n22_right + n23_left + n23_right ; 

                   leftcount =  cell_right + n0_left + n0_right  + n1_left + n1_right+ n2_left  + n5_left + n5_right + n6_left + n6_right + n7_left + n7_right + n8_left + n10_left + n10_right + n11_left + n11_right + n12_left + n12_right + n13_left   + n14_right + n15_left + n15_right + n16_left + n16_right + n17_left + n17_right + n18_left + n18_right + n20_right + n21_left + n21_right + n22_left + n22_right + n23_left + n23_right ;

                                
                   if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} else {newcell_left = birthrule[celdotcolor][leftcount]}
                   if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} else {newcell_right = birthrule[celdotcolor][rightcount]}


                   if (newcell_right == 1) {
                     if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                     else {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;}
                   }
                   else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;}
                         else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                   };
                  break;

              

           case 15:  // Rhombus ("Qbert") tiling
                   cellist = cel.neighbors;
                   celdotextra = cel.extra
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                   cell_left = celdotextra == 1 || celdotextra == 4 || celdotextra == 6 || celdotextra == 7
                   cell_right = celdotextra == 2 || celdotextra == 5 || celdotextra == 6 || celdotextra == 7
                   cell_top = celdotextra == 3 || celdotextra == 4 || celdotextra == 5 || celdotextra == 7
                   nw_right = nw_neigh == 2 || nw_neigh == 5 || nw_neigh == 6 || nw_neigh == 7
                   nw_left = nw_neigh == 1 || nw_neigh == 4 || nw_neigh == 6 || nw_neigh == 7
                   n_left = n_neigh == 1 || n_neigh == 4 || n_neigh == 6 || n_neigh == 7
                   n_right = n_neigh == 2 || n_neigh == 5 || n_neigh == 6 || n_neigh == 7
                   e_left = e_neigh == 1 || e_neigh == 4 || e_neigh == 6 || e_neigh == 7
                   e_top = e_neigh  == 3 || e_neigh == 4 || e_neigh == 5 || e_neigh == 7
                   se_left = se_neigh == 1 || se_neigh == 4 || se_neigh == 6 || se_neigh == 7
                   se_top = se_neigh  == 3 || se_neigh == 4 || se_neigh == 5 || se_neigh == 7
                   s_right = s_neigh == 2 || s_neigh == 5 || s_neigh == 6 || s_neigh == 7
                   s_top = s_neigh == 3 || s_neigh == 4 || s_neigh == 5 || s_neigh == 7
                   w_right = w_neigh == 2 || w_neigh == 5 || w_neigh == 6 || w_neigh == 7
                   w_top = w_neigh  == 3 || w_neigh == 4 || w_neigh == 5 || w_neigh == 7


/*

                   topcount = cell_left + cell_right + nw_right + n_left  // the four side cells
                              + w_right + w_top + nw_left // the three corner cells to the west
                              + n_right + e_top + e_left; // the three corner cells to the east

                   leftcount = cell_top + cell_right + s_top + w_right // the four side cells
                                + w_top + nw_left + nw_right // the three corner cells to the top
                                + s_right + se_left + se_top; // the three corner cells to the bottom

                   rightcount = cell_left + cell_top + e_left + se_top // the four side cells
                                + n_left + n_right + e_top // the three corner cells to the top
                                +  s_top +  s_right + se_left  // the three corner cells to the bottom
*/

                 topcount = cell_left + cell_right + nw_right +  n_left +  m_or_vn_weight[celdotcolor] *( w_right + w_top + nw_left + n_right + e_top + e_left); 
                 leftcount = cell_top + cell_right + s_top +  w_right +  m_or_vn_weight[celdotcolor] *(w_top + nw_left + nw_right + s_right + se_left + se_top); 
                 rightcount = cell_left + cell_top + e_left +  se_top + m_or_vn_weight[celdotcolor] *(n_left + n_right + e_top  +  s_top +  s_right + se_left);


             // This is Qbert-VN6 (it includes the middle corner cells)
              //   topcount = cell_left + cell_right + nw_right +  n_left +     w_top  + e_top       + m_or_vn_weight[celdotcolor] *( w_right + nw_left + n_right + e_left); 
              //   leftcount = cell_top + cell_right + s_top +  w_right      + nw_left + se_left +  m_or_vn_weight[celdotcolor] *(w_top  + nw_right + s_right + se_top); 
              //   rightcount = cell_left + cell_top + e_left +  se_top      + n_right  +  s_right + m_or_vn_weight[celdotcolor] *(n_left + e_top + s_top + se_left);

             // This is Qbert-VN8 (it excludes the middle corner cells)
            //     topcount = cell_left + cell_right + nw_right +  n_left +    + m_or_vn_weight[celdotcolor] *(  w_top  + e_top  ) +       w_right + nw_left + n_right + e_left; 
            //     leftcount = cell_top + cell_right + s_top +  w_right     + m_or_vn_weight[celdotcolor] *(  nw_left + se_left)  +   w_top  + nw_right + s_right + se_top; 
            //     rightcount = cell_left + cell_top + e_left +  se_top     + m_or_vn_weight[celdotcolor] *(   n_right  +  s_right) + n_left + e_top + s_top + se_left;




                   // Birth & Survival
                      if (cell_top == 1) { newcell_top = survivalrule[celdotcolor][topcount]}
                      else  { newcell_top = birthrule[celdotcolor][topcount]  }

                      if (cell_left == 1) { newcell_left = survivalrule[celdotcolor][leftcount]}
                      else  { newcell_left = birthrule[celdotcolor][leftcount]  }


                      if (cell_right == 1) { newcell_right = survivalrule[celdotcolor][rightcount]}
                      else  { newcell_right = birthrule[celdotcolor][rightcount]  }


                      // Final results
                      // this could have used binary encoding, etc but it would have been harder to debug.
                         if (newcell_left == 0 && newcell_right == 0 && newcell_top == 0) 
                            {cel.placeholder_extra = 0; cel.placeholder_color = background;} 
                         else if (newcell_left == 1 && newcell_right == 0 && newcell_top == 0) 
                            {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_left == 0 && newcell_right == 1 && newcell_top == 0) 
                            {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_left == 0 && newcell_right == 0 && newcell_top == 1) 
                            {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_left == 1 && newcell_right == 0 && newcell_top == 1) 
                            {cel.placeholder_extra = 4; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_left == 0 && newcell_right == 1 && newcell_top == 1) 
                            {cel.placeholder_extra = 5; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_left == 1 && newcell_right == 1 && newcell_top == 0) 
                            {cel.placeholder_extra = 6; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_left == 1 && newcell_right == 1 && newcell_top == 1) 
                            {cel.placeholder_extra = 7; cel.placeholder_color = celdotcolor;} 
                     break;

           case 51:  // Rhombus-VN-Radius2
                   cellist = cel.neighbors;
                   celdotextra = cel.extra
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                   cell_left = celdotextra == 1 || celdotextra == 4 || celdotextra == 6 || celdotextra == 7
                   cell_right = celdotextra == 2 || celdotextra == 5 || celdotextra == 6 || celdotextra == 7
                   cell_top = celdotextra == 3 || celdotextra == 4 || celdotextra == 5 || celdotextra == 7
                   nw_top = nw_neigh  == 3 || nw_neigh == 4 || nw_neigh == 5 || nw_neigh == 7
                   nw_right = nw_neigh == 2 || nw_neigh == 5 || nw_neigh == 6 || nw_neigh == 7
                   nw_left = nw_neigh == 1 || nw_neigh == 4 || nw_neigh == 6 || nw_neigh == 7
                   n_top = n_neigh  == 3 || n_neigh == 4 || n_neigh == 5 || n_neigh == 7
                   n_left = n_neigh == 1 || n_neigh == 4 || n_neigh == 6 || n_neigh == 7
                   n_right = n_neigh == 2 || n_neigh == 5 || n_neigh == 6 || n_neigh == 7
                   e_left = e_neigh == 1 || e_neigh == 4 || e_neigh == 6 || e_neigh == 7
                   e_right = e_neigh == 2 || e_neigh == 5 || e_neigh == 6 || e_neigh == 7
                   e_top = e_neigh  == 3 || e_neigh == 4 || e_neigh == 5 || e_neigh == 7
                   se_right = se_neigh == 2 || se_neigh == 5 || se_neigh == 6 || se_neigh == 7
                   se_left = se_neigh == 1 || se_neigh == 4 || se_neigh == 6 || se_neigh == 7
                   se_top = se_neigh  == 3 || se_neigh == 4 || se_neigh == 5 || se_neigh == 7
                   s_left = s_neigh == 1 || s_neigh == 4 || s_neigh == 6 || s_neigh == 7
                   s_right = s_neigh == 2 || s_neigh == 5 || s_neigh == 6 || s_neigh == 7
                   s_top = s_neigh == 3 || s_neigh == 4 || s_neigh == 5 || s_neigh == 7
                   w_right = w_neigh == 2 || w_neigh == 5 || w_neigh == 6 || w_neigh == 7
                   w_top = w_neigh  == 3 || w_neigh == 4 || w_neigh == 5 || w_neigh == 7
                   w_left = w_neigh == 1 || w_neigh == 4 || w_neigh == 6 || w_neigh == 7



                   topcount = cell_left + cell_right + nw_right +  n_left +  nw_left + nw_top + n_right + n_top + w_right + e_left + s_top + se_top;
                   leftcount = cell_top + cell_right + s_top +  w_right + s_left + s_right + w_left + w_top + nw_right + n_left + e_left + se_top;
                   rightcount = cell_left + cell_top + e_left +  se_top + e_right + e_top + se_left + se_right + s_top + nw_right + n_left + w_right;

                   // Birth & Survival
                      if (cell_top == 1) { newcell_top = survivalrule[celdotcolor][topcount]}
                      else  { newcell_top = birthrule[celdotcolor][topcount]  }

                      if (cell_left == 1) { newcell_left = survivalrule[celdotcolor][leftcount]}
                      else  { newcell_left = birthrule[celdotcolor][leftcount]  }


                      if (cell_right == 1) { newcell_right = survivalrule[celdotcolor][rightcount]}
                      else  { newcell_right = birthrule[celdotcolor][rightcount]  }


                      // Final results
                      // this could have used binary encoding, etc but it would have been harder to debug.
                         if (newcell_left == 0 && newcell_right == 0 && newcell_top == 0) 
                            {cel.placeholder_extra = 0; cel.placeholder_color = background;} 
                         else if (newcell_left == 1 && newcell_right == 0 && newcell_top == 0) 
                            {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_left == 0 && newcell_right == 1 && newcell_top == 0) 
                            {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_left == 0 && newcell_right == 0 && newcell_top == 1) 
                            {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_left == 1 && newcell_right == 0 && newcell_top == 1) 
                            {cel.placeholder_extra = 4; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_left == 0 && newcell_right == 1 && newcell_top == 1) 
                            {cel.placeholder_extra = 5; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_left == 1 && newcell_right == 1 && newcell_top == 0) 
                            {cel.placeholder_extra = 6; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_left == 1 && newcell_right == 1 && newcell_top == 1) 
                            {cel.placeholder_extra = 7; cel.placeholder_color = celdotcolor;} 
                     break;


           case 52:  // Penta-Type9
                   cellist = cel.neighbors;
                   celdotextra = cel.extra
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                   if (celdotextra == 1) {
                      len = (n_neigh == 6) +  (w_neigh == 7) + (e_neigh == 7) +  (sw_neigh == 4) +(s_neigh == 5)  +  m_or_vn_weight[celdotcolor] *((ne_neigh == 3)+(se_neigh == 4))
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 1
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                    else if (celdotextra == 2) {
                      len =  (n_neigh == 5)  + (w_neigh == 8) + (e_neigh == 8) + (s_neigh == 6) +(se_neigh == 3) +  m_or_vn_weight[celdotcolor] *((nw_neigh == 4) + (sw_neigh == 3))
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 2
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                   else if (celdotextra == 3) {
                      len = (nw_neigh == 2) + (n_neigh == 8)  +  (w_neigh == 6) + (e_neigh == 6)  + (s_neigh == 7) +  m_or_vn_weight[celdotcolor] *((ne_neigh == 2) + (sw_neigh == 1))
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 3
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                   else if (celdotextra == 4) {
                      len =  (n_neigh == 7)  + (ne_neigh == 1) + (w_neigh == 5) + (e_neigh == 5) + (s_neigh == 8) +  m_or_vn_weight[celdotcolor] *((nw_neigh == 1)  + (se_neigh == 2))
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 4
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                   else if (celdotextra == 5) {
                      len = (n_neigh == 1) + (w_neigh == 4) + (e_neigh == 4) + (s_neigh == 2) +(se_neigh == 8) +  m_or_vn_weight[celdotcolor] *((ne_neigh == 7) + (sw_neigh == 8))
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 5
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                    else if (celdotextra == 6) {
                      len =  (n_neigh == 2)  + (w_neigh == 3) + (e_neigh == 3) + (sw_neigh == 7) + (s_neigh == 1) +  m_or_vn_weight[celdotcolor] *((nw_neigh == 8) +(se_neigh == 7) )
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 6
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                   else if (celdotextra == 7) {
                      len =  (n_neigh == 3)  + (ne_neigh == 6) + (w_neigh == 1) + (e_neigh == 1) + (s_neigh == 4) +  m_or_vn_weight[celdotcolor] *((nw_neigh == 6) + (sw_neigh == 5) )
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 7
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                   else if (celdotextra == 8) {
                      len = (nw_neigh == 5) + (n_neigh == 4)  +  (w_neigh == 2) + (e_neigh == 2) + (s_neigh == 3)   +  m_or_vn_weight[celdotcolor] *((ne_neigh == 5) + (se_neigh == 6))
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 8
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                       
                  break;
                 


/*
x = 65, y = 97, rule = B3/S23
$9b8ob15o8b8ob15o$8b9ob15o7b9ob15o$7b10ob15o6b10ob15o$6b11ob15o5b11ob
15o$5b12ob15o4b12ob15o$4b6ob6ob5o3b7o3b6ob6ob5o3b7o$3b7ob6ob7ob7o2b7ob
6ob7ob7o$2b8ob6ob7ob7ob8ob6ob7ob7o$2b8ob6ob7ob6o2b8ob6ob7ob6o$2b8ob6ob
7ob5o3b8ob6ob7ob5o$2b15ob12o4b15ob12o$2b15ob11o5b15ob11o$2b15ob10o6b
15ob10o$2b15ob9o7b15ob9o$2b15ob8o8b15ob8o2$9b8ob15o8b8ob15o$8b9ob15o7b
9ob15o$7b10ob15o6b10ob15o$6b11ob15o5b11ob15o$5b12ob15o4b12ob15o$4b13ob
8obob4o3b13ob8obob4o$3b6o3b5ob8obob4o2b6o3b5ob8obob4o$2b7ob7ob8o3b4ob
7ob7ob8o3b4o$2b7o3b5o2b9ob4ob7o3b5o2b9ob4o$2b9ob5o3b8ob4ob9ob5o3b8ob4o
$2b7o3b5o4b12ob7o3b5o4b12o$2b15o5b11ob15o5b11o$2b15o6b10ob15o6b10o$2b
15o7b9ob15o7b9o$2b15o8b8ob15o8b8o2$2b8o8b15ob8o8b15o$2b9o7b15ob9o7b15o
$2b10o6b15ob10o6b15o$2b11o5b15ob11o5b15o$2b12o4b15ob12o4b15o$2b4o3b6o
3b8o3b4ob4o3b6o3b8o3b4o$2b6ob7o2b8obob4ob6ob7o2b8obob4o$2b4o3b8ob8o3b
4ob4o3b8ob8o3b4o$2b4ob10o2b7obob4ob4ob10o2b7obob4o$2b4o3b8o3b6o3b4ob4o
3b8o3b6o3b4o$2b15o4b12ob15o4b12o$2b15o5b11ob15o5b11o$2b15o6b10ob15o6b
10o$2b15o7b9ob15o7b9o$2b15o8b8ob15o8b8o2$2b8o8b15ob8o8b15o$2b9o7b15ob
9o7b15o$2b10o6b15ob10o6b15o$2b11o5b15ob11o5b15o$2b12o4b15ob12o4b15o$2b
5o3b5o3b15ob5o3b5o3b15o$2b5ob8o2b5o3b7ob5ob8o2b5o3b7o$2b5o3b7ob7ob7ob
5o3b7ob7ob7o$2b5obob7ob5o3b6o2b5obob7ob5o3b6o$2b5o3b7ob7ob5o3b5o3b7ob
7ob5o$2b15ob5o3b4o4b15ob5o3b4o$2b15ob11o5b15ob11o$2b15ob10o6b15ob10o$
2b15ob9o7b15ob9o$2b15ob8o8b15ob8o2$9b8ob15o8b8ob15o$8b9ob15o7b9ob15o$
7b10ob15o6b10ob15o$6b11ob15o5b11ob15o$5b12ob15o4b12ob15o$4b6ob6ob5o3b
7o3b6ob6ob5o3b7o$3b7ob6ob7ob7o2b7ob6ob7ob7o$2b8ob6ob7ob7ob8ob6ob7ob7o$
2b8ob6ob7ob6o2b8ob6ob7ob6o$2b8ob6ob7ob5o3b8ob6ob7ob5o$2b15ob12o4b15ob
12o$2b15ob11o5b15ob11o$2b15ob10o6b15ob10o$2b15ob9o7b15ob9o$2b15ob8o8b
15ob8o2$9b8ob15o8b8ob15o$8b9ob15o7b9ob15o$7b10ob15o6b10ob15o$6b11ob15o
5b11ob15o$5b12ob15o4b12ob15o$4b13ob8obob4o3b13ob8obob4o$3b6o3b5ob8obob
4o2b6o3b5ob8obob4o$2b7ob7ob8o3b4ob7ob7ob8o3b4o$2b7o3b5o2b9ob4ob7o3b5o
2b9ob4o$2b9ob5o3b8ob4ob9ob5o3b8ob4o$2b7o3b5o4b12ob7o3b5o4b12o$2b15o5b
11ob15o5b11o$2b15o6b10ob15o6b10o$2b15o7b9ob15o7b9o$2b15o8b8ob15o8b8o!
*/


/*
           case 52:  // Penta-Type9 c3 version
                   cellist = cel.neighbors;
                   celdotextra = cel.extra
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                   if (celdotextra == 1) {
                      len = (n_neigh == 6) +  (w_neigh == 7) + (e_neigh == 7) +  (sw_neigh == 4) +(s_neigh == 5)  +  m_or_vn_weight[celdotcolor] *((ne_neigh == 3)+(se_neigh == 4))
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 1
                      }  
                      else {cel.placeholder_color = celdotcolor;
                            cel.placeholder_extra = 9
                      }
                    }
                    else if (celdotextra == 2) {
                      len =  (n_neigh == 5)  + (w_neigh == 8) + (e_neigh == 8) + (s_neigh == 6) +(se_neigh == 3) +  m_or_vn_weight[celdotcolor] *((nw_neigh == 4) + (sw_neigh == 3))
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 2
                      }  
                      else {cel.placeholder_color = celdotcolor;
                            cel.placeholder_extra = 9
                      }
                    }
                   else if (celdotextra == 3) {
                      len = (nw_neigh == 2) + (n_neigh == 8)  +  (w_neigh == 6) + (e_neigh == 6)  + (s_neigh == 7) +  m_or_vn_weight[celdotcolor] *((ne_neigh == 2) + (sw_neigh == 1))
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 3
                      }  
                      else {cel.placeholder_color = celdotcolor;
                            cel.placeholder_extra = 9
                      }
                    }
                   else if (celdotextra == 4) {
                      len =  (n_neigh == 7)  + (ne_neigh == 1) + (w_neigh == 5) + (e_neigh == 5) + (s_neigh == 8) +  m_or_vn_weight[celdotcolor] *((nw_neigh == 1)  + (se_neigh == 2))
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 4
                      }  
                      else {cel.placeholder_color = celdotcolor;
                            cel.placeholder_extra = 9
                      }
                    }
                   else if (celdotextra == 5) {
                      len = (n_neigh == 1) + (w_neigh == 4) + (e_neigh == 4) + (s_neigh == 2) +(se_neigh == 8) +  m_or_vn_weight[celdotcolor] *((ne_neigh == 7) + (sw_neigh == 8))
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 5
                      }  
                      else {cel.placeholder_color = celdotcolor;
                            cel.placeholder_extra = 9
                      }
                    }
                    else if (celdotextra == 6) {
                      len =  (n_neigh == 2)  + (w_neigh == 3) + (e_neigh == 3) + (sw_neigh == 7) + (s_neigh == 1) +  m_or_vn_weight[celdotcolor] *((nw_neigh == 8) +(se_neigh == 7) )
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 6
                      }  
                      else {cel.placeholder_color = celdotcolor;
                            cel.placeholder_extra = 9
                      }
                    }
                   else if (celdotextra == 7) {
                      len =  (n_neigh == 3)  + (ne_neigh == 6) + (w_neigh == 1) + (e_neigh == 1) + (s_neigh == 4) +  m_or_vn_weight[celdotcolor] *((nw_neigh == 6) + (sw_neigh == 5) )
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 7
                      }  
                      else {cel.placeholder_color = celdotcolor;
                            cel.placeholder_extra = 9
                      }
                    }
                   else if (celdotextra == 8) {
                      len = (nw_neigh == 5) + (n_neigh == 4)  +  (w_neigh == 2) + (e_neigh == 2) + (s_neigh == 3)   +  m_or_vn_weight[celdotcolor] *((ne_neigh == 5) + (se_neigh == 6))
                      if (survivalrule[celdotcolor][len]) {cel.placeholder_color = celdotcolor; 
                                                           cel.placeholder_extra = 8
                      }  
                      else {cel.placeholder_color = celdotcolor;
                            cel.placeholder_extra = 9
                      }
                    }
                   else if (celdotextra == 9) {
                            cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                  // else if (celdotextra == 10) {
                  //          cel.placeholder_color = background;
                  //          cel.placeholder_extra = 0
                  //    }


                       
                  break;
                      
*/

 case 53:    
            // Penta-Type14 ("Penta-Type-E")
      //state 0 = background, 
      // 1 = red-left     2 = red-right,    3 = red-both, 
      // 4 = yellow-left, 5 = yellow-right, 6 = yellow-both, 
      // 7 = green-top,   8 = green-bottom, 9 = green-both
        
                   cellist = cel.neighbors;
                   celdotextra = cel.extra
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

    if ((cel.xpos % 3 == 0 && cel.ypos % 3 == 0) || (cel.xpos % 3 == 1 && cel.ypos % 3 == 2)|| (cel.xpos % 3 == 2 && cel.ypos % 3 == 1)) {
      // then cell is a "Red" 

      cell_left = celdotextra == 1 || celdotextra == 3;
      cell_right =  celdotextra == 2 || celdotextra == 3;

       // the red cell's neighbors are either yellow or green
      nw_right = nw_neigh == 5 || nw_neigh == 6
      n_bottom = n_neigh == 8 || n_neigh == 9
      w_top = w_neigh == 7 || w_neigh == 9
      w_bottom = w_neigh == 8 || w_neigh == 9
      s_left = s_neigh == 4 || s_neigh == 6
      s_right = s_neigh == 5 || s_neigh == 6
      e_left = e_neigh == 4 || e_neigh == 6 
      se_top = se_neigh == 7 || se_neigh == 9

      leftcount = cell_right + nw_right + n_bottom + w_top + w_bottom + s_left + s_right
      rightcount = cell_left + n_bottom + e_left + s_right + se_top


                       // If we know the entire cell is empty then this:
                       //  newcell_left = birthrule[majcolor][leftcount]
                       //  newcell_right = birthrule[majcolor][rightcount]
                   
                      if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};

                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 2; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };

   }  //end section for red  cells


  else  if ((cel.xpos % 3 == 0 && cel.ypos % 3 == 1) || (cel.xpos % 3 == 1 && cel.ypos % 3 == 0)
           || (cel.xpos % 3 == 2 && cel.ypos % 3 == 2)) {  // begin section for yellow cells

     // then cell is a "Yellow" 

      //state 0 = background, 
      // 1 = red-left     2 = red-right,    3 = red-both, 
      // 4 = yellow-left, 5 = yellow-right, 6 = yellow-both, 
      // 7 = green-top,   8 = green-bottom, 9 = green-both

      cell_left = celdotextra == 4 || celdotextra == 6;
      cell_right =  celdotextra == 5 || celdotextra == 6;

       // the yellow cell's neighbors are either red or green

       nw_bottom = nw_neigh == 8 || nw_neigh == 9
       n_left = n_neigh == 1 || n_neigh == 3
       n_right = n_neigh  == 2 || n_neigh == 3
       w_right = w_neigh ==  2 || w_neigh == 3
       s_top =  s_neigh == 7|| s_neigh == 9 
       e_top =   e_neigh == 7|| e_neigh == 9
       e_bottom = e_neigh == 8|| e_neigh == 9
       se_left = se_neigh == 1|| se_neigh == 3

       leftcount = cell_right + nw_bottom + n_left + w_right + s_top
       rightcount = cell_left + n_left +  n_right + e_top  +  e_bottom + se_left +  s_top

                       // If we know the entire cell is empty then this:
                       //  newcell_left = birthrule[majcolor][leftcount]
                       //  newcell_right = birthrule[majcolor][rightcount]
                   
                      if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};

                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 6; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 4; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };

   }  //end section for yellow  cells

         
 else  { //if ((cel.xpos % 3 == 0 && cel.ypos % 3 == 2) || (cel.xpos % 3 == 1 && cel.ypos % 3 == 1)
       //    || (cel.xpos % 3 == 2 && cel.ypos % 3 == 0)) {
         // then cell is a "green" 


      //state 0 = background, 
      // 1 = red-left     2 = red-right,    3 = red-both, 
      // 4 = yellow-left, 5 = yellow-right, 6 = yellow-both, 
      // 7 = green-top,   8 = green-bottom, 9 = green-both

     cell_top = cel.extra == 7 || cel.extra == 9;
     cell_bottom = cel.extra == 8 || cel.extra == 9;

       // the green cell's neighbors are either red or yellow

      nw_right = nw_neigh == 2 || nw_neigh ==  3 // red
      n_left = n_neigh == 4 || n_neigh ==  6    // yellow
      n_right = n_neigh == 5 || n_neigh == 6     // yellow
      w_right = w_neigh == 5 || w_neigh == 6   // yellow
      e_left = e_neigh == 1 || e_neigh == 3  // red
      s_left = s_neigh == 1 || s_neigh == 3   // red
      s_right = s_neigh == 2|| s_neigh ==  3 // red
      se_left = se_neigh == 4 || se_neigh == 6 // yellow
     

       topcount = cell_bottom + nw_right + n_left + n_right + w_right + e_left
       bottomcount = cell_top + w_right + e_left + s_left + s_right + se_left

                    // If we know the entire cell is empty then this:
                       //  newcell_top = birthrule[majcolor][topcount]
                       //  newcell_bottom = birthrule[majcolor][bottomcount]
                   
                      if (cell_top == 1) {newcell_top = survivalrule[celdotcolor][topcount]} 
                               else {newcell_top = birthrule[celdotcolor][topcount]};
                      if (cell_bottom == 1) {newcell_bottom = survivalrule[celdotcolor][bottomcount]} 
                              else {newcell_bottom = birthrule[celdotcolor][bottomcount]};

                      // either way:

                      if (newcell_bottom == 1) {
                        if (newcell_top == 1) {cel.placeholder_extra = 9; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 8; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_top == 1) {cel.placeholder_extra = 7; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                      };
                } // end section for top-bottom cells

             break;


case 54:     // Triakis-Triangular Tiling 
                 // binary code for the six cellular subdivisions in the hexagon
                   // 000001 = top_inner,
                   // 000010 = top_outer, 
                   // 000100 = left_inner,
                  //  001000 = left_outer,
                  //  010000 = right_inner, 
                  //  100000 = right_outer


                   cellist = cel.neighbors;
                   celdotextra = cel.extra

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   // ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   // sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                   cell_left_inner = (celdotextra >> 2) & 1
                   cell_right_inner = (celdotextra >> 4) & 1
                   cell_top_inner = celdotextra & 1
 
                   cell_left_outer = (celdotextra  >> 3) & 1
                   cell_right_outer = (celdotextra >> 5) & 1
                   cell_top_outer = (celdotextra >> 1) & 1

                   nw_right_inner = (nw_neigh >> 4) & 1 
                   nw_left_inner = (nw_neigh >> 2) & 1
                   n_left_inner = (n_neigh >> 2) & 1
                   n_right_inner = (n_neigh >> 4) & 1
                   e_left_inner = (e_neigh >> 2) & 1
                   e_top_inner = e_neigh & 1   
                   se_left_inner = (se_neigh >> 2) & 1
                   se_top_inner = se_neigh & 1  
                   s_right_inner = (s_neigh >> 4) & 1
                   s_top_inner = s_neigh & 1 
                   w_right_inner = (w_neigh >> 4) & 1
                   w_top_inner = w_neigh  & 1 

                   nw_right_outer = (nw_neigh >> 5) & 1
                   nw_left_outer = (nw_neigh >> 3) & 1
                   n_left_outer = (n_neigh >> 3) & 1
                   n_right_outer = (n_neigh >> 5) & 1
                   e_left_outer = (e_neigh >> 3) & 1
                   e_top_outer = (e_neigh >> 1) & 1 
                   se_left_outer = (se_neigh >> 3) & 1
                   se_top_outer = (se_neigh >> 1) & 1 
                   s_right_outer = (s_neigh >> 5) & 1 
                   s_top_outer = (s_neigh >> 1) & 1
                   w_right_outer = (w_neigh >> 5) & 1
                   w_top_outer = (w_neigh >> 1) & 1

                  topcount_inner = cell_top_outer
                              + cell_left_inner + cell_right_inner + nw_right_inner + n_left_inner  // the four side cells
                              + w_right_inner + w_top_inner + nw_left_inner // the three corner cells to the west
                              + n_right_inner + e_top_inner + e_left_inner // the three corner cells to the east

                              + cell_left_outer + cell_right_outer + nw_right_outer + n_left_outer  // the four side cells
                              + w_right_outer + w_top_outer + nw_left_outer // the three corner cells to the west
                              + n_right_outer + e_top_outer + e_left_outer; // the three corner cells to the east

                   topcount_outer = cell_top_inner
                              + cell_left_inner + cell_right_inner + nw_right_inner + n_left_inner  // the four side cells
                              + w_right_inner + w_top_inner + nw_left_inner // the three corner cells to the west
                              + n_right_inner + e_top_inner + e_left_inner // the three corner cells to the east

                              + cell_left_outer + cell_right_outer + nw_right_outer + n_left_outer  // the four side cells
                              + w_right_outer + w_top_outer + nw_left_outer // the three corner cells to the west
                              + n_right_outer + e_top_outer + e_left_outer; // the three corner cells to the east

                   leftcount_inner = cell_left_outer
                                + cell_top_inner + cell_right_inner + s_top_inner + w_right_inner // the four side cells
                                + w_top_inner + nw_left_inner + nw_right_inner // the three corner cells to the top
                                + s_right_inner + se_left_inner + se_top_inner // the three corner cells to the bottom

                                + cell_top_outer + cell_right_outer + s_top_outer +  w_right_outer // the four side cells
                                + w_top_outer + nw_left_outer + nw_right_outer // the three corner cells to the top
                                + s_right_outer + se_left_outer + se_top_outer; // the three corner cells to the bottom

                   leftcount_outer = cell_left_inner
                                + cell_top_inner + cell_right_inner + s_top_inner + w_right_inner // the four side cells
                                + w_top_inner + nw_left_inner + nw_right_inner // the three corner cells to the top
                                + s_right_inner + se_left_inner + se_top_inner // the three corner cells to the bottom

                                + cell_top_outer + cell_right_outer + s_top_outer +  w_right_outer // the four side cells
                                + w_top_outer + nw_left_outer + nw_right_outer // the three corner cells to the top
                                + s_right_outer + se_left_outer + se_top_outer; // the three corner cells to the bottom

                   rightcount_inner = cell_right_outer
                                + cell_left_inner + cell_top_inner + e_left_inner + se_top_inner // the four side cells
                                + n_left_inner + n_right_inner + e_top_inner // the three corner cells to the top
                                +  s_top_inner +  s_right_inner + se_left_inner  // the three corner cells to the bottom

                                + cell_left_outer + cell_top_outer + e_left_outer + se_top_outer // the four side cells
                                + n_left_outer + n_right_outer + e_top_outer // the three corner cells to the top
                                +  s_top_outer +  s_right_outer + se_left_outer  // the three corner cells to the bottom
 
                   rightcount_outer = cell_right_inner
                                + cell_left_inner + cell_top_inner + e_left_inner + se_top_inner // the four side cells
                                + n_left_inner + n_right_inner + e_top_inner // the three corner cells to the top
                                +  s_top_inner +  s_right_inner + se_left_inner  // the three corner cells to the bottom

                                + cell_left_outer + cell_top_outer + e_left_outer + se_top_outer // the four side cells
                                + n_left_outer + n_right_outer + e_top_outer // the three corner cells to the top
                                +  s_top_outer +  s_right_outer + se_left_outer  // the three corner cells to the bottom   

                     if (cell_top_inner == 1) {newcell_top_inner = survivalrule[celdotcolor][topcount_inner]} 
                               else {newcell_top_inner = birthrule[celdotcolor][topcount_inner]};

                     if (cell_top_outer == 1) {newcell_top_outer = survivalrule[celdotcolor][topcount_outer]} 
                               else {newcell_top_outer = birthrule[celdotcolor][topcount_outer]};

                     if (cell_left_inner == 1) {newcell_left_inner = survivalrule[celdotcolor][leftcount_inner]} 
                               else {newcell_left_inner = birthrule[celdotcolor][leftcount_outer]};

                     if (cell_left_outer == 1) {newcell_left_outer = survivalrule[celdotcolor][leftcount_outer]} 
                               else {newcell_left_outer = birthrule[celdotcolor][leftcount_outer]};

                     if (cell_right_inner == 1) {newcell_right_inner = survivalrule[celdotcolor][rightcount_inner]} 
                               else {newcell_right_inner = birthrule[celdotcolor][rightcount_inner]};

                     if (cell_right_outer == 1) {newcell_right_outer = survivalrule[celdotcolor][rightcount_outer]} 
                               else {newcell_right_outer = birthrule[celdotcolor][rightcount_outer]};


                      cel.placeholder_extra = newcell_top_inner + (newcell_top_outer << 1) + (newcell_left_inner << 2) + (newcell_left_outer << 3) + (newcell_right_inner << 4) + (newcell_right_outer << 5)
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = celdotcolor} 
                      else {cel.placeholder_color = background}
                  break;


case 55:   // Snub Hexagonal Tiling --  Survival Case

                   cellist = cel.neighbors;
                   celdotextra = cel.extra


                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;


/* 
 19 states:

0 background
1 upward_left
2 upward_middle
3 upward_left_and_middle
4 upward_right
5 upward_left_and_right
6 upward_middle_and_right
7 upward_all_three

8 downward_left
9 downward_middle
10 downward_left_and_middle
11 downward_right
12 downward_left_and_right
13 downward_middle_and_right
14 downward_all_three

15 centersquare_left
16 centersquare_right
17 centersquare_both
18 hexagon
*/


/*  Here's how to access each kind of cell
cell_upward_left = celdotextra == 1 || celdotextra == 3 || celdotextra == 5 || celdotextra == 7
cell_upward_middle = celdotextra == 2 || celdotextra == 3 || celdotextra == 6 || celdotextra == 7
cell_upward_right =  celdotextra == 4 || celdotextra == 5 || celdotextra == 6 || celdotextra == 7 

cell_downward_left = celdotextra == 8 || celdotextra == 10 || celdotextra == 12 || celdotextra == 14 
cell_downward_middle = celdotextra == 9 || celdotextra == 10 || celdotextra == 13 || celdotextra == 14
cell_downward_right = celdotextra == 11 || celdotextra == 12 || celdotextra == 13 || celdotextra == 14 

cell_centersquare_left = celdotextra == 15 || celdotextra == 17 
cell_centersquare_right = celdotextra == 16 || celdotextra == 17 

cell_hexagon = (celdotextra  == 18)
*/


   // center squares
   if ((cel.ypos % 4 == 0 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 2 && cel.xpos % 2 == 1))  {
          cell_left = celdotextra == 15 || celdotextra == 17
          cell_right = celdotextra == 16 || celdotextra == 17
          nw_downward_right = nw_neigh == 11 || nw_neigh == 12 || nw_neigh == 13 || nw_neigh == 14  
          n_upward_left = n_neigh == 1 || n_neigh == 3 || n_neigh == 5 || n_neigh == 7
          n_upward_middle = n_neigh == 2 || n_neigh == 3 || n_neigh == 6 || n_neigh == 7
          n_upward_right = n_neigh == 4 || n_neigh == 5 || n_neigh == 6 || n_neigh == 7 
          w_hexagon = (w_neigh  == 18)
          e_hexagon =  (e_neigh  == 18)
          sw_upward_middle = sw_neigh == 2 || sw_neigh == 3 || sw_neigh == 6 || sw_neigh == 7
          sw_upward_right = sw_neigh == 4 || sw_neigh == 5 || sw_neigh == 6 || sw_neigh == 7 
          s_downward_left = s_neigh == 8 || s_neigh == 10 || s_neigh == 12 || s_neigh == 14 
          s_downward_middle =  s_neigh == 9 || s_neigh == 10 || s_neigh == 13 || s_neigh == 14
          
          
          leftcount = nw_downward_right + n_upward_left + w_hexagon + e_hexagon + cell_right + sw_upward_middle + sw_upward_right + s_downward_left + s_downward_middle
          rightcount = nw_downward_right + n_upward_left + n_upward_middle + n_upward_right + w_hexagon + e_hexagon + cell_left + s_downward_left + s_downward_middle

          // Apply Birth and Survive rules to each side of the cell
                   
                      if (cell_left == 1) {newcell_left = survivalrule[celdotcolor][leftcount]} 
                               else {newcell_left = birthrule[celdotcolor][leftcount]};
                      if (cell_right == 1) {newcell_right = survivalrule[celdotcolor][rightcount]} 
                              else {newcell_right = birthrule[celdotcolor][rightcount]};


                    // Now return the final cell value for left-right cells


                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 17; cel.placeholder_color = celdotcolor;} 
                        else {cel.placeholder_extra = 16; cel.placeholder_color = celdotcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 15; cel.placeholder_color = celdotcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                      };
                } // end section for split center square  cells

           // Hexagons
   else if ((cel.ypos % 4 == 2 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 0 && cel.xpos % 2 == 1))  {

               nw_upward_left = nw_neigh == 1 || nw_neigh == 3 || nw_neigh == 5 || nw_neigh == 7
               nw_upward_middle = nw_neigh == 2 || nw_neigh == 3 || nw_neigh == 6 || nw_neigh == 7
               nw_upward_right  =  nw_neigh == 4 || nw_neigh == 5 || nw_neigh == 6 || nw_neigh == 7 
               n_downward_left  = n_neigh == 8 || n_neigh == 10 || n_neigh == 12 || n_neigh == 14 
               n_downward_middle = n_neigh == 9 || n_neigh == 10 || n_neigh == 13 || n_neigh == 14
               n_downward_right = n_neigh == 11 || n_neigh == 12 || n_neigh == 13 || n_neigh == 14 
               ne_upward_left = ne_neigh == 1 || ne_neigh == 3 || ne_neigh == 5 || ne_neigh == 7
               w_centersquare_left = w_neigh == 15 || w_neigh == 17 
               w_centersquare_right  = w_neigh == 16 || w_neigh == 17 
               e_centersquare_left = e_neigh == 15 || e_neigh == 17 
               e_centersquare_right = e_neigh == 16 || e_neigh == 17
               sw_downward_left  = sw_neigh == 8 || sw_neigh == 10 || sw_neigh == 12 || sw_neigh == 14 
               sw_downward_middle  = sw_neigh == 9 || sw_neigh == 10 || sw_neigh == 13 || sw_neigh == 14
               sw_downward_right = sw_neigh == 11 || sw_neigh == 12 || sw_neigh == 13 || sw_neigh == 14 
               s_upward_left = s_neigh == 1 || s_neigh == 3 || s_neigh == 5 || s_neigh == 7
               s_upward_middle = s_neigh == 2 || s_neigh == 3 || s_neigh == 6 || s_neigh == 7
               s_upward_right =  s_neigh == 4 || s_neigh == 5 || s_neigh == 6 || s_neigh == 7 
               se_downward_left  = se_neigh == 8 || se_neigh == 10 || se_neigh == 12 || se_neigh == 14 

             mycount = nw_upward_left + nw_upward_middle + nw_upward_right + n_downward_left + n_downward_middle + n_downward_right + ne_upward_left + w_centersquare_left + w_centersquare_right +  e_centersquare_left + e_centersquare_right + sw_downward_left + sw_downward_middle + sw_downward_right + s_upward_left + s_upward_middle + s_upward_right + se_downward_left
                      
                  if (survivalrule[celdotcolor][mycount]) {cel.placeholder_color = celdotcolor; cel.placeholder_extra = 18} 
                  else {cel.placeholder_color = background; cel.placeholder_extra = 0};

      } // end section for Hexagons
     //   Upward Trio above the central square
 else if ((cel.ypos % 4 == 3 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 1 && cel.xpos % 2 == 1))   {

               cell_upward_left = celdotextra == 1 || celdotextra == 3 || celdotextra == 5 || celdotextra == 7
               cell_upward_middle = celdotextra == 2 || celdotextra == 3 || celdotextra == 6 || celdotextra == 7
               cell_upward_right =  celdotextra == 4 || celdotextra == 5 || celdotextra == 6 || celdotextra == 7  

               n_hexagon = (n_neigh  == 18)
               ne_centersquare_left = ne_neigh == 15 || ne_neigh == 17 
               w_downward_middle = w_neigh == 9 || w_neigh == 10 || w_neigh == 13 || w_neigh == 14
               w_downward_right = w_neigh == 11 || w_neigh == 12 || w_neigh == 13 || w_neigh == 14 
               sw_hexagon = (sw_neigh  == 18)
               s_centersquare_left = s_neigh == 15 || s_neigh == 17 
               s_centersquare_right = s_neigh == 16 || s_neigh == 17 
               se_hexagon = (se_neigh  == 18) 
               e_downward_left = e_neigh == 8 || e_neigh == 10 || e_neigh == 12 || e_neigh == 14 
               e_downward_middle = e_neigh == 9 || e_neigh == 10 || e_neigh == 13 || e_neigh == 14
               e_downward_right = e_neigh == 11 || e_neigh == 12 || e_neigh == 13 || e_neigh == 14 

               leftcount = n_hexagon + w_downward_middle + w_downward_right + cell_upward_middle + cell_upward_right + sw_hexagon + s_centersquare_left + s_centersquare_right + se_hexagon
               middlecount = n_hexagon + ne_centersquare_left + w_downward_middle + w_downward_right + cell_upward_left + cell_upward_right + e_downward_left + s_centersquare_right + se_hexagon
               rightcount =  n_hexagon + ne_centersquare_left + cell_upward_left + cell_upward_middle + e_downward_left + e_downward_middle + e_downward_right + s_centersquare_right + se_hexagon
 
                      if (cell_upward_right == 1) { newcell_upward_right = survivalrule[celdotcolor][rightcount]}
                      else  { newcell_upward_right = birthrule[celdotcolor][rightcount]  }

                      if (cell_upward_left == 1) { newcell_upward_left = survivalrule[celdotcolor][leftcount]}
                      else  { newcell_upward_left = birthrule[celdotcolor][leftcount]  }


                      if (cell_upward_middle == 1) { newcell_upward_middle = survivalrule[celdotcolor][middlecount]}
                      else  { newcell_upward_middle = birthrule[celdotcolor][middlecount]  }

                      // For upward, this works:
                         // surivial case:
                      cel.placeholder_extra = newcell_upward_left + (newcell_upward_middle << 1) + (newcell_upward_right << 2)                           
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = celdotcolor} 
                      else {cel.placeholder_color = background}

      } // end section for Upward Trio


     //   section for Downwards Trio, above the hexagon
  else if ((cel.ypos % 4 == 1 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 3 && cel.xpos % 2 == 1))  {

               cell_downward_left = celdotextra == 8 || celdotextra == 10 || celdotextra == 12 || celdotextra == 14 
               cell_downward_middle = celdotextra == 9 || celdotextra == 10 || celdotextra == 13 || celdotextra == 14
               cell_downward_right = celdotextra == 11 || celdotextra == 12 || celdotextra == 13 || celdotextra == 14 


                  nw_hexagon = (nw_neigh  == 18)
                  n_centersquare_left = n_neigh == 15 || n_neigh == 17 
                  n_centersquare_right = n_neigh == 16 || n_neigh == 17 
                  ne_hexagon = (ne_neigh  == 18)
                  w_upward_middle = w_neigh == 2 || w_neigh == 3 || w_neigh == 6 || w_neigh == 7
                  w_upward_right =  w_neigh == 4 || w_neigh == 5 || w_neigh == 6 || w_neigh == 7 
                  s_hexagon = (s_neigh  == 18) 
                  e_upward_left = e_neigh == 1 || e_neigh == 3 || e_neigh == 5 || e_neigh == 7
                  e_upward_middle = e_neigh == 2 || e_neigh == 3 || e_neigh == 6 || e_neigh == 7
                 se_centersquare_left = se_neigh == 15 || se_neigh == 17 
                 se_centersquare_right  = se_neigh == 16 || se_neigh == 17  

               leftcount = nw_hexagon + n_centersquare_left + n_centersquare_right + ne_hexagon + w_upward_middle + w_upward_right + cell_downward_middle + cell_downward_right + s_hexagon
               middlecount = n_centersquare_left + n_centersquare_right + ne_hexagon + w_upward_right + cell_downward_left + cell_downward_right +  e_upward_left + e_upward_middle + s_hexagon
               rightcount = ne_hexagon + w_upward_right + cell_downward_left + cell_downward_middle + e_upward_left + e_upward_middle + s_hexagon + se_centersquare_left + se_centersquare_right


                      if (cell_downward_right == 1) { newcell_downward_right = survivalrule[celdotcolor][rightcount]}
                      else  { newcell_downward_right = birthrule[celdotcolor][rightcount]  }

                      if (cell_downward_left == 1) { newcell_downward_left = survivalrule[celdotcolor][leftcount]}
                      else  { newcell_downward_left = birthrule[celdotcolor][leftcount]  }


                      if (cell_downward_middle == 1) { newcell_downward_middle = survivalrule[celdotcolor][middlecount]}
                      else  { newcell_downward_middle = birthrule[celdotcolor][middlecount]  }


                       cel.placeholder_extra = 7 + newcell_downward_left + (newcell_downward_middle << 1) + (newcell_downward_right << 2)                         
                      if (cel.placeholder_extra > 7) {cel.placeholder_color = celdotcolor} 
                      else {cel.placeholder_color = background; cel.placeholder_extra = 0}

/*
                      // for downward, we have to resort to this:
                              // adapted from the Rhombus("Qbert") code, warts and all
                         if (newcell_downward_left == 0 && newcell_downward_middle == 0 && newcell_downward_right == 0) 
                            {cel.placeholder_extra = 0; cel.placeholder_color = background;} 
                         else if (newcell_downward_left == 1 && newcell_downward_middle == 0 && newcell_downward_right == 0) 
                            {cel.placeholder_extra = 8; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_downward_left == 0 && newcell_downward_middle == 1 && newcell_downward_right == 0) 
                            {cel.placeholder_extra = 9; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_downward_left == 0 && newcell_downward_middle == 0 && newcell_downward_right == 1) 
                            {cel.placeholder_extra = 11; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_downward_left == 1 && newcell_downward_middle == 0 && newcell_downward_right == 1) 
                            {cel.placeholder_extra = 12; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_downward_left == 0 && newcell_downward_middle == 1 && newcell_downward_right == 1) 
                            {cel.placeholder_extra = 13; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_downward_left == 1 && newcell_downward_middle == 1 && newcell_downward_right == 0) 
                            {cel.placeholder_extra = 10; cel.placeholder_color = celdotcolor;} 
                         else if (newcell_downward_left == 1 && newcell_downward_middle == 1 && newcell_downward_right == 1) 
                            {cel.placeholder_extra = 14; cel.placeholder_color = celdotcolor;} 
*/

      } // end section for Downward Trio
  break;




        case 56:  
                       //  Kisrhombile Tiling  -- Survival case

                    // Just like  Deltoidal TriHexagonal (Kites) but split each cell into "leading" and "following"               
              

                   cellist = cel.neighbors;


                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   // ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   // sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;



                   celdotextra = cel.extra

                   cell_top_left_leading = celdotextra & 1
                   cell_top_right_leading  = (celdotextra >> 1) & 1
                   cell_mid_left_leading = (celdotextra >> 2) & 1
                   cell_mid_right_leading  = (celdotextra >> 3) & 1
                   cell_bot_left_leading = (celdotextra >> 4) & 1
                   cell_bot_right_leading  = (celdotextra >> 5) & 1

                   cell_top_left_trailing = ( celdotextra  >> ( 0  + 6 ))& 1
                   cell_top_right_trailing  = (celdotextra  >> ( 1 + 6 )) & 1
                   cell_mid_left_trailing = (celdotextra  >> ( 2 + 6 )) & 1
                   cell_mid_right_trailing  = (celdotextra  >> ( 3 + 6 )) & 1
                   cell_bot_left_trailing = (celdotextra  >> ( 4 + 6 )) & 1
                   cell_bot_right_trailing  = (celdotextra  >> ( 5 + 6 )) & 1


                   nw_bot_left_leading = (nw_neigh >> 4) & 1
                   nw_bot_right_leading  = (nw_neigh >> 5) & 1
                   w_bot_right_leading   = (w_neigh >> 5) & 1
                   w_mid_right_leading  = (w_neigh >> 3) & 1  
                   n_mid_left_leading = (n_neigh >> 2) & 1
                   n_bot_left_leading = (n_neigh >> 4) & 1
                   e_top_left_leading = e_neigh & 1
                   e_mid_left_leading = (e_neigh >> 2) & 1
                   se_top_right_leading   = (se_neigh >> 1) & 1
                   se_top_left_leading  = se_neigh & 1
                   s_mid_right_leading   = (s_neigh >> 3) & 1
                   s_top_right_leading  = (s_neigh >> 1) & 1

                   nw_bot_left_trailing = (nw_neigh  >> ( 4 + 6 )) & 1
                   nw_bot_right_trailing  = (nw_neigh  >> ( 5 + 6 )) & 1
                   w_bot_right_trailing   = (w_neigh  >> ( 5 + 6 )) & 1
                   w_mid_right_trailing  = (w_neigh  >> ( 3 + 6 )) & 1  
                   n_mid_left_trailing = (n_neigh  >> ( 2 + 6 )) & 1
                   n_bot_left_trailing = (n_neigh  >> ( 4 + 6 )) & 1
                   e_top_left_trailing = (e_neigh >> (0 + 6)) & 1
                   e_mid_left_trailing = (e_neigh  >> ( 2 + 6 )) & 1
                   se_top_right_trailing   = (se_neigh  >> ( 1 + 6 )) & 1
                   se_top_left_trailing  = (se_neigh >> (0 + 6)) & 1
                   s_mid_right_trailing   = (s_neigh  >> ( 3 + 6 )) & 1
                   s_top_right_trailing  = (s_neigh  >> ( 1 + 6 )) & 1


                  top_leftcount_leading = cell_top_left_trailing 
                                           + cell_top_right_trailing +  cell_mid_left_trailing +  w_mid_right_trailing +  nw_bot_left_trailing
                                           + cell_mid_right_trailing +  cell_bot_left_trailing + cell_bot_right_trailing + cell_top_right_leading
                                           +  cell_mid_left_leading +  w_mid_right_leading +  nw_bot_left_leading + nw_bot_right_leading 
                                           +  cell_mid_right_leading +  cell_bot_left_leading +  cell_bot_right_leading

                  top_leftcount_trailing = cell_top_left_leading
                                           + cell_top_right_trailing +  cell_mid_left_trailing + w_mid_right_trailing + nw_bot_left_trailing 
                                           + cell_mid_right_trailing + cell_bot_left_trailing + cell_bot_right_trailing +   w_bot_right_trailing
                                           +  cell_top_right_leading + cell_mid_left_leading + w_mid_right_leading +  nw_bot_left_leading 
                                           + cell_mid_right_leading + cell_bot_left_leading + cell_bot_right_leading

                 top_rightcount_leading =  cell_top_right_trailing
                                            + cell_top_left_leading + cell_mid_right_leading  + n_mid_left_leading + nw_bot_right_leading + n_bot_left_leading 
                                            + cell_bot_right_leading  + cell_bot_left_leading + cell_mid_left_leading + cell_top_left_trailing 
                                            + cell_mid_right_trailing  + n_mid_left_trailing + nw_bot_right_trailing + cell_bot_right_trailing 
                                            + cell_bot_left_trailing + cell_mid_left_trailing  


                  top_rightcount_trailing = cell_top_right_leading
                                   + cell_top_left_leading + cell_mid_right_leading  + n_mid_left_leading + nw_bot_right_leading 
                                  + cell_bot_right_leading  + cell_bot_left_leading + cell_mid_left_leading    
                                  + cell_top_left_trailing + cell_mid_right_trailing  + n_mid_left_trailing + nw_bot_right_trailing 
                                  + cell_bot_right_trailing  + cell_bot_left_trailing + cell_mid_left_trailing + nw_bot_left_trailing


                  mid_rightcount_leading  = cell_mid_right_trailing 
                                   + cell_top_right_leading  + cell_bot_right_leading  + n_bot_left_leading + e_top_left_leading
                                  + e_mid_left_leading  + cell_bot_left_leading + cell_mid_left_leading + cell_top_left_leading   
                                  +  cell_top_right_trailing  + cell_bot_right_trailing  + n_bot_left_trailing + e_top_left_trailing
                                   + cell_bot_left_trailing + cell_mid_left_trailing + cell_top_left_trailing    


                  mid_rightcount_trailing  = cell_mid_right_leading
                                   + cell_top_right_leading  + cell_bot_right_leading  + n_bot_left_leading + e_top_left_leading
                                   + cell_bot_left_leading + cell_mid_left_leading + cell_top_left_leading  
                                   + cell_top_right_trailing  + cell_bot_right_trailing  + n_bot_left_trailing + e_top_left_trailing
                                   + cell_bot_left_trailing + cell_mid_left_trailing + cell_top_left_trailing + n_mid_left_trailing  

              mid_leftcount_leading  =  cell_mid_left_trailing
                                  + cell_top_left_leading + cell_bot_left_leading + s_top_right_leading  + w_bot_right_leading 
                                  + w_mid_right_leading  +  cell_top_right_leading  + cell_mid_right_leading  + cell_bot_right_leading    
                                  + cell_top_left_trailing + cell_bot_left_trailing + s_top_right_trailing  + w_bot_right_trailing 
                                  +  cell_top_right_trailing  + cell_mid_right_trailing  + cell_bot_right_trailing   

                  mid_leftcount_trailing  =  cell_mid_left_leading
                                   + cell_top_left_leading + cell_bot_left_leading + s_top_right_leading  + w_bot_right_leading 
                                   +  cell_top_right_leading  + cell_mid_right_leading  + cell_bot_right_leading  
                                   + cell_top_left_trailing + cell_bot_left_trailing + s_top_right_trailing  + w_bot_right_trailing 
                                   +  cell_top_right_trailing  + cell_mid_right_trailing  + cell_bot_right_trailing   + s_mid_right_trailing  


                  bot_rightcount_leading  = cell_bot_right_trailing
                                  + cell_mid_right_leading  + cell_bot_left_leading + e_mid_left_leading + se_top_right_leading 
                                 +  se_top_left_leading +  + cell_mid_left_leading + cell_top_left_leading + cell_top_right_leading   
                                 + cell_mid_right_trailing  + cell_bot_left_trailing + e_mid_left_trailing + se_top_right_trailing 
                                      + cell_mid_left_trailing + cell_top_left_trailing + cell_top_right_trailing  

                 bot_rightcount_trailing  = cell_bot_right_leading
                                    + cell_mid_right_leading  + cell_bot_left_leading + e_mid_left_leading + se_top_right_leading 
                                    + cell_mid_left_leading + cell_top_left_leading + cell_top_right_leading   
                                    + cell_mid_right_trailing  + cell_bot_left_trailing + e_mid_left_trailing + se_top_right_trailing 
                                    + cell_mid_left_trailing + cell_top_left_trailing + cell_top_right_trailing  +  e_top_left_trailing  

                  bot_leftcount_leading  =  cell_bot_left_trailing
                                 + cell_mid_left_leading + cell_bot_right_leading  + s_mid_right_leading  + se_top_left_leading
                                 +  s_top_right_leading    + cell_top_right_leading  + cell_top_left_leading + cell_mid_right_leading  
                                 + cell_mid_left_trailing + cell_bot_right_trailing  + s_mid_right_trailing  + se_top_left_trailing
                                 + cell_top_right_trailing  + cell_top_left_trailing + cell_mid_right_trailing  

                  bot_leftcount_trailing  =  cell_bot_left_leading
                                     + cell_mid_left_leading + cell_bot_right_leading  + s_mid_right_leading  + se_top_left_leading
                                     + cell_top_right_leading  + cell_top_left_leading + cell_mid_right_leading 
                                     + cell_mid_left_trailing + cell_bot_right_trailing  + s_mid_right_trailing  + se_top_left_trailing
                                     + se_top_right_trailing  + cell_top_right_trailing  + cell_top_left_trailing + cell_mid_right_trailing  


                     if (cell_top_left_leading == 1) {newcell_top_left_leading = survivalrule[celdotcolor][top_leftcount_leading ]} 
                               else {newcell_top_left_leading = birthrule[celdotcolor][top_leftcount_leading ]};

                     if (cell_top_right_leading == 1) {newcell_top_right_leading = survivalrule[celdotcolor][top_rightcount_leading ]} 
                               else {newcell_top_right_leading = birthrule[celdotcolor][top_rightcount_leading ]};

                     if (cell_mid_left_leading == 1) {newcell_mid_left_leading = survivalrule[celdotcolor][mid_leftcount_leading ]} 
                               else {newcell_mid_left_leading = birthrule[celdotcolor][mid_leftcount_leading ]};

                     if (cell_mid_right_leading == 1) {newcell_mid_right_leading = survivalrule[celdotcolor][mid_rightcount_leading ]} 
                               else {newcell_mid_right_leading = birthrule[celdotcolor][mid_rightcount_leading ]};

                     if (cell_bot_left_leading == 1) {newcell_bot_left_leading = survivalrule[celdotcolor][bot_leftcount_leading ]} 
                               else {newcell_bot_left_leading = birthrule[celdotcolor][bot_leftcount_leading ]};

                     if (cell_bot_right_leading == 1) {newcell_bot_right_leading = survivalrule[celdotcolor][bot_rightcount_leading ]} 
                               else {newcell_bot_right_leading = birthrule[celdotcolor][bot_rightcount_leading ]};


                     if (cell_top_left_trailing == 1) {newcell_top_left_trailing = survivalrule[celdotcolor][top_leftcount_trailing ]} 
                               else {newcell_top_left_trailing = birthrule[celdotcolor][top_leftcount_trailing ]};

                     if (cell_top_right_trailing == 1) {newcell_top_right_trailing = survivalrule[celdotcolor][top_rightcount_trailing ]} 
                               else {newcell_top_right_trailing = birthrule[celdotcolor][top_rightcount_trailing ]};

                     if (cell_mid_left_trailing == 1) {newcell_mid_left_trailing = survivalrule[celdotcolor][mid_leftcount_trailing ]} 
                               else {newcell_mid_left_trailing = birthrule[celdotcolor][mid_leftcount_trailing ]};

                     if (cell_mid_right_trailing == 1) {newcell_mid_right_trailing = survivalrule[celdotcolor][mid_rightcount_trailing ]} 
                               else {newcell_mid_right_trailing = birthrule[celdotcolor][mid_rightcount_trailing ]};

                     if (cell_bot_left_trailing == 1) {newcell_bot_left_trailing = survivalrule[celdotcolor][bot_leftcount_trailing ]} 
                               else {newcell_bot_left_trailing = birthrule[celdotcolor][bot_leftcount_trailing ]};

                     if (cell_bot_right_trailing == 1) {newcell_bot_right_trailing = survivalrule[celdotcolor][bot_rightcount_trailing ]} 
                               else {newcell_bot_right_trailing = birthrule[celdotcolor][bot_rightcount_trailing ]};

                    cel.placeholder_extra = newcell_top_left_leading + (newcell_top_right_leading << 1) + (newcell_mid_left_leading << 2) + (newcell_mid_right_leading << 3) + (newcell_bot_left_leading << 4) + (newcell_bot_right_leading << 5) + (newcell_top_left_trailing << (6 +  0))  + (newcell_top_right_trailing << (6 +  1)) + (newcell_mid_left_trailing << (6 +  2)) + (newcell_mid_right_trailing << (6 +  3)) + (newcell_bot_left_trailing << (6 +  4)) + (newcell_bot_right_trailing << (6 +  5))

                      if (cel.placeholder_extra > 0) {cel.placeholder_color = celdotcolor} 
                      else {cel.placeholder_color = background}
                  break;

case 57:   // Penta-668 Alternating Penta peace signs -- Survival case 
                      cellist = cel.neighbors;
                      nw_neigh = cellist[0].extra;
                      n_neigh = cellist[1].extra;
                      ne_neigh = cellist[2].extra;
                      w_neigh = cellist[3].extra;
                      e_neigh = cellist[4].extra;
                      sw_neigh = cellist[5].extra;
                      s_neigh = cellist[6].extra;
                      se_neigh = cellist[7].extra;
                      celdotextra = cel.extra


                     //if celltype = "bottomish":
// ( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 2 == 0) || ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 2 == 1)
                    if ((cel.xpos % 2 == 0 && cel.ypos % 2 == 0) || (cel.xpos % 2 == 1 && cel.ypos % 2 == 1))   {

  /*
                         cell_bottom =     (celdotextra  - 7) & 1
                         cell_topleft =    ((celdotextra - 7) >> 1) & 1
                         cell_topright =   ((celdotextra - 7) >> 2) & 1

                        nw_bottom =  (nw_neigh  - 7) & 1
                         w_botright =  (w_neigh >> 2) & 1
                         s_top =  s_neigh & 1
                        s_botright = (s_neigh >> 2) & 1
                         n_botleft =  (n_neigh >> 1) & 1
                         e_top =  e_neigh & 1
                         e_botleft =  (e_neigh >> 1) & 1
                         se_topleft =  ((se_neigh - 7) >> 1) & 1 
                         se_topright = ((se_neigh - 7) >> 2) & 1
 */

                         cell_bottom =     (celdotextra == 8) || (celdotextra == 10) || (celdotextra == 12) || (celdotextra == 14)
                         cell_topleft =    (celdotextra == 9) || (celdotextra == 10) || (celdotextra == 13) || (celdotextra == 14)
                         cell_topright =    (celdotextra == 11) || (celdotextra == 12) || (celdotextra == 13) || (celdotextra == 14)

                        nw_bottom =  (nw_neigh == 8) || (nw_neigh == 10) || (nw_neigh == 12) || (nw_neigh == 14)
                        w_botright =  (w_neigh == 4) || (w_neigh == 5) || (w_neigh == 6) || (w_neigh == 7)
                        s_top =  (s_neigh == 1) || (s_neigh == 3) || (s_neigh == 5) || (s_neigh == 7)
                        s_botright = (s_neigh == 4) || (s_neigh == 5) || (s_neigh == 6) || (s_neigh == 7)
                        n_botleft =  (n_neigh == 2) || (n_neigh  == 3) || (n_neigh  == 6) || (n_neigh  == 7)
                        e_top =  (e_neigh == 1) || (e_neigh == 3) || (e_neigh == 5) || (e_neigh == 7)
                        e_botleft =  (e_neigh == 2) || (e_neigh  == 3) || (e_neigh  == 6) || (e_neigh  == 7)
                        se_topleft = (se_neigh == 9) || (se_neigh == 10) || (se_neigh == 13) || (se_neigh == 14)
                        se_topright = (se_neigh == 11) || (se_neigh == 12) || (se_neigh == 13) || (se_neigh == 14)





                          topleftcount = nw_bottom + w_botright + cell_topright + cell_bottom + s_top + s_botright
                          toprightcount = nw_bottom + n_botleft + cell_topleft + cell_bottom + e_top + e_botleft
                          botcount = cell_topleft + cell_topright + e_top + e_botleft + s_top + s_botright + se_topleft + se_topright
   
   
                      if (cell_bottom == 1) {newcell_bottom = survivalrule[celdotcolor][botcount]} 
                               else {newcell_bottom = birthrule[celdotcolor][botcount]};

                      if (cell_topright == 1) {newcell_topright = survivalrule[celdotcolor][toprightcount]} 
                               else {newcell_topright = birthrule[celdotcolor][toprightcount]};

                      if (cell_topleft == 1) {newcell_topleft= survivalrule[celdotcolor][topleftcount]} 
                               else {newcell_topleft = birthrule[celdotcolor][topleftcount]};


                      cel.placeholder_extra = 7 + newcell_bottom + (newcell_topleft << 1) + (newcell_topright << 2);                          
                      if (cel.placeholder_extra > 7) {cel.placeholder_color = celdotcolor} 
                      else {cel.placeholder_color = background; cel.placeholder_extra = 0};
                 }

                       //if celltype == "topish":
                else {  
                   /*
                         cell_top = celdotextra & 1
                         cell_botleft = (celdotextra >> 1) & 1
                         cell_botright = (celdotextra >> 2) & 1

                         e_topleft =   ((e_neigh - 7) >> 1) & 1
                         se_top =   se_neigh & 1
                         s_topright = ((s_neigh - 7) >> 2) & 1
                         nw_botleft =  (nw_neigh >> 1) & 1
                         nw_botright =  (nw_neigh >> 2) & 1
                         n_topleft =   ((n_neigh - 7) >> 1) & 1
                         n_bottom =  (n_neigh  - 7) & 1
                         w_topright =  ((w_neigh - 7) >> 2) & 1
                         w_bottom =  (w_neigh  - 7) & 1
                   */


                         cell_top = (celdotextra == 1) || (celdotextra == 3) || (celdotextra == 5) || (celdotextra == 7)
                         cell_botleft = (celdotextra == 2) || (celdotextra == 3) || (celdotextra == 6) || (celdotextra == 7)
                         cell_botright = (celdotextra == 4) || (celdotextra == 5) || (celdotextra == 6) || (celdotextra == 7)

                         e_topleft =  (e_neigh == 9) || (e_neigh == 10) || (e_neigh == 13) || (e_neigh == 14)
                         se_top =   (se_neigh == 1) || (se_neigh == 3) || (se_neigh == 5) || (se_neigh == 7)
                         s_topright = (s_neigh == 11) || (s_neigh == 12) || (s_neigh == 13) || (s_neigh == 14)
                         nw_botleft = (nw_neigh == 2) || (nw_neigh == 3) || (nw_neigh == 6) || (nw_neigh == 7)
                         nw_botright =  (nw_neigh == 4) || (nw_neigh == 5) || (nw_neigh == 6) || (nw_neigh == 7)
                         n_topleft =   (n_neigh == 9) || (n_neigh == 10) || (n_neigh == 13) || (n_neigh == 14)
                         n_bottom =   (n_neigh == 8) || (n_neigh == 10) || (n_neigh == 12) || (n_neigh == 14)
                         w_topright =  (w_neigh  == 11) || (w_neigh  == 12) || (w_neigh  == 13) || (w_neigh  == 14)
                         w_bottom =  (w_neigh == 8) || (w_neigh == 10) || (w_neigh == 12) || (w_neigh == 14)






                            botrightcount = n_topleft + n_bottom + cell_top + cell_botleft + e_topleft + se_top
                            botleftcount = w_topright + w_bottom + cell_top + cell_botright + se_top + s_topright
                            topcount =  nw_botleft + nw_botright + n_topleft + n_bottom + cell_botleft + cell_botright + w_topright + w_bottom


                      if (cell_top == 1) {newcell_top = survivalrule[celdotcolor][topcount]} 
                               else {newcell_top = birthrule[celdotcolor][topcount]};

                      if (cell_botright == 1) {newcell_botright = survivalrule[celdotcolor][botrightcount]} 
                               else {newcell_botright = birthrule[celdotcolor][botrightcount]};

                      if (cell_botleft == 1) {newcell_botleft = survivalrule[celdotcolor][botleftcount]} 
                               else {newcell_botleft = birthrule[celdotcolor][botleftcount]};


                      cel.placeholder_extra = newcell_top + (newcell_botleft << 1) + (newcell_botright << 2)                           
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = celdotcolor} 
                      else {cel.placeholder_color = background}
            } // end if-then statement
                  break;   


        case 16 :    cellist = cel.neighbors;
                    len = weightrule[celdotcolor][0]*bx2(cellist[0]) + weightrule[celdotcolor][1]*bx2(cellist[1]) + weightrule[celdotcolor][2]*bx2(cellist[2]) 
                          + weightrule[celdotcolor][3]*bx2(cellist[3]) + weightrule[celdotcolor][4]*bx2(cellist[4]) + weightrule[celdotcolor][5]*bx2(cellist[5]) 
                          + weightrule[celdotcolor][6]*bx2(cellist[6]) + weightrule[celdotcolor][7]*bx2(cellist[7]) ;

                     if (cel.extra ==  1) { 
                             if (birthrule[celdotcolor][len]) {
                                 cel.placeholder_color = celdotcolor; 
                                 cel.placeholder_extra = 2;
                             }
                            else {
                                cel.placeholder_color = background; 
                                cel.placeholder_extra = 0
                            }
                     }
                     else if (cel.extra == 2) {
                             if (survivalrule[celdotcolor][len]) {
                                 cel.placeholder_color = celdotcolor; 
                                 cel.placeholder_extra = 2
                                
                              } 
                            else {
                                cel.placeholder_color = background; 
                                cel.placeholder_extra = 0
                            }
                      }
                 break;


          
 

                 } // end of switch
    } // end of if section
    else {
         // for rulecode 0 & 11 the following pre-switch code may not be optimal
      cellist = cel.neighbors;
      //majcolor = getmajoritycolor(cellist)
            //************************************* the following way to determine majcolor is simpliflying assumption for speed that may not always be true if other code changes 

      switch (len) {
       case 0:  majcolor = background; 
                cel.placeholder_color = background;  // perhaps this can be undone, if need be, by the switch statement.   It will only be undone in the case of Larger Than Life...
               // cel.decayval = 0;
             // majcolor = blue;   // it may be faster in chrome to leave this line as the active one.
                 // if rulecode[background] was a case that meant something below, majcolor could be set to background.  Could that allow yellow larger than life Bugs???
                                  // rulecode[background] could usually be set to zero or -1 and just directly set placholder_color to background, 
                                //   but when a color is set to "Bugs", rulecode[background] could be set  to the Bugs rulecode. (thus slowing everyone else down, same as before)
                     // Hmmm, weird!  I set it to background and there are no errors, (and maybe no performance change?)
                      // this is confusing - why doesn't placeholder need to be set?!  Because it was set last time.
                 // what about B0 rules?   set rulecode[background] to the appropriate B0 rule code?  Or no, because B0's become non-B0 alternating rules anyway.  They do seem to work.
                break;
       // case 1:    majcolor =  cellist[0].color +  cellist[1].color +  cellist[2].color +  cellist[3].color +  cellist[4].color +  cellist[5].color +  cellist[6].color +  cellist[7].color;
       //            if (majcolor == decaygray){majcolor = blue} // {majcolor = background; cel.placeholder_color = background;  };  // seems to only fire for generations rules given velocity
                 // majcolor =  getSingleNeighborColor(cellist);
        //       break;
       default: majcolor = getmajoritycolor(cellist);
       }

      switch (rulecode[majcolor]) {
         case -1:   break;
         case 1:   if (birthrule[majcolor][len] ) {cel.placeholder_color = majcolor;
                                                   if (physicsOn) {//velocitybirth(cel, len)
                                                                   Decay_velocitybirth(cel, len);  // slower but should be slightly more accurate 
                                                                   };
                                                   } 
                   else {cel.placeholder_color = background}; 
                   break;   
         case 2:  if (oddgeneration_p) { 
                      if (oddbirthrule[majcolor][len] ) {cel.placeholder_color = majcolor;
                                                       //  *********  if (physicsOn) {velocitybirth(cel, len)};
                                                   } 
                       else {cel.placeholder_color = background}; 
                   } 
                   else {
                       if (evenbirthrule[majcolor][len] ) {cel.placeholder_color = majcolor;
                                                     //********* if (physicsOn) {velocitybirth(cel, len)};
                                                   } 
                       else {cel.placeholder_color = background}; 
                   };
                   break;

         case 3:    if (cellist[2].color != background && cel.neighbors[2].color != decaygray) {len -= 1};   // what about decaygray?!   This shortcut should be equivalent to case 8 weighted life
                    if (cellist[5].color != background && cel.neighbors[5].color != decaygray) {len -= 1};
                    if (birthrule[majcolor][len] ) {cel.placeholder_color = majcolor;
                                                     if (physicsOn) {//Hex_velocitybirth (cel, len);
                                                                    Decay_Hex_velocitybirth(cel, len);
                                                                    };
                                                     } 
                     else {cel.placeholder_color = background}; 
                     break;   
         case 4:    if (cellist[2].color != background && cel.neighbors[2].color != decaygray) {len -= 1};  // what about decaygray?!
                    if (cellist[5].color != background && cel.neighbors[5].color != decaygray) {len -= 1};
                    if (oddgeneration_p) { 
                      if (oddbirthrule[majcolor][len] ) {cel.placeholder_color = majcolor;
                                                     //************ if (physicsOn) {Hex_velocitybirth (cel, len)};
                                                   } 
                       else {cel.placeholder_color = background}; 
                   } 
                   else {
                       if (evenbirthrule[majcolor][len] ) {cel.placeholder_color = majcolor;
                                                     //************ if (physicsOn) {velocitybirth(cel, len)};
                                                   } 
                       else {cel.placeholder_color = background}; 
                   };
                   break;

         case 5:   
                  if (cel.neighbors[2].color != background && cel.neighbors[2].color != decaygray) {len -= 1}; 
                  if (cel.neighbors[5].color != background && cel.neighbors[5].color != decaygray) {len -= 1};
                  //   if (cel.neighbors[2].color != background ) {len -= 1}; 
                  //   if (cel.neighbors[5].color != background ) {len -= 1};

                   if (birthrule[majcolor][len] ) {cel.placeholder_color = majcolor;  
                                                   if (physicsOn) {Decay_Hex_velocitybirth  (cel, len)  };
                                                   } 
                   else {cel.placeholder_color = background}; 
                   break;   
         case 6:   
                    if (birthrule[majcolor][len] ) {cel.placeholder_color = majcolor;
                                                  //  cel.decayval = 0; // bagel
                                                    if (physicsOn) {    Decay_velocitybirth(cel, len);
                                                                };
                                                   } 
                   else {cel.placeholder_color = background}; 
                   break;

         case 8:   unweighted_len = len;

                   len = weightrule[majcolor][0]*c1(cellist[0]) + weightrule[majcolor][1]*c1(cellist[1]) + weightrule[majcolor][2]*c1(cellist[2]) 
                        + weightrule[majcolor][3]*c1(cellist[3]) + weightrule[majcolor][4]*c1(cellist[4]) + weightrule[majcolor][5]*c1(cellist[5]) 
                        + weightrule[majcolor][6]*c1(cellist[6]) + weightrule[majcolor][7]*c1(cellist[7]) ;
                   if (birthrule[majcolor][len] ) {cel.placeholder_color = majcolor;
                                                    if (physicsOn) {velocitybirth(cel, unweighted_len);
                                                                    // Decay_velocitybirth ...
                                                                     };
                                                   } 
                   else {cel.placeholder_color = background};                    
                   break;



                   // **********************  if Decay_velocitybirth works ***********
                 // case 9 should get an unweighted len + Decay_velocitybirth  also make a HexDecay_velocity birth for case 5 and others.
                // ******** delete this comment when it is all done ***********************


          case 9: len = weightrule[majcolor][0]*c1(cellist[0]) + weightrule[majcolor][1]*c1(cellist[1]) + weightrule[majcolor][2]*c1(cellist[2]) 
                        + weightrule[majcolor][3]*c1(cellist[3]) + weightrule[majcolor][4]*c1(cellist[4]) + weightrule[majcolor][5]*c1(cellist[5]) 
                        + weightrule[majcolor][6]*c1(cellist[6]) + weightrule[majcolor][7]*c1(cellist[7]) ;
                  // this next part identical to case 1.   Possibly the switch should be rejiggered.
                   if (birthrule[majcolor][len] ) {cel.placeholder_color = majcolor;
                                                  if (physicsOn) {Decay_velocitybirth(cel, len)};
                                                   } 
                   else {cel.placeholder_color = background}; 
                   break;

           case 10: //unweighted_len = len;
                  //if (cel.neighbors[2].color != background && cel.neighbors[2].color != decaygray) {unweighted_len -= 1}; 
                  //if (cel.neighbors[5].color != background && cel.neighbors[5].color != decaygray) {unweighted_len -= 1};
                   len = weightrule[majcolor][0]*c1(cellist[0]) + weightrule[majcolor][1]*c1(cellist[1]) + weightrule[majcolor][2]*c1(cellist[2]) 
                        + weightrule[majcolor][3]*c1(cellist[3]) + weightrule[majcolor][4]*c1(cellist[4]) + weightrule[majcolor][5]*c1(cellist[5]) 
                        + weightrule[majcolor][6]*c1(cellist[6]) + weightrule[majcolor][7]*c1(cellist[7]) ;
                   if (birthrule[majcolor][len] ) {cel.placeholder_color = majcolor;
                                                    if (physicsOn) {Decay_Hex_velocitybirth  (cel, len)};
                                                   } 
                   else {cel.placeholder_color = background};                    
                   break;



         case 11: if (cellist[2].color != background) {len -= 1};
                    if (cellist[5].color != background) {len -= 1};
                    if (len != 2 || HexCalnotBorn(cel))  {cel.placeholder_color = background}
                      else {cel.placeholder_color = majcolor;
                            if (physicsOn) {Hex_velocitybirth (cel, len)};
                           } ;
                   break;
         case 12:  if (len != 2 || twoAdjacent_JF_neighbors(cel, cellist))    {cel.placeholder_color = background}
                    else  {cel.placeholder_color = majcolor;
                           if (physicsOn) {velocitybirth(cel, len)};
                          };
                    break;
        case 13:  unweighted_len = len;
                  len = weightrule[majcolor][0]*bx2(cellist[0]) + weightrule[majcolor][1]*bx2(cellist[1]) + weightrule[majcolor][2]*bx2(cellist[2]) 
                        + weightrule[majcolor][3]*bx2(cellist[3]) + weightrule[majcolor][4]*bx2(cellist[4]) + weightrule[majcolor][5]*bx2(cellist[5]) 
                        + weightrule[majcolor][6]*bx2(cellist[6]) + weightrule[majcolor][7]*bx2(cellist[7]) ;

                   if (birthrule[majcolor][len] ) {cel.placeholder_color = majcolor; cel.placeholder_extra = 1 }
                                             else {cel.placeholder_color = background; 
                                                   //cel.placeholder_extra = 0
                                                   };                    
                   break;

        case 22:
        case 23:   unweighted_len = len;
                  len = weightrule[majcolor][0]*bx2(cellist[0]) + weightrule[majcolor][1]*bx2(cellist[1]) + weightrule[majcolor][2]*bx2(cellist[2]) 
                         + weightrule[majcolor][3]*bx2(cellist[3]) + weightrule[majcolor][4]*bx2(cellist[4]) + weightrule[majcolor][5]*bx2(cellist[5]) 
                         + weightrule[majcolor][6]*bx2(cellist[6]) + weightrule[majcolor][7]*bx2(cellist[7]) + weightrule[majcolor][8]*bx2(cellist[8]) 
                         + weightrule[majcolor][9]*bx2(cellist[9]) + weightrule[majcolor][10]*bx2(cellist[10]) + weightrule[majcolor][11]*bx2(cellist[11]) 
                         + weightrule[majcolor][12]*bx2(cellist[12]) + weightrule[majcolor][13]*bx2(cellist[13]) + weightrule[majcolor][14]*bx2(cellist[14]) 
                         + weightrule[majcolor][15]*bx2(cellist[15]) 
                         + weightrule[majcolor][16]*bx2(cellist[16]) + weightrule[majcolor][17]*bx2(cellist[17]) + weightrule[majcolor][18]*bx2(cellist[18]) 
                         + weightrule[majcolor][19]*bx2(cellist[19]) + weightrule[majcolor][20]*bx2(cellist[20]) + weightrule[majcolor][21]*bx2(cellist[21]) 
                         + weightrule[majcolor][22]*bx2(cellist[22]) + weightrule[majcolor][23]*bx2(cellist[23]);
                   if (birthrule[majcolor][len] ) {cel.placeholder_color = majcolor; cel.placeholder_extra = 1 }
                                             else {cel.placeholder_color = background; 
                                                   //cel.placeholder_extra = 0
                                                   };                    
                   break;

            // Weighted Rules
         case 28:  

                   len = weightrule[majcolor][0]*c1(cellist[0]) + weightrule[majcolor][1]*c1(cellist[1]) + weightrule[majcolor][2]*c1(cellist[2]) 
                         + weightrule[majcolor][3]*c1(cellist[3]) + weightrule[majcolor][4]*c1(cellist[4]) + weightrule[majcolor][5]*c1(cellist[5]) 
                         + weightrule[majcolor][6]*c1(cellist[6]) + weightrule[majcolor][7]*c1(cellist[7]) + weightrule[majcolor][8]*c1(cellist[8]) 
                         + weightrule[majcolor][9]*c1(cellist[9]) + weightrule[majcolor][10]*c1(cellist[10]) + weightrule[majcolor][11]*c1(cellist[11]) 
                         + weightrule[majcolor][12]*c1(cellist[12]) + weightrule[majcolor][13]*c1(cellist[13]) + weightrule[majcolor][14]*c1(cellist[14]) 
                         + weightrule[majcolor][15]*c1(cellist[15]) 
                         + weightrule[majcolor][16]*c1(cellist[16]) + weightrule[majcolor][17]*c1(cellist[17]) + weightrule[majcolor][18]*c1(cellist[18]) 
                         + weightrule[majcolor][19]*c1(cellist[19]) + weightrule[majcolor][20]*c1(cellist[20]) + weightrule[majcolor][21]*c1(cellist[21]) 
                         + weightrule[majcolor][22]*c1(cellist[22]) + weightrule[majcolor][23]*c1(cellist[23]);
                   if (birthrule[majcolor][len] ) {cel.placeholder_color = majcolor;  } 
                   else {cel.placeholder_color = background};                    
                   break;



               // Weighted Generations (Weighted with decay)
          case 29:   len = weightrule[majcolor][0]*c1(cellist[0]) + weightrule[majcolor][1]*c1(cellist[1]) + weightrule[majcolor][2]*c1(cellist[2]) 
                         + weightrule[majcolor][3]*c1(cellist[3]) + weightrule[majcolor][4]*c1(cellist[4]) + weightrule[majcolor][5]*c1(cellist[5]) 
                         + weightrule[majcolor][6]*c1(cellist[6]) + weightrule[majcolor][7]*c1(cellist[7]) + weightrule[majcolor][8]*c1(cellist[8]) 
                         + weightrule[majcolor][9]*c1(cellist[9]) + weightrule[majcolor][10]*c1(cellist[10]) + weightrule[majcolor][11]*c1(cellist[11]) 
                         + weightrule[majcolor][12]*c1(cellist[12]) + weightrule[majcolor][13]*c1(cellist[13]) + weightrule[majcolor][14]*c1(cellist[14]) 
                         + weightrule[majcolor][15]*c1(cellist[15]) 
                         + weightrule[majcolor][16]*c1(cellist[16]) + weightrule[majcolor][17]*c1(cellist[17]) + weightrule[majcolor][18]*c1(cellist[18]) 
                         + weightrule[majcolor][19]*c1(cellist[19]) + weightrule[majcolor][20]*c1(cellist[20]) + weightrule[majcolor][21]*c1(cellist[21]) 
                         + weightrule[majcolor][22]*c1(cellist[22]) + weightrule[majcolor][23]*c1(cellist[23]);
                   if (birthrule[majcolor][len] ) {cel.placeholder_color = majcolor;
                                              
                                                   } 
                   else {cel.placeholder_color = background}; 
                   break;
         case 14: 
                   //  cellist = cel.neighbors;

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                   // codes for Trilife: in a square cell,  left triangle only = 1, right  triange only = 2, both triangles = 3

                   cell_left =  cel.extra == 1 || cel.extra == 3;
                   cell_right = cel.extra == 2 || cel.extra == 3;

                   nw_left =  nw_neigh  == 1 || nw_neigh  == 3;
                   nw_right = nw_neigh  == 2 || nw_neigh == 3;

                   n_left =  n_neigh == 1 || n_neigh == 3;
                   n_right = n_neigh  == 2 || n_neigh == 3;

                   ne_left =  ne_neigh == 1 || ne_neigh == 3;

                   e_left =  e_neigh == 1 || e_neigh == 3;
                   e_right = e_neigh  == 2 || e_neigh == 3;

                   se_left =  se_neigh == 1 || se_neigh == 3;
                   se_right = se_neigh  == 2 || se_neigh == 3;

                   s_left =  s_neigh == 1 || s_neigh == 3;
                   s_right = s_neigh  == 2 || s_neigh == 3;

                   sw_right =  sw_neigh == 2 || sw_neigh == 3; 

                   w_left =  w_neigh == 1 || w_neigh == 3;
                   w_right = w_neigh  == 2 || w_neigh == 3;


                   rightcount = cell_left + nw_left + nw_right + n_left+ n_right + ne_left + e_left + e_right + se_left + se_right + s_right + w_right

                   leftcount =  cell_right + nw_left + nw_right + n_left + e_left + se_left + se_right + s_left + s_right + sw_right + w_left + w_right
                 if ( cell_left != 0 || cell_right != 0) { document.getElementById("info_message2").innerHTML="why yes"} 

                 // If we know the entire cell is empty then this:
                   newcell_left = birthrule[majcolor][leftcount]
                   newcell_right = birthrule[majcolor][rightcount]
                   
                  // if (cell_left == 1) {newcell_left = survivalrule[majcolor][leftcount]} else {newcell_left = birthrule[majcolor][leftcount]}
                  // if (cell_right == 1) {newcell_right = survivalrule[majcolor][rightcount]} else {newcell_right = birthrule[majcolor][rightcount]}


                   if (newcell_right == 1) {
                     if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                     else {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;}
                   }
                   else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;}
                         else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                   };
                  break;

         case 17:   // Pentagonal Prismatic Tesselation
                   //  cellist = cel.neighbors;

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;


                   // codes for Trilife: in a square cell,  left triangle only = 1, right  triange only = 2, both triangles = 3

                   cell_left =  cel.extra == 1 || cel.extra == 3;
                   cell_right = cel.extra == 2 || cel.extra == 3;

                   nw_left = nw_neigh  == 1 || nw_neigh == 3;
                   nw_right = nw_neigh  == 2 || nw_neigh == 3;

                   n_left =  n_neigh == 1 || n_neigh == 3;

                   e_left =  e_neigh == 1 || e_neigh == 3;

                   se_left =  se_neigh == 1 || se_neigh == 3;
                   se_right =  se_neigh == 2 || se_neigh == 3;

                   s_right = s_neigh  == 2 || s_neigh == 3;

                   w_right = w_neigh  == 2 || w_neigh == 3;

                   rightcount = cell_left + nw_left + nw_right + n_left + e_left + se_left + se_right
                   leftcount =  cell_right + s_right + se_left + se_right + w_right + nw_left + nw_right
                     // If we know the entire cell is empty then this:
                   newcell_left = birthrule[majcolor][leftcount]
                   newcell_right = birthrule[majcolor][rightcount]
                   
                  // if (cell_left == 1) {newcell_left = survivalrule[majcolor][leftcount]} else {newcell_left = birthrule[majcolor][leftcount]}
                  // if (cell_right == 1) {newcell_right = survivalrule[majcolor][rightcount]} else {newcell_right = birthrule[majcolor][rightcount]}


                   if (newcell_right == 1) {
                     if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                     else {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;}
                   }
                   else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;}
                         else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                   };
                  break;

   case 18:    // Basketweave Pentalife
                // States:   left = 1, right = 2, left&right = 3, top = 4, bottom = 5, top & bottom = 6


                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;



                       // I wonder if wrap-around is a problem???!!!!  Might be a strong reason to switch to quarted hexagons!!!
                      // I wonder if wrap-around is a problem???!!!!  Might be a strong reason to switch to quartered hexagons!!!
                       // I wonder if simply enforcing an even number for memoryX and memoryY, regardless of the window configuration, would suffice.
                       // might only be a problem for the fill window function.
                      // tested:  sure enough, for cell size = 3 (memoryY = 213, the glider stopped at the border and didn't wrap around.


                  if ((cel.xpos % 2 == 0 && cel.ypos % 2 == 0) || (cel.xpos % 2 == 1 && cel.ypos % 2 == 1)) {
                      // then cel is a left-right type of cell.
                      cell_left =  cel.extra == 1 || cel.extra == 3;
                      cell_right = cel.extra == 2 || cel.extra == 3;
                      nw_right = nw_neigh == 2 || nw_neigh == 3;
                      n_bottom = n_neigh  == 5 || n_neigh == 6;
                      ne_left = ne_neigh == 1 || ne_neigh == 3;
                      e_top = e_neigh == 4  || e_neigh == 6;
                      e_bottom = e_neigh == 5  || e_neigh == 6;
                      se_left = se_neigh == 1 || se_neigh == 3;
                      s_top = s_neigh == 4 || s_neigh == 6;
                      sw_right = sw_neigh == 2 || sw_neigh == 3;
                      w_top = w_neigh == 4 || w_neigh == 6;
                      w_bottom = w_neigh == 5 || w_neigh == 6;

                      rightcount = cell_left +  n_bottom  + e_top + e_bottom + s_top  + m_or_vn_weight[majcolor] *(se_left +  ne_left) ;                  
                      leftcount =  cell_right + n_bottom  + w_top + w_bottom + s_top +  m_or_vn_weight[majcolor] *(sw_right  + nw_right) ;   

                       // If we know the entire cell is empty then this:
                       newcell_left = birthrule[majcolor][leftcount];
                       newcell_right = birthrule[majcolor][rightcount];
                   

                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                      };
                }   // end section for left-right cells

                else {  // begin section for top-down cells

                       cell_top = cel.extra == 4 || cel.extra == 6;
                       cell_bottom = cel.extra == 5 || cel.extra == 6;
                       nw_bottom = nw_neigh == 5 || nw_neigh == 6;
                       n_left = n_neigh == 1 || n_neigh == 3;
                       n_right = n_neigh == 2 || n_neigh == 3;
                       ne_bottom = ne_neigh == 5 || ne_neigh == 6;
                       e_left = e_neigh == 1 || e_neigh == 3;
                       se_top = se_neigh == 4 || se_neigh == 6;
                       s_left = s_neigh == 1 || s_neigh == 3;
                       s_right = s_neigh == 2 || s_neigh == 3;
                       sw_top = sw_neigh == 4 || sw_neigh == 6;
                       w_right = w_neigh == 2 || w_neigh == 3;

        if ((cell_top >0 && cell_top <4) || (cell_bottom >0 && cell_bottom <4)){ document.getElementById("info_message2").innerHTML="why yes"} 

 
                      topcount = cell_bottom + n_left + n_right + e_left + w_right + m_or_vn_weight[majcolor] * (ne_bottom  + nw_bottom) ;   
                      bottomcount = cell_top + e_left + w_right  + s_left + s_right +  m_or_vn_weight[majcolor] * (se_top + sw_top);

                    // If we know the entire cell is empty then this:
                       newcell_top = birthrule[majcolor][topcount];
                       newcell_bottom = birthrule[majcolor][bottomcount];
                   
 
                      // either way:

                      if (newcell_bottom == 1) {
                        if (newcell_top == 1) {cel.placeholder_extra = 6; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_top == 1) {cel.placeholder_extra = 4; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                      };
                }  // end section for top-bottom cells

             break;

        case 20:  // Deltoidal TriHexagonal (Kites) (Radius 1)
                  
                   // binary code for the six cellular subdivisions in the hexagon
                   // 000001 = top_left, 000010 = top_right, 000100 = mid_left, 001000 = mid_right, 010000 = bot_left, 100000 = bot_right
                  // So, for example, bot_right and top_left would be 100001

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   // ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   // sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                   celdotextra = cel.extra
                   cell_top_left = celdotextra & 1
                   cell_top_right = (celdotextra >> 1) & 1
                   cell_mid_left = (celdotextra >> 2) & 1
                   cell_mid_right = (celdotextra >> 3) & 1
                   cell_bot_left = (celdotextra >> 4) & 1
                   cell_bot_right = (celdotextra >> 5) & 1

                   nw_bot_left = (nw_neigh >> 4) & 1
                   nw_bot_right = (nw_neigh >> 5) & 1
                   w_bot_right  = (w_neigh >> 5) & 1
                   w_mid_right = (w_neigh >> 3) & 1  
                   n_mid_left = (n_neigh >> 2) & 1
                   n_bot_left = (n_neigh >> 4) & 1
                   e_top_left = e_neigh & 1
                   e_mid_left = (e_neigh >> 2) & 1
                   se_top_right  = (se_neigh >> 1) & 1
                   se_top_left  = se_neigh & 1
                   s_mid_right  = (s_neigh >> 3) & 1
                   s_top_right = (s_neigh >> 1) & 1


                 top_leftcount = cell_top_right + cell_mid_left + w_mid_right + nw_bot_left 
                                  + m_or_vn_weight[majcolor] *(nw_bot_right + cell_mid_right + cell_bot_left + cell_bot_right +  w_bot_right) 



                  top_rightcount = cell_top_left + cell_mid_right + n_mid_left + nw_bot_right
                                  + m_or_vn_weight[majcolor] *(nw_bot_left   + n_bot_left + cell_bot_right + cell_bot_left + cell_mid_left) 

                  mid_rightcount = cell_top_right + cell_bot_right + n_bot_left + e_top_left
                                  + m_or_vn_weight[majcolor] *(n_mid_left  + e_mid_left  + cell_bot_left + cell_mid_left + cell_top_left)


                  bot_rightcount = cell_mid_right + cell_bot_left + e_mid_left + se_top_right
                                  + m_or_vn_weight[majcolor] *( e_top_left  + se_top_left +  + cell_mid_left + cell_top_left + cell_top_right)



                  bot_leftcount =  cell_mid_left + cell_bot_right + s_mid_right + se_top_left
                                  + m_or_vn_weight[majcolor] *(  se_top_right + s_top_right  + cell_top_right + cell_top_left + cell_mid_right)



                  mid_leftcount =  cell_top_left + cell_bot_left + s_top_right + w_bot_right
                                  + m_or_vn_weight[majcolor] *(  cell_top_right + cell_mid_right + cell_bot_right  + s_mid_right  + w_mid_right)


                       // If we know the entire cell is empty then this:
                     newcell_top_left = birthrule[majcolor][top_leftcount]
                     newcell_top_right = birthrule[majcolor][top_rightcount]
                     newcell_mid_left  = birthrule[majcolor][mid_leftcount]
                     newcell_mid_right  = birthrule[majcolor][mid_rightcount]
                     newcell_bot_left  = birthrule[majcolor][bot_leftcount]
                     newcell_bot_right  = birthrule[majcolor][bot_rightcount]

                      cel.placeholder_extra = newcell_top_left + (newcell_top_right << 1) + (newcell_mid_left << 2) + (newcell_mid_right << 3) + (newcell_bot_left << 4) + (newcell_bot_right << 5)
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = majcolor} 
                      else {cel.placeholder_color = background}
                  break;

        case 21:  // Pentagonal Floret
                  
                   // binary code for the six cellular subdivisions in the hexagon
                   // 000001 = top_left, 000010 = top_right, 000100 = mid_left, 001000 = mid_right, 010000 = bot_left, 100000 = bot_right
                  // So, for example, bot_right and top_left would be 100001

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   // ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   // sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                   celdotextra = cel.extra
                   cell_top_left = celdotextra & 1
                   cell_top_right = (celdotextra >> 1) & 1
                   cell_mid_left = (celdotextra >> 2) & 1
                   cell_mid_right = (celdotextra >> 3) & 1
                   cell_bot_left = (celdotextra >> 4) & 1
                   cell_bot_right = (celdotextra >> 5) & 1

                   nw_bot_left = (nw_neigh >> 4) & 1
                   nw_bot_right = (nw_neigh >> 5) & 1
                   w_bot_right  = (w_neigh >> 5) & 1
                   w_mid_right = (w_neigh >> 3) & 1  
                   n_mid_left = (n_neigh >> 2) & 1
                   n_bot_left = (n_neigh >> 4) & 1
                   e_top_left = e_neigh & 1
                   e_mid_left = (e_neigh >> 2) & 1
                   se_top_right  = (se_neigh >> 1) & 1
                   se_top_left  = se_neigh & 1
                   s_mid_right  = (s_neigh >> 3) & 1
                   s_top_right = (s_neigh >> 1) & 1



                   top_leftcount  = nw_bot_left + nw_bot_right + cell_top_right + cell_mid_left + w_mid_right + m_or_vn_weight[majcolor] *( cell_bot_left + cell_bot_right + cell_mid_right)
                   top_rightcount = nw_bot_right + n_mid_left + n_bot_left + cell_mid_right  + cell_top_left  + m_or_vn_weight[majcolor] *(  cell_bot_right + cell_bot_left + cell_mid_left)
                   mid_rightcount = n_bot_left + e_top_left + e_mid_left + cell_bot_right  + cell_top_right + m_or_vn_weight[majcolor] *(cell_bot_left + cell_mid_left + cell_top_left)
                   bot_rightcount = cell_mid_right + e_mid_left + se_top_right + se_top_left + cell_bot_left + m_or_vn_weight[majcolor] *( cell_mid_left + cell_top_left + cell_top_right)
                   bot_leftcount = cell_bot_right  + se_top_left + s_mid_right + s_top_right + cell_mid_left  + m_or_vn_weight[majcolor] *(cell_top_right + cell_top_left + cell_mid_right)
                   mid_leftcount = cell_top_left + cell_bot_left  + s_top_right + w_bot_right + w_mid_right  + m_or_vn_weight[majcolor] *( cell_top_right + cell_mid_right + cell_bot_right)



                       // If we know the entire cell is empty then this:
                     newcell_top_left = birthrule[majcolor][top_leftcount]
                     newcell_top_right = birthrule[majcolor][top_rightcount]
                     newcell_mid_left  = birthrule[majcolor][mid_leftcount]
                     newcell_mid_right  = birthrule[majcolor][mid_rightcount]
                     newcell_bot_left  = birthrule[majcolor][bot_leftcount]
                     newcell_bot_right  = birthrule[majcolor][bot_rightcount]

                      cel.placeholder_extra = newcell_top_left + (newcell_top_right << 1) + (newcell_mid_left << 2) + (newcell_mid_right << 3) + (newcell_bot_left << 4) + (newcell_bot_right << 5)
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = majcolor} 
                      else {cel.placeholder_color = background}
                  break;

        case 39: // Truncated Hex - This is just like Kagome except that triangles have only three neighobrs!

                     // top_left = 001 bot_right = 010 middle = 100  topleft&botright = 011 mid&topleft = 101 mid&botright = 110 midtopbot = 111  
                     // top_left = 1   bot_right = 2   middlle = 4   top&bot = 3 mid&topleft = 5 mid&botright = 6 midtopbot = 7 

                      cellist = cel.neighbors;
                      nw_neigh = cellist[0].extra;
                      n_neigh = cellist[1].extra;
                      ne_neigh = cellist[2].extra;
                      w_neigh = cellist[3].extra;
                      e_neigh = cellist[4].extra;
                      sw_neigh = cellist[5].extra;
                      s_neigh = cellist[6].extra;
                      se_neigh = cellist[7].extra;
                      celdotextra = cel.extra

                      cell_top_left  = celdotextra & 1
                      cell_bot_right = (celdotextra >> 1) & 1
                      cell_middle = (celdotextra >> 2) & 1


                      n_middle = (n_neigh >> 2) & 1
                      ne_middle = (ne_neigh >> 2) & 1
                      e_middle = (e_neigh >> 2) & 1
                      s_middle = (s_neigh >> 2) & 1
                      sw_middle  = (sw_neigh >> 2) & 1
                      w_middle = (w_neigh >> 2) & 1

                      n_bot_right = (n_neigh >> 1) & 1
                      nw_bot_right = (nw_neigh >> 1) & 1
                      w_bot_right = (w_neigh >> 1) & 1

                      s_top_left = s_neigh  & 1
                      se_top_left = se_neigh & 1
                      e_top_left = e_neigh & 1



                      top_leftcount = n_middle + cell_middle + w_middle // (the hex neighbors)
                                     // commented out for Truncated Hex instaad of Kagome  + nw_bot_right + n_bot_right +w_bot_right // (the tri neighbors)
                
                      middle_count = n_middle + ne_middle + e_middle + s_middle + sw_middle + w_middle // (the hex neighbors)
                                   + n_bot_right + e_top_left + cell_bot_right + s_top_left + w_bot_right + cell_top_left // (the tri neighbors)

                      bot_rightcount = cell_middle + e_middle + s_middle // (the hex neighbors)
                                       // commented out for Truncated Hex instaad of Kagome  + e_top_left + se_top_left + s_top_left // (the tri neighbors)

                      // If we know the entire cell is empty then this:
                     newcell_top_left = birthrule[majcolor][top_leftcount]
                     newcell_middle  = birthrule[majcolor][middle_count]
                     newcell_bot_right  = birthrule[majcolor][bot_rightcount]

                     cel.placeholder_extra = newcell_top_left + (newcell_bot_right << 1) + (newcell_middle << 2) 
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = majcolor} 
                      else {cel.placeholder_color = background}
                  break;



          case 40:  // Kagome Lattice (Hexagons and TriangleS)

// top_left = 001 bot_right = 010 middle = 100  topleft&botright = 011 mid&topleft = 101 mid&botright = 110 midtopbot = 111  
// top_left = 1   bot_right = 2   middlle = 4   top&bot = 3 mid&topleft = 5 mid&botright = 6 midtopbot = 7 

                      cellist = cel.neighbors;
                      nw_neigh = cellist[0].extra;
                      n_neigh = cellist[1].extra;
                      ne_neigh = cellist[2].extra;
                      w_neigh = cellist[3].extra;
                      e_neigh = cellist[4].extra;
                      sw_neigh = cellist[5].extra;
                      s_neigh = cellist[6].extra;
                      se_neigh = cellist[7].extra;
                      celdotextra = cel.extra

                      cell_top_left  = celdotextra & 1
                      cell_bot_right = (celdotextra >> 1) & 1
                      cell_middle = (celdotextra >> 2) & 1


                      n_middle = (n_neigh >> 2) & 1
                      ne_middle = (ne_neigh >> 2) & 1
                      e_middle = (e_neigh >> 2) & 1
                      s_middle = (s_neigh >> 2) & 1
                      sw_middle  = (sw_neigh >> 2) & 1
                      w_middle = (w_neigh >> 2) & 1

                      n_bot_right = (n_neigh >> 1) & 1
                      nw_bot_right = (nw_neigh >> 1) & 1
                      w_bot_right = (w_neigh >> 1) & 1

                      s_top_left = s_neigh  & 1
                      se_top_left = se_neigh & 1
                      e_top_left = e_neigh & 1



                      top_leftcount = n_middle + cell_middle + w_middle // (the hex neighbors)
                                     + nw_bot_right + n_bot_right +w_bot_right // (the tri neighbors)
                
                      middle_count = n_middle + ne_middle + e_middle + s_middle + sw_middle + w_middle // (the hex neighbors)
                                   + n_bot_right + e_top_left + cell_bot_right + s_top_left + w_bot_right + cell_top_left // (the tri neighbors)

                      bot_rightcount = cell_middle + e_middle + s_middle // (the hex neighbors)
                                       + e_top_left + se_top_left + s_top_left // (the tri neighbors)

                      // If we know the entire cell is empty then this:
                     newcell_top_left = birthrule[majcolor][top_leftcount]
                     newcell_middle  = birthrule[majcolor][middle_count]
                     newcell_bot_right  = birthrule[majcolor][bot_rightcount]

                     cel.placeholder_extra = newcell_top_left + (newcell_bot_right << 1) + (newcell_middle << 2) 
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = majcolor} 
                      else {cel.placeholder_color = background}
                  break;

      case 41:  // octo-squares
       if ((cel.xpos % 2 == 0 && cel.ypos % 2 == 0) || (cel.xpos % 2 == 1 && cel.ypos % 2 == 1)) {
                   if (birthrule[majcolor][len]) {cel.placeholder_color = majcolor; 
                                                     cel.placeholder_extra = 1
                   } 
                    else {cel.placeholder_color = background; 
                           cel.placeholder_extra = 0
                    };
             }
             else {
                     cellist = cel.neighbors;
                   
                   len = c1(cellist[1]) + c1(cellist[3]) +  c1(cellist[4]) + c1(cellist[6]) // North, East, West, South respectively
                   if (birthrule[majcolor][len]) {cel.placeholder_color = majcolor;
                                                  cel.placeholder_extra = 2
                   } 
                  else {cel.placeholder_color = background; 
                        cel.placeholder_extra = 0
                       };
              }
              break;


case 42:  // Rhombitrihexagonal  -- birth case

                  cellist = cel.neighbors;
                   celdotextra = cel.extra
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;


   // 9 states:
   // 0 000 = background
   // 1 001 = upward_right
   // 2 010 = upward__left
   // 3 011 = upward_split_both
   // 4 100 = Dodecagon
   // 5 101 = downward_right
   // 6 110 = downward_left
   // 7 111 = downward_split_both
   // 8 1000 = middle square     

                 

   // middle squares
   if ((cel.ypos % 4 == 0 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 2 && cel.xpos % 2 == 1))  {

      n_right = n_neigh == 5 || n_neigh == 7
      n_left = n_neigh == 6 || n_neigh == 7
      ne_left = ne_neigh == 2 || ne_neigh == 3
      se_left = se_neigh == 6 || se_neigh == 7
      s_right = s_neigh == 1 || s_neigh == 3
      s_left = s_neigh == 2 || s_neigh == 3
      
      mycount = n_right  + (e_neigh == 4) + (w_neigh == 4)  + s_right + m_or_vn_weight[majcolor] * (n_left + ne_left + se_left + s_left)
                     
                  if (birthrule[majcolor][mycount]) {cel.placeholder_color = majcolor; cel.placeholder_extra = 8} 
                  else {cel.placeholder_color = background; cel.placeholder_extra = 0};
   }

   // middle hexagons
   else if ((cel.ypos % 4 == 2 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 0 && cel.xpos % 2 == 1))  {
     n_left = n_neigh == 2 || n_neigh == 3
     n_right = n_neigh == 1 || n_neigh == 3
     ne_left = ne_neigh == 6 || ne_neigh == 7
     ne_right = ne_neigh == 5 || ne_neigh == 7
     se_left = se_neigh == 2 || se_neigh == 3
     se_right = se_neigh == 1 || se_neigh == 3
     s_right = s_neigh == 5 || s_neigh == 7
     s_left = s_neigh == 6 || s_neigh == 7
     sw_right = sw_neigh == 1 || sw_neigh == 3
     nw_right = nw_neigh == 5 || nw_neigh == 7


     //mycount = (n_neigh in [2, 3]) + (n_neigh in [1, 3]) + (ne_neigh in [6, 7]) + (ne_neigh in [5,7]) + (e_neigh == 8) + (se_neigh in [2,3]) 
      //         + (se_neigh in [1,3]) + (s_neigh in [5,7]) + (s_neigh in [6,7])  + (sw_neigh in [1,3]) + (w_neigh == 8) + (nw_neigh in [5,7])
      mycount = n_left + n_right + ne_left + ne_right + (e_neigh == 8) + se_left + se_right + s_right + s_left  + sw_right  + (w_neigh == 8) + nw_right

                      
                  if (birthrule[majcolor][mycount]) {cel.placeholder_color = majcolor; cel.placeholder_extra = 4} 
                  else {cel.placeholder_color = background; cel.placeholder_extra = 0};

      } // end section for Dodecagons

   // Upwards left-right cell
   else if ((cel.ypos % 4 == 1 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 3 && cel.xpos % 2 == 1))  {

      cell_left = celdotextra == 2 || celdotextra == 3
      cell_right = celdotextra == 1 || celdotextra == 3
      e_left = e_neigh == 6 || e_neigh == 7
      w_right = w_neigh == 5 || w_neigh == 7
      w_left = w_neigh == 6 || w_neigh == 7
      
    
      rightcount =  (n_neigh == 8) + cell_left + e_left + m_or_vn_weight[majcolor] *((nw_neigh == 4) + (ne_neigh == 4)  + (s_neigh == 4))  // triangle
      leftcount =  (nw_neigh == 4) + cell_right  + (s_neigh == 4)  + w_right  + m_or_vn_weight[majcolor] *((n_neigh == 8) + (sw_neigh == 8) + e_left + w_left ) // Square  
     
                     newcell_left = birthrule[majcolor][leftcount]
                     newcell_right = birthrule[majcolor][rightcount]

                     // Now return the final cell value for left-right cells


                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


                } // end section for upwards left-right cells



   // Downwards left-right cell
   if ((cel.ypos % 4 == 3 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 1 && cel.xpos % 2 == 1))  {

      cell_left = celdotextra == 6 || celdotextra == 7
      cell_right = celdotextra == 5 || celdotextra == 7
      e_left = e_neigh == 2 || e_neigh == 3
      w_right = w_neigh == 1 || w_neigh == 3
      w_left = w_neigh == 2 || w_neigh == 3
      

  
      rightcount =   e_left + (s_neigh == 8) + cell_left + m_or_vn_weight[majcolor] *( (sw_neigh == 4) + (n_neigh == 4)  + (se_neigh == 4) )
      leftcount =    (n_neigh == 4)  + cell_right  + (sw_neigh == 4) +  w_right + m_or_vn_weight[majcolor] *( w_left  + e_left + (nw_neigh == 8) + (s_neigh == 8) ) // Square

     
                     newcell_left = birthrule[majcolor][leftcount]
                     newcell_right = birthrule[majcolor][rightcount]
                   
                     // Now return the final cell value for left-right cells


                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 7; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 6; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


                } // end section for downwards left-right cells

            break;



case 43:  // Truncated Trihexagonal Tiling  -- birth case

                  cellist = cel.neighbors;
                   celdotextra = cel.extra
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;


   // 9 states:
   // 0 000 = background
   // 1 001 = upward_right
   // 2 010 = upward__left
   // 3 011 = upward_split_both
   // 4 100 = Dodecagon
   // 5 101 = downward_right
   // 6 110 = downward_left
   // 7 111 = downward_split_both
   // 8 1000 = middle square     

                 

   // middle squares
   if ((cel.ypos % 4 == 0 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 2 && cel.xpos % 2 == 1))  {

      n_right = n_neigh == 5 || n_neigh == 7
      s_right = s_neigh == 1 || s_neigh == 3
      mycount = n_right  + (e_neigh == 4) + (w_neigh == 4)  + s_right
                     
                  if (birthrule[majcolor][mycount]) {cel.placeholder_color = majcolor; cel.placeholder_extra = 8} 
                  else {cel.placeholder_color = background; cel.placeholder_extra = 0};
   }

   // Dodecagons
   else if ((cel.ypos % 4 == 2 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 0 && cel.xpos % 2 == 1))  {
     n_left = n_neigh == 2 || n_neigh == 3
     n_right = n_neigh == 1 || n_neigh == 3
     ne_left = ne_neigh == 6 || ne_neigh == 7
     ne_right = ne_neigh == 5 || ne_neigh == 7
     se_left = se_neigh == 2 || se_neigh == 3
     se_right = se_neigh == 1 || se_neigh == 3
     s_right = s_neigh == 5 || s_neigh == 7
     s_left = s_neigh == 6 || s_neigh == 7
     sw_right = sw_neigh == 1 || sw_neigh == 3
     nw_right = nw_neigh == 5 || nw_neigh == 7


     //mycount = (n_neigh in [2, 3]) + (n_neigh in [1, 3]) + (ne_neigh in [6, 7]) + (ne_neigh in [5,7]) + (e_neigh == 8) + (se_neigh in [2,3]) 
      //         + (se_neigh in [1,3]) + (s_neigh in [5,7]) + (s_neigh in [6,7])  + (sw_neigh in [1,3]) + (w_neigh == 8) + (nw_neigh in [5,7])
      mycount = n_left + n_right + ne_left + ne_right + (e_neigh == 8) + se_left + se_right + s_right + s_left  + sw_right  + (w_neigh == 8) + nw_right

                      
                  if (birthrule[majcolor][mycount]) {cel.placeholder_color = majcolor; cel.placeholder_extra = 4} 
                  else {cel.placeholder_color = background; cel.placeholder_extra = 0};

      } // end section for Dodecagons

   // Upwards left-right cell
   else if ((cel.ypos % 4 == 1 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 3 && cel.xpos % 2 == 1))  {

      cell_left = celdotextra == 2 || celdotextra == 3
      cell_right = celdotextra == 1 || celdotextra == 3
      e_left = e_neigh == 6 || e_neigh== 7
      w_right = w_neigh == 5 || w_neigh == 7
      
      rightcount = (nw_neigh == 4) + (n_neigh == 8) + (ne_neigh == 4) + cell_left + e_left + (s_neigh == 4) // Hexagon
      leftcount =  (nw_neigh == 4) + cell_right  + (s_neigh == 4)  + w_right  // Square

  
     
                     newcell_left = birthrule[majcolor][leftcount]
                     newcell_right = birthrule[majcolor][rightcount]

                     // Now return the final cell value for left-right cells


                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


                } // end section for upwards left-right cells



   // Downwards left-right cell
   if ((cel.ypos % 4 == 3 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 1 && cel.xpos % 2 == 1))  {

      cell_left = celdotextra == 6 || celdotextra == 7
      cell_right = celdotextra == 5 || celdotextra == 7
      e_left = e_neigh == 2 || e_neigh == 3
      w_right = w_neigh == 1 || w_neigh == 3
      
      rightcount =  (n_neigh == 4) +  e_left  + (se_neigh == 4) + (s_neigh == 8) + (sw_neigh == 4) + cell_left // Hexagon
      leftcount =    (n_neigh == 4)  + cell_right  + (sw_neigh == 4) +  w_right   // Square

     
                     newcell_left = birthrule[majcolor][leftcount]
                     newcell_right = birthrule[majcolor][rightcount]
                   
                     // Now return the final cell value for left-right cells


                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 7; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 6; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


                } // end section for downwards left-right cells

            break;







        case 44: //  Elongated Triangular  (using alternating square method)
                // States: in a square cell,  left triangle only = 1, right  triange only = 2, both triangles = 3, full square = 4
                                 // in squares, nw_right, n_right, s_right, se_right, not ne_right!

                   cellist = cel.neighbors;

               if (cel.ypos % 2 == 0) {  // if it is an even row
                   cell_left =  cel.extra == 1 || cel.extra == 3;
                   cell_right = cel.extra == 2 || cel.extra == 3;
 
                   nw_neigh = cellist[0].extra == 4
                   n_neigh = cellist[1].extra == 4
                   ne_neigh = cellist[2].extra == 4

                   w_neigh = cellist[3].extra;
                   w_left =  w_neigh == 1 || w_neigh == 3;
                   w_right = w_neigh  == 2 || w_neigh == 3;
                   
                   e_neigh = cellist[4].extra;
                   e_left =  e_neigh == 1 || e_neigh == 3;
                   e_right = e_neigh  == 2 || e_neigh == 3;

                   sw_neigh = cellist[5].extra == 4
                   s_neigh = cellist[6].extra == 4
                   se_neigh = cellist[7].extra == 4

                    rightcount = cell_left  + e_left + n_neigh + nw_neigh + ne_neigh + e_right + s_neigh + se_neigh + w_right  // first three are VN
                    leftcount =  cell_right + w_right + s_neigh + sw_neigh  + se_neigh + w_left  + nw_neigh + n_neigh + e_left // first three are VN
                                    // If we know the entire cell is empty then this:
                  newcell_left = birthrule[majcolor][leftcount]
                  newcell_right = birthrule[majcolor][rightcount]
                   
                   if (newcell_right == 1) {
                     if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                     else {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;}
                   }
                   else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;}
                         else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                   };
            } // end even row handling
           else {  // else it is an odd row....
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   //w_neigh = cellist[3].extra;
                   //e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                   // This isn't used -- candidate for deletion   cell_full = cel.extra == 4

                   n_left = n_neigh == 1 || n_neigh == 3
                   n_right = n_neigh  == 2 || n_neigh == 3;
                   ne_left = ne_neigh == 1 || ne_neigh == 3;
                   e_neigh = cellist[4].extra == 4
                   se_left = se_neigh == 1 || se_neigh == 3
                   se_right = se_neigh  == 2 || se_neigh == 3;
                   s_left = s_neigh == 1 || s_neigh == 3
                   s_right = s_neigh  == 2 || s_neigh == 3;
                   sw_right = sw_neigh  == 2 || sw_neigh == 3;
                   w_neigh = cellist[3].extra == 4
                   nw_left = nw_neigh == 1 || nw_neigh == 3
                   nw_right = nw_neigh  == 2 || nw_neigh == 3;


                   len =  n_left + e_neigh + w_neigh + s_right +  n_right + ne_left+ se_left + se_right + s_left + sw_right + nw_left + nw_right // first four: VN
                   
                      
                    if (birthrule[majcolor][len] ) {cel.placeholder_color = majcolor; cel.placeholder_extra = 4;}
                    else {cel.placeholder_color = background; cel.placeholder_extra = 0; }
                 }


                   break;

     case 46:   // Snub Square Tiling  -- Birth version
  // as implemented in 8 states as alternating left and right triangles,
  //                                           reverse triangles (backleft and backright), 
  //                                       and full squares.
            // States:   left = 1, right = 2, left&right = 3, backleft = 4, backright = 5, backleft & backright = 6, alivesquare = 7

                   cellist = cel.neighbors;



                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                if (cel.xpos % 2 == 0 && cel.ypos % 2 == 0) {
                      // then cel is a left-right type of cell.

                      cell_left =  cel.extra == 1 || cel.extra == 3;
                      cell_right = cel.extra == 2 || cel.extra == 3;
                      nw_backleft = nw_neigh == 4 || nw_neigh == 6;
                      nw_backright = nw_neigh == 5 || nw_neigh == 6;
                      ne_backleft = ne_neigh == 4 || ne_neigh == 6;
                      se_backleft = se_neigh == 4 || se_neigh == 6; 
                      se_backright = se_neigh == 5 || se_neigh == 6;
                      sw_backright = sw_neigh == 5 || sw_neigh == 6;

                      if (n_neigh == 7) {n_square = 1} else {n_square = 0}
                      if (e_neigh == 7) {e_square = 1} else {e_square = 0}
                      if (s_neigh == 7) {s_square = 1} else {s_square = 0}
                      if (w_neigh == 7) {w_square = 1} else {w_square = 0}

  
                      rightcount = cell_left + e_square+ s_square + m_or_vn_weight[majcolor] * (n_square + ne_backleft + se_backleft + se_backright + sw_backright + w_square)
                      leftcount =  cell_right + w_square + n_square + m_or_vn_weight[majcolor] * (ne_backleft + e_square + s_square + sw_backright + nw_backleft + nw_backright)
                   
                      
                        newcell_left = birthrule[majcolor][leftcount]
                        newcell_right = birthrule[majcolor][rightcount]
                                     
                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


               }  //end section for left-right cells


               else if (cel.xpos % 2 == 1 && cel.ypos % 2 == 1) {  // begin section for backleft-backright cells

                      cell_backleft = cel.extra == 4 || cel.extra == 6;
                      cell_backright = cel.extra == 5 || cel.extra == 6;

                  
                      if (n_neigh == 7) {n_square = 1} else {n_square = 0}
                      if (e_neigh == 7) {e_square = 1} else {e_square = 0}
                      if (s_neigh == 7) {s_square = 1} else {s_square = 0}
                      if (w_neigh == 7) {w_square = 1} else {w_square = 0}
 
                      nw_right = nw_neigh == 2 || nw_neigh == 3

                      ne_left = ne_neigh == 1 || ne_neigh == 3
                      ne_right = ne_neigh == 2 || ne_neigh == 3

                      se_left = se_neigh == 1 || se_neigh == 3

                      sw_left = sw_neigh == 1 || sw_neigh == 3
                      sw_right = sw_neigh == 2 || sw_neigh == 3

                     rightcount = cell_backleft + n_square + e_square + m_or_vn_weight[majcolor] * (ne_left + ne_right + se_left + s_square +w_square + nw_right)  // for cell_backright
                     leftcount =  cell_backright + s_square + w_square + m_or_vn_weight[majcolor] * (n_square + e_square + se_left + sw_left + sw_right + nw_right) // for cell_backleft

                     newcell_left = birthrule[majcolor][leftcount]
                     newcell_right = birthrule[majcolor][rightcount]
                   
                     if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 6; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 4; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


                } // end section for backleft-backright cells
              else {  // begin section for full cells  

                    //There are really two "kinds" of full cells, but one calcuation can cover both
                     //   However, this makes patterns incompatible with the golly version!  Might want to add a state and rewrite to make it compatible with golly.

                     n_backleft =  n_neigh == 4 || n_neigh == 6
                     n_left = n_neigh == 1 || n_neigh == 3

                     e_left =      e_neigh == 1 || e_neigh == 3
                     e_backleft = e_neigh == 4 || e_neigh == 6

                     s_right = s_neigh == 2 || s_neigh == 3
                     s_backright = s_neigh == 5 || s_neigh == 6

                     w_right =     w_neigh == 2 || w_neigh == 3
                     w_backright = w_neigh == 5 || w_neigh == 6

                     n_backright = n_neigh == 5 || n_neigh == 6
                     n_right = n_neigh == 2 || n_neigh == 3

                     e_right = e_neigh == 2 || e_neigh == 3
                     e_backright = e_neigh == 5 || e_neigh == 6

                     s_backleft = s_neigh == 4 || s_neigh == 6
                     s_left = s_neigh == 1 || s_neigh == 3

                     w_backleft =  w_neigh == 4 || w_neigh == 6
                     w_left =  w_neigh == 1 || w_neigh == 3



                      if (ne_neigh == 7) {ne_square = 1} else {ne_square = 0}
                      if (nw_neigh == 7) {nw_square = 1} else {nw_square = 0}
                      if (se_neigh == 7) {se_square = 1} else {se_square = 0}
                      if (sw_neigh == 7) {sw_square = 1} else {sw_square = 0}

                  


                        // Need to rearrange the following and then insert m_or_vn_weight[majcolor] * ()
             // mycount = n_backleft + n_left + e_left + e_backleft + s_backright + s_right + w_right + w_backright + n_backright + n_right + ne_square + e_right + e_backright + se_square + s_backleft + s_left + sw_square + w_left + w_backleft + nw_square 

               mycount = n_backleft + n_right + e_left + e_backleft + s_backright   + w_right + w_backright  + s_left   
                    + m_or_vn_weight[majcolor] * (n_left + s_right +  n_backright  + ne_square  + e_right  
                      + e_backright + se_square + s_backleft   + sw_square +  w_left + nw_square   + w_backleft  )



                   
                      
                     if (birthrule[majcolor][mycount]) {cel.placeholder_color = majcolor; cel.placeholder_extra = 7} 
                     else {cel.placeholder_color = background; cel.placeholder_extra = 0};
                 }


                 
             break;

   case 48:
                   // six-six alternating splithex pentagons
                   // states:  1 = left, 2 = right, 3 = left & right, 4 = top, 5 = bottom, 6 = top & bottom
                   cellist = cel.neighbors;

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                  // ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                  // sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

             // lets say left-right cells occupy even columns and top-down cells occupy odd columns
                 
               if (cel.xpos % 2 == 0) {
                      // then cel is a left-right type of cell.

                      cell_left =  cel.extra == 1 || cel.extra == 3;
                      cell_right = cel.extra == 2 || cel.extra == 3;
                      nw_bottom =  nw_neigh == 5 || nw_neigh == 6
                      n_left = n_neigh == 1 || n_neigh == 3
                      w_top =   w_neigh == 4 || w_neigh == 6
                      w_bottom = w_neigh == 5 || w_neigh == 6
                      s_right = s_neigh == 2 || s_neigh == 3
                      se_top =  se_neigh == 4 || se_neigh == 6
                      e_top = e_neigh == 4 || e_neigh == 6
                      e_bottom = e_neigh == 5 || e_neigh == 6
                      
                     leftcount = cell_right + w_top + w_bottom + nw_bottom + se_top + s_right
                     rightcount = cell_left + e_top + e_bottom  + nw_bottom + se_top + n_left

                       // Since we know the entire cell is empty:
                         newcell_left = birthrule[majcolor][leftcount]
                         newcell_right = birthrule[majcolor][rightcount]
                   
                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };
                      
                  }  //end section for left-right cells

                else {    // then cel is a top-bottom type of cell.
                      cell_top =  cel.extra == 4 || cel.extra == 6;
                      cell_bottom = cel.extra == 5 || cel.extra == 6;
                      nw_left = nw_neigh == 1 || nw_neigh == 3
                      nw_right = nw_neigh == 2 || nw_neigh == 3
                      n_bottom = n_neigh == 5 || n_neigh == 6
                      e_left = e_neigh == 1 || e_neigh == 3
                      se_left = se_neigh == 1 || se_neigh == 3
                      se_right  = se_neigh == 2 || se_neigh == 3
                      s_top = s_neigh == 4 || s_neigh == 6
                      w_right = w_neigh == 2 || w_neigh == 3

                      bottomcount = cell_top + e_left  + w_right + se_left + se_right + s_top 
                      topcount = cell_bottom + e_left  + w_right + nw_left + nw_right + n_bottom

                    // Since we know the entire cell is empty:
                       newcell_top = birthrule[majcolor][topcount]
                       newcell_bottom = birthrule[majcolor][bottomcount]
                                     
                   // either way:

                      if (newcell_bottom == 1) {
                        if (newcell_top == 1) {cel.placeholder_extra = 6; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_top == 1) {cel.placeholder_extra = 4; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                      };
                } // end section for top-bottom cells
              break;

 case 49:   // Birth case

                  // 5-8 alternating splithex pentagons
                  // states:  1 = left, 2 = right, 3 = left & right, 4 = top, 5 = bottom, 6 = top & bottom


                   cellist = cel.neighbors;

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;
                if ((cel.xpos % 2 == 0 && cel.ypos % 2 == 0) || (cel.xpos % 2 == 1 && cel.ypos % 2 == 1)) {
                      // then cel is a left-right type of cell.
                      cell_left =  cel.extra == 1 || cel.extra == 3;
                      cell_right = cel.extra == 2 || cel.extra == 3;
                      nw_left = nw_neigh == 1 || nw_neigh == 3
                      nw_right = nw_neigh == 2 || nw_neigh == 3
                      n_bottom = n_neigh == 5 || n_neigh == 6
                      e_top = e_neigh == 4 || e_neigh == 6
                      e_bottom = e_neigh == 5 || e_neigh == 6
                      se_left = se_neigh == 1 || se_neigh == 3
                      se_right = se_neigh == 2 || se_neigh == 3
                      s_top = s_neigh == 4 || s_neigh == 6
                      w_top = w_neigh == 4 || w_neigh == 6
                      w_bottom = w_neigh == 5 || w_neigh == 6

                      rightcount = cell_left + nw_right + n_bottom + e_top + e_bottom + se_right + se_left  + nw_left // last two: VN
                      leftcount =  cell_right + nw_left + s_top   +  w_top + w_bottom  + se_left + se_right + nw_right // last two: VN

                       // Since we know the entire cell is empty:
                         newcell_left = birthrule[majcolor][leftcount]
                         newcell_right = birthrule[majcolor][rightcount]
                   
                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };
                      
                  }  //end section for left-right cells


                else {    // then cel is a top-bottom type of cell.
                        cell_top = cel.extra == 4 || cel.extra == 6
                        cell_bottom = cel.extra == 5 || cel.extra == 6
                        nw_bottom = nw_neigh == 5 || nw_neigh == 6
                        n_left = n_neigh == 1 || n_neigh == 3
                        w_right = w_neigh == 2 || w_neigh == 3
                        e_left = e_neigh == 1 || e_neigh == 3
                        se_top = se_neigh == 4 || se_neigh == 6
                        s_right = s_neigh == 2 || s_neigh == 3

                      topcount = cell_bottom + nw_bottom + n_left + e_left + w_right
                      bottomcount = cell_top + w_right + e_left + se_top + s_right

                    // Since we know the entire cell is empty:
                       newcell_top = birthrule[majcolor][topcount]
                       newcell_bottom = birthrule[majcolor][bottomcount]
                                     
                   // either way:

                      if (newcell_bottom == 1) {
                        if (newcell_top == 1) {cel.placeholder_extra = 6; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_top == 1) {cel.placeholder_extra = 4; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                      };
                } // end section for top-bottom cells
              break;
  
   case 50:   //Tetrakis Square Tiling -- birth

             // States:   left = 1, right = 2, left&right = 3, backleft = 4, backright = 5, backleft & backright = 6, 


                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                if ((cel.xpos % 2 == 0 && cel.ypos % 2 == 0) || (cel.xpos % 2 == 1 && cel.ypos % 2 == 1)) {


                   cell_backleft = cel.extra == 4 || cel.extra == 6
                   cell_backright = cel.extra == 5 || cel.extra == 6
                   nw_backleft = nw_neigh == 4 || nw_neigh == 6
                   nw_backright = nw_neigh == 5 || nw_neigh == 6
                   n_left = n_neigh == 1 || n_neigh == 3
                   n_right = n_neigh == 2 || n_neigh == 3
                   e_left = e_neigh == 1 || e_neigh == 3
                   e_right = e_neigh == 2 || e_neigh == 3
                   se_backleft  = se_neigh == 4 || se_neigh == 6
                   se_backright = se_neigh == 5 || se_neigh == 6
                   s_left = s_neigh == 1 || s_neigh == 3
                   s_right = s_neigh == 2 || s_neigh == 3
                   sw_backright = sw_neigh == 5 || sw_neigh == 6
                   w_left = w_neigh == 1 || w_neigh == 3
                   w_right = w_neigh == 2 || w_neigh == 3
                   ne_backleft = ne_neigh == 4 || ne_neigh == 6

                   leftcount = cell_backright + nw_backleft + nw_backright + n_left + n_right + e_left + e_right + se_backleft + se_backright + s_left + s_right + sw_backright + w_left + w_right

                   rightcount = cell_backleft + nw_backleft + nw_backright + n_left + n_right +  ne_backleft + e_left + e_right + se_backleft + se_backright + s_left + s_right +  w_left + w_right

                   
                    newcell_left = birthrule[majcolor][leftcount];
                    newcell_right = birthrule[majcolor][rightcount];

                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 6; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 4; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


               }  //end section for backleft-backright cells
               else {
                     cell_left = cel.extra == 1 || cel.extra == 3
                     cell_right = cel.extra == 2 || cel.extra == 3
                     nw_right = nw_neigh == 2 || nw_neigh == 3
                     n_backleft = n_neigh == 4 || n_neigh == 6
                     n_backright = n_neigh == 5 || n_neigh == 6
                     ne_left = ne_neigh == 1 || ne_neigh == 3
                     ne_right = ne_neigh == 2 || ne_neigh == 3
                     e_backleft = e_neigh == 4 || e_neigh == 6
                     e_backright = e_neigh == 5 || e_neigh == 6
                     se_left = se_neigh == 1 || se_neigh == 3
                     s_backleft = s_neigh == 4 || s_neigh == 6
                     s_backright = s_neigh == 5 || s_neigh == 6
                     sw_left = sw_neigh == 1 || sw_neigh == 3
                     sw_right = sw_neigh == 2 || sw_neigh == 3
                     w_backleft = w_neigh == 4 || w_neigh == 6
                     w_backright = w_neigh == 5 || w_neigh == 6


                     leftcount = cell_right + nw_right + n_backleft + n_backright + ne_left + ne_right + e_backleft + e_backright + s_backleft + s_backright + sw_left + sw_right + w_backleft + w_backright

                     rightcount =  cell_left + n_backleft + n_backright + ne_left + ne_right + e_backleft + e_backright + se_left +  s_backleft + s_backright + sw_left + sw_right + w_backleft + w_backright

                   
                     newcell_left = birthrule[majcolor][leftcount];
                     newcell_right = birthrule[majcolor][rightcount];

                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };


               }  //end section for left-right cells

             break;

           // Radius2-Trilife

           case 30: 

                   n0 = cellist[0].extra
                   n1 = cellist[1].extra
                   n2 = cellist[2].extra
                   n3 = cellist[3].extra
                   //n4 = cellist[4].extra  // unused!
                   n5 = cellist[5].extra
                   n6 = cellist[6].extra
                   n7 = cellist[7].extra
                   n8 = cellist[8].extra
                   n9 = cellist[9].extra
                   n10 = cellist[10].extra
                   n11 = cellist[11].extra
                   n12 = cellist[12].extra
                   n13 = cellist[13].extra
                   n14 = cellist[14].extra
                   n15 = cellist[15].extra
                   n16 = cellist[16].extra
                   n17 = cellist[17].extra
                   n18 = cellist[18].extra
                   //n19 = cellist[19].extra  // unused!
                   n20 = cellist[20].extra
                   n21= cellist[21].extra
                   n22 = cellist[22].extra
                   n23 = cellist[23].extra

                   cell_left =  cel.extra == 1 || cel.extra == 3;
                   cell_right = cel.extra == 2 || cel.extra == 3;

                   n0_left =  n0  == 1 || n0  == 3;
                   n0_right = n0  == 2 || n0 == 3;

                   n1_left =  n1 == 1 || n1 == 3;
                   n1_right = n1  == 2 || n1 == 3;

                   n2_left =  n2 == 1 || n2 == 3;
                   n2_right = n2  == 2 || n2 == 3;


                   n3_left =  n3 == 1 || n3 == 3;
                   // no n4
                   n5_left =  n5 == 1 || n5 == 3;
                   n5_right = n5  == 2 || n5 == 3;

                   n6_left =  n6 == 1 || n6 == 3;
                   n6_right = n6  == 2 || n6 == 3;

                   n7_left =  n7 == 1 || n7 == 3;
                   n7_right = n7  == 2 || n7 == 3;

                   n8_left =  n8 == 1 || n8 == 3;
                   n8_right = n8  == 2 || n8 == 3;



                   n9_left =  n9 == 1 || n9 == 3;


                   n10_left =  n10 == 1 || n10 == 3;
                   n10_right = n10  == 2 || n10 == 3;

                   n11_left =  n11 == 1 || n11 == 3;
                   n11_right = n11  == 2 || n11 == 3;

                   n12_left =  n12 == 1 || n12 == 3;
                   n12_right = n12  == 2 || n12 == 3;

                   n13_left =  n13 == 1 || n13 == 3;
                   n13_right = n13  == 2 || n13 == 3;


                   n14_right = n14 == 2 || n14 == 3;


                   n15_left =  n15 == 1 || n15 == 3;
                   n15_right = n15  == 2 || n15 == 3;

                   n16_left =  n16 == 1 || n16 == 3;
                   n16_right = n16  == 2 ||n16 == 3;

                   n17_left =  n17 == 1 || n17 == 3;
                   n17_right = n17  == 2 || n17 == 3;

                   n18_left =  n18 == 1 || n18 == 3;
                   n18_right = n18 == 2 || n18 == 3;

                   // no n19

                   n20_right = n20 == 2 || n20 == 3;

                   
                   n21_left =  n21 == 1 || n21 == 3;
                   n21_right = n21  == 2 || n21 == 3;


                   n22_left =  n22 == 1 || n22 == 3;
                   n22_right = n22  == 2 || n22 == 3;


                   n23_left =  n23 == 1 || n23== 3;
                   n23_right = n23  == 2 || n23 == 3;



                   rightcount = cell_left + n0_left + n0_right  + n1_left + n1_right+ n2_left + n2_right + n3_left+ n5_left + n5_right + n6_left + n6_right + n7_left + n7_right + n8_left + n8_right + n9_left + n10_right + n11_left + n11_right + n12_left + n12_right + n13_left + n13_right  + n15_right + n16_left + n16_right + n17_left + n17_right + n18_left + n18_right  + n21_right + n22_left + n22_right + n23_left + n23_right ; 

                   leftcount =  cell_right + n0_left + n0_right  + n1_left + n1_right+ n2_left  + n5_left + n5_right + n6_left + n6_right + n7_left + n7_right + n8_left + n10_left + n10_right + n11_left + n11_right + n12_left + n12_right + n13_left   + n14_right + n15_left + n15_right + n16_left + n16_right + n17_left + n17_right + n18_left + n18_right + n20_right + n21_left + n21_right + n22_left + n22_right + n23_left + n23_right ;

                 //if ( majcolor == background) { document.getElementById("info_message2").innerHTML="why yes"} 
                 if ( cell_left != 0 || cell_right != 0) { document.getElementById("info_message2").innerHTML="why yes"} 

                 // If we know the entire cell is empty then this:
                   newcell_left = birthrule[majcolor][leftcount]
                   newcell_right = birthrule[majcolor][rightcount]
                   


                   if (newcell_right == 1) {
                     if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                     else {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;}
                   }
                   else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;}
                         else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                   };
                  break;



           case 15: 
                   celdotextra = cel.extra
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                   cell_left = celdotextra == 1 || celdotextra == 4 || celdotextra == 6 || celdotextra == 7;
                   cell_right = celdotextra == 2 || celdotextra == 5 || celdotextra == 6 || celdotextra == 7;
                   cell_top = celdotextra == 3 || celdotextra == 4 || celdotextra == 5 || celdotextra == 7;
                   nw_right = nw_neigh == 2 || nw_neigh == 5 || nw_neigh == 6 || nw_neigh == 7;
                   nw_left = nw_neigh == 1 || nw_neigh == 4 || nw_neigh == 6 || nw_neigh == 7;
                   n_left = n_neigh == 1 || n_neigh == 4 || n_neigh == 6 || n_neigh == 7;
                   n_right = n_neigh == 2 || n_neigh == 5 || n_neigh == 6 || n_neigh == 7;
                   e_left = e_neigh == 1 || e_neigh == 4 || e_neigh == 6 || e_neigh == 7;
                   e_top = e_neigh  == 3 || e_neigh == 4 || e_neigh == 5 || e_neigh == 7;
                   se_left = se_neigh == 1 || se_neigh == 4 || se_neigh == 6 || se_neigh == 7;
                   se_top = se_neigh  == 3 || se_neigh == 4 || se_neigh == 5 || se_neigh == 7;
                   s_right = s_neigh == 2 || s_neigh == 5 || s_neigh == 6 || s_neigh == 7;
                   s_top = s_neigh == 3 || s_neigh == 4 || s_neigh == 5 || s_neigh == 7;
                   w_right = w_neigh == 2 || w_neigh == 5 || w_neigh == 6 || w_neigh == 7;
                   w_top = w_neigh  == 3 || w_neigh == 4 || w_neigh == 5 || w_neigh == 7;
/*

                   topcount = cell_left + cell_right + nw_right + n_left  // the four side cells
                              + w_right + w_top + nw_left // the three corner cells to the west
                              + n_right + e_top + e_left; // the three corner cells to the east

                   leftcount = cell_top + cell_right + s_top + w_right // the four side cells
                                + w_top + nw_left + nw_right // the three corner cells to the top
                                + s_right + se_left + se_top; // the three corner cells to the bottom

                   rightcount = cell_left + cell_top + e_left + se_top // the four side cells
                                + n_left + n_right + e_top // the three corner cells to the top
                                +  s_top +  s_right + se_left  // the three corner cells to the bottom
*/

               
                   topcount = cell_left + cell_right + nw_right +  n_left +  m_or_vn_weight[majcolor] *( w_right + w_top + nw_left + n_right + e_top + e_left); 
                   leftcount = cell_top + cell_right + s_top +  w_right +  m_or_vn_weight[majcolor] *(w_top + nw_left + nw_right + s_right + se_left + se_top); 
                  rightcount = cell_left + cell_top + e_left +  se_top + m_or_vn_weight[majcolor] *(n_left + n_right + e_top  +  s_top +  s_right + se_left);


          
             // This is Qbert-VN6 (it includes the middle corner cells)
           //      topcount = cell_left + cell_right + nw_right +  n_left +     w_top  + e_top       + m_or_vn_weight[majcolor] *( w_right + nw_left + n_right + e_left); 
           //      leftcount = cell_top + cell_right + s_top +  w_right      + nw_left + se_left +  m_or_vn_weight[majcolor] *(w_top  + nw_right + s_right + se_top); 
           //      rightcount = cell_left + cell_top + e_left +  se_top      + n_right  +  s_right + m_or_vn_weight[majcolor] *(n_left + e_top + s_top + se_left);


             // This is Qbert-VN8 (it excludes the middle corner cells)
              //   topcount = cell_left + cell_right + nw_right +  n_left +    + m_or_vn_weight[majcolor] *(  w_top  + e_top  ) +       w_right + nw_left + n_right + e_left; 
             //    leftcount = cell_top + cell_right + s_top +  w_right     + m_or_vn_weight[majcolor] *(  nw_left + se_left)  +   w_top  + nw_right + s_right + se_top; 
            //     rightcount = cell_left + cell_top + e_left +  se_top     + m_or_vn_weight[majcolor] *(   n_right  +  s_right) + n_left + e_top + s_top + se_left;


                  // alert(topcount +"  "+ leftcount  +"  "+ rightcount)   

                  
                   // Birth & Survival
                      if (cell_top == 1) { newcell_top = survivalrule[majcolor][topcount]}
                      else  { newcell_top = birthrule[majcolor][topcount]  };

                      if (cell_left == 1) { newcell_left = survivalrule[majcolor][leftcount]}
                      else  { newcell_left = birthrule[majcolor][leftcount]  };


                      if (cell_right == 1) { newcell_right = survivalrule[majcolor][rightcount]}
                      else  { newcell_right = birthrule[majcolor][rightcount]  };


                      // Final results
                      // this could have used binary encoding, etc but it would have been harder to debug.
                         if (newcell_left == 0 && newcell_right == 0 && newcell_top == 0) 
                            {cel.placeholder_extra = 0; cel.placeholder_color = background;} 
                         else if (newcell_left == 1 && newcell_right == 0 && newcell_top == 0) 
                            {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;} 
                         else if (newcell_left == 0 && newcell_right == 1 && newcell_top == 0) 
                            {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;} 
                         else if (newcell_left == 0 && newcell_right == 0 && newcell_top == 1) 
                            {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                         else if (newcell_left == 1 && newcell_right == 0 && newcell_top == 1) 
                            {cel.placeholder_extra = 4; cel.placeholder_color = majcolor;} 
                         else if (newcell_left == 0 && newcell_right == 1 && newcell_top == 1) 
                            {cel.placeholder_extra = 5; cel.placeholder_color = majcolor;} 
                         else if (newcell_left == 1 && newcell_right == 1 && newcell_top == 0) 
                            {cel.placeholder_extra = 6; cel.placeholder_color = majcolor;} 
                         else if (newcell_left == 1 && newcell_right == 1 && newcell_top == 1) 
                            {cel.placeholder_extra = 7; cel.placeholder_color = majcolor;} 
                     break;

           case 51:   // Rhombus-VN-Radius2
                   celdotextra = cel.extra
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

 
                   cell_left = celdotextra == 1 || celdotextra == 4 || celdotextra == 6 || celdotextra == 7
                   cell_right = celdotextra == 2 || celdotextra == 5 || celdotextra == 6 || celdotextra == 7
                   cell_top = celdotextra == 3 || celdotextra == 4 || celdotextra == 5 || celdotextra == 7
                   nw_top = nw_neigh  == 3 || nw_neigh == 4 || nw_neigh == 5 || nw_neigh == 7
                   nw_right = nw_neigh == 2 || nw_neigh == 5 || nw_neigh == 6 || nw_neigh == 7
                   nw_left = nw_neigh == 1 || nw_neigh == 4 || nw_neigh == 6 || nw_neigh == 7
                   n_top = n_neigh  == 3 || n_neigh == 4 || n_neigh == 5 || n_neigh == 7
                   n_left = n_neigh == 1 || n_neigh == 4 || n_neigh == 6 || n_neigh == 7
                   n_right = n_neigh == 2 || n_neigh == 5 || n_neigh == 6 || n_neigh == 7
                   e_left = e_neigh == 1 || e_neigh == 4 || e_neigh == 6 || e_neigh == 7
                   e_right = e_neigh == 2 || e_neigh == 5 || e_neigh == 6 || e_neigh == 7
                   e_top = e_neigh  == 3 || e_neigh == 4 || e_neigh == 5 || e_neigh == 7
                   se_right = se_neigh == 2 || se_neigh == 5 || se_neigh == 6 || se_neigh == 7
                   se_left = se_neigh == 1 || se_neigh == 4 || se_neigh == 6 || se_neigh == 7
                   se_top = se_neigh  == 3 || se_neigh == 4 || se_neigh == 5 || se_neigh == 7
                   s_left = s_neigh == 1 || s_neigh == 4 || s_neigh == 6 || s_neigh == 7
                   s_right = s_neigh == 2 || s_neigh == 5 || s_neigh == 6 || s_neigh == 7
                   s_top = s_neigh == 3 || s_neigh == 4 || s_neigh == 5 || s_neigh == 7
                   w_right = w_neigh == 2 || w_neigh == 5 || w_neigh == 6 || w_neigh == 7
                   w_top = w_neigh  == 3 || w_neigh == 4 || w_neigh == 5 || w_neigh == 7
                   w_left = w_neigh == 1 || w_neigh == 4 || w_neigh == 6 || w_neigh == 7



                   topcount = cell_left + cell_right + nw_right +  n_left +  nw_left + nw_top + n_right + n_top + w_right + e_left + s_top + se_top;
                   leftcount = cell_top + cell_right + s_top +  w_right + s_left + s_right + w_left + w_top + nw_right + n_left + e_left + se_top;
                   rightcount = cell_left + cell_top + e_left +  se_top + e_right + e_top + se_left + se_right + s_top + nw_right + n_left + w_right;


                  // alert(topcount +"  "+ leftcount  +"  "+ rightcount)   

                  
                   // Birth & Survival
                      if (cell_top == 1) { newcell_top = survivalrule[majcolor][topcount]}
                      else  { newcell_top = birthrule[majcolor][topcount]  };

                      if (cell_left == 1) { newcell_left = survivalrule[majcolor][leftcount]}
                      else  { newcell_left = birthrule[majcolor][leftcount]  };


                      if (cell_right == 1) { newcell_right = survivalrule[majcolor][rightcount]}
                      else  { newcell_right = birthrule[majcolor][rightcount]  };


                      // Final results
                      // this could have used binary encoding, etc but it would have been harder to debug.
                         if (newcell_left == 0 && newcell_right == 0 && newcell_top == 0) 
                            {cel.placeholder_extra = 0; cel.placeholder_color = background;} 
                         else if (newcell_left == 1 && newcell_right == 0 && newcell_top == 0) 
                            {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;} 
                         else if (newcell_left == 0 && newcell_right == 1 && newcell_top == 0) 
                            {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;} 
                         else if (newcell_left == 0 && newcell_right == 0 && newcell_top == 1) 
                            {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                         else if (newcell_left == 1 && newcell_right == 0 && newcell_top == 1) 
                            {cel.placeholder_extra = 4; cel.placeholder_color = majcolor;} 
                         else if (newcell_left == 0 && newcell_right == 1 && newcell_top == 1) 
                            {cel.placeholder_extra = 5; cel.placeholder_color = majcolor;} 
                         else if (newcell_left == 1 && newcell_right == 1 && newcell_top == 0) 
                            {cel.placeholder_extra = 6; cel.placeholder_color = majcolor;} 
                         else if (newcell_left == 1 && newcell_right == 1 && newcell_top == 1) 
                            {cel.placeholder_extra = 7; cel.placeholder_color = majcolor;} 
                     break;

           case 52:  // Penta-Type9  birth case

                   celdotextra = cel.extra
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                   if ( (n_neigh == 6) || (ne_neigh == 3) || (w_neigh == 7) || (e_neigh == 7) || (sw_neigh == 4) || (s_neigh == 5) || (se_neigh == 4)) {
                      len = (n_neigh == 6) +  (w_neigh == 7) + (e_neigh == 7) +  (sw_neigh == 4) +(s_neigh == 5)  +  m_or_vn_weight[majcolor] *((ne_neigh == 3)+(se_neigh == 4))
                      if (birthrule[majcolor][len]) {cel.placeholder_color = majcolor; 
                                                           cel.placeholder_extra = 1
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                    else if ((nw_neigh == 4) || (n_neigh == 5)  || (w_neigh == 8) || (e_neigh == 8) || (sw_neigh == 3) || (s_neigh == 6) || (se_neigh == 3)) {
                      len =  (n_neigh == 5)  + (w_neigh == 8) + (e_neigh == 8) + (s_neigh == 6) +(se_neigh == 3) +  m_or_vn_weight[majcolor] *((nw_neigh == 4) + (sw_neigh == 3))
                      if (birthrule[majcolor][len]) {cel.placeholder_color = majcolor; 
                                                           cel.placeholder_extra = 2
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                   else if ((nw_neigh == 2) || (n_neigh == 8)  ||  (ne_neigh == 2) ||  (w_neigh == 6) ||  (e_neigh == 6) ||  (sw_neigh == 1) ||  (s_neigh == 7) ) {
                      len = (nw_neigh == 2) + (n_neigh == 8)  +  (w_neigh == 6) + (e_neigh == 6)  + (s_neigh == 7) +  m_or_vn_weight[majcolor] *((ne_neigh == 2) + (sw_neigh == 1))
                      if (birthrule[majcolor][len]) {cel.placeholder_color = majcolor; 
                                                           cel.placeholder_extra = 3
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                   else if ((nw_neigh == 1) || (n_neigh == 7)  || (ne_neigh == 1) || (w_neigh == 5) || (e_neigh == 5) || (s_neigh == 8) || (se_neigh == 2)) {
                      len =  (n_neigh == 7)  + (ne_neigh == 1) + (w_neigh == 5) + (e_neigh == 5) + (s_neigh == 8) +  m_or_vn_weight[majcolor] *((nw_neigh == 1)  + (se_neigh == 2))
                      if (birthrule[majcolor][len]) {cel.placeholder_color = majcolor; 
                                                           cel.placeholder_extra = 4
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                   else if ((n_neigh == 1) || (ne_neigh == 7) || (w_neigh == 4) || (e_neigh == 4) || (sw_neigh == 8) || (s_neigh == 2) || (se_neigh == 8)) {
                      len = (n_neigh == 1) + (w_neigh == 4) + (e_neigh == 4) + (s_neigh == 2) +(se_neigh == 8) +  m_or_vn_weight[majcolor] *((ne_neigh == 7) + (sw_neigh == 8))
                      if (birthrule[majcolor][len]) {cel.placeholder_color = majcolor; 
                                                           cel.placeholder_extra = 5
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                    else if ((nw_neigh == 8) || (n_neigh == 2)  || (w_neigh == 3) || (e_neigh == 3) || (sw_neigh == 7) || (s_neigh == 1) || (se_neigh == 7)) {
                      len =  (n_neigh == 2)  + (w_neigh == 3) + (e_neigh == 3) + (sw_neigh == 7) + (s_neigh == 1) +  m_or_vn_weight[majcolor] *((nw_neigh == 8) +(se_neigh == 7) )
                      if (birthrule[majcolor][len]) {cel.placeholder_color = majcolor; 
                                                           cel.placeholder_extra = 6
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                   else if ((nw_neigh == 6) || (n_neigh == 3)  || (ne_neigh == 6) || (w_neigh == 1) || (e_neigh == 1) || (sw_neigh == 5) || (s_neigh == 4) ) {
                      len =  (n_neigh == 3)  + (ne_neigh == 6) + (w_neigh == 1) + (e_neigh == 1) + (s_neigh == 4) +  m_or_vn_weight[majcolor] *((nw_neigh == 6) + (sw_neigh == 5) )
                      if (birthrule[majcolor][len]) {cel.placeholder_color = majcolor; 
                                                           cel.placeholder_extra = 7
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                   else if ((nw_neigh == 5) || (n_neigh == 4)  || (ne_neigh == 5) || (w_neigh == 2) || (e_neigh == 2) || (s_neigh == 3) || (se_neigh == 6)) {
                      len = (nw_neigh == 5) + (n_neigh == 4)  +  (w_neigh == 2) + (e_neigh == 2) + (s_neigh == 3)   +  m_or_vn_weight[majcolor] *((ne_neigh == 5) + (se_neigh == 6))
                      if (birthrule[majcolor][len]) {cel.placeholder_color = majcolor; 
                                                           cel.placeholder_extra = 8
                      }  
                      else {cel.placeholder_color = background;
                            cel.placeholder_extra = 0
                      }
                    }
                       
                  break;

 case 53:     // Penta-Type 14 Birth Case ("TYPE-E")

      //state 0 = background, 
      // 1 = red-left     2 = red-right,    3 = red-both, 
      // 4 = yellow-left, 5 = yellow-right, 6 = yellow-both, 
      // 7 = green-top,   8 = green-bottom, 9 = green-both
        
                   cellist = cel.neighbors;
                   celdotextra = cel.extra
                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

    if ((cel.xpos % 3 == 0 && cel.ypos % 3 == 0) || (cel.xpos % 3 == 1 && cel.ypos % 3 == 2)|| (cel.xpos % 3 == 2 && cel.ypos % 3 == 1)) {
      // then cell is a "Red" 

      cell_left = celdotextra == 1 || celdotextra == 3;
      cell_right =  celdotextra == 2 || celdotextra == 3;

       // the red cell's neighbors are either yellow or green
      nw_right = nw_neigh == 5 || nw_neigh == 6
      n_bottom = n_neigh == 8 || n_neigh == 9
      w_top = w_neigh == 7 || w_neigh == 9
      w_bottom = w_neigh == 8 || w_neigh == 9
      s_left = s_neigh == 4|| s_neigh == 6
      s_right = s_neigh == 5 || s_neigh == 6
      e_left = e_neigh == 4 || e_neigh == 6 
      se_top = se_neigh == 7|| se_neigh == 9

      leftcount = cell_right + nw_right + n_bottom + w_top + w_bottom + s_left + s_right
      rightcount = cell_left + n_bottom + e_left + s_right + se_top


                        newcell_left = birthrule[majcolor][leftcount]
                        newcell_right = birthrule[majcolor][rightcount]
                   

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 3; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 2; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 1; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };

   }  //end section for red  cells


  else  if ((cel.xpos % 3 == 0 && cel.ypos % 3 == 1) || (cel.xpos % 3 == 1 && cel.ypos % 3 == 0)
           || (cel.xpos % 3 == 2 && cel.ypos % 3 == 2)) {  // begin section for yellow cells

     // then cell is a "Yellow" 

      //state 0 = background, 
      // 1 = red-left     2 = red-right,    3 = red-both, 
      // 4 = yellow-left, 5 = yellow-right, 6 = yellow-both, 
      // 7 = green-top,   8 = green-bottom, 9 = green-both

      cell_left = celdotextra == 4 || celdotextra == 6;
      cell_right =  celdotextra == 5 || celdotextra == 6;

       // the yellow cell's neighbors are either red or green

       nw_bottom = nw_neigh == 8 || nw_neigh == 9
       n_left = n_neigh == 1 || n_neigh == 3
       n_right = n_neigh  == 2 || n_neigh == 3
       w_right = w_neigh ==  2 || w_neigh == 3
       s_top =  s_neigh == 7 || s_neigh == 9 
       e_top =   e_neigh == 7 || e_neigh == 9
       e_bottom = e_neigh == 8 || e_neigh == 9
       se_left = se_neigh == 1 || se_neigh == 3



       leftcount = cell_right + nw_bottom + n_left + w_right + s_top
       rightcount = cell_left + n_left +  n_right + e_top  +  e_bottom + se_left +  s_top

                         newcell_left = birthrule[majcolor][leftcount]
                         newcell_right = birthrule[majcolor][rightcount]
 
                      // either way:

                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 6; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 5; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 4; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}

                      };

   }  //end section for yellow  cells

         
 else  { //if ((cel.xpos % 3 == 0 && cel.ypos % 3 == 2) || (cel.xpos % 3 == 1 && cel.ypos % 3 == 1)
       //    || (cel.xpos % 3 == 2 && cel.ypos % 3 == 0)) {
         // then cell is a "green" 


      //state 0 = background, 
      // 1 = red-left     2 = red-right,    3 = red-both, 
      // 4 = yellow-left, 5 = yellow-right, 6 = yellow-both, 
      // 7 = green-top,   8 = green-bottom, 9 = green-both

     cell_top = cel.extra == 7 || cel.extra == 9;
     cell_bottom = cel.extra == 8 || cel.extra == 9;

       // the green cell's neighbors are either red or yellow

      nw_right = nw_neigh == 2 || nw_neigh ==  3 // red
      n_left = n_neigh == 4 || n_neigh ==  6    // yellow
      n_right = n_neigh == 5 || n_neigh == 6     // yellow
      w_right = w_neigh == 5 || w_neigh == 6   // yellow
      e_left = e_neigh == 1 || e_neigh == 3  // red
      s_left = s_neigh == 1 || s_neigh == 3   // red
      s_right = s_neigh == 2 || s_neigh ==  3 // red
      se_left = se_neigh == 4 || se_neigh == 6 // yellow
     

       topcount = cell_bottom + nw_right + n_left + n_right + w_right + e_left
       bottomcount = cell_top + w_right + e_left + s_left + s_right + se_left

                   
                       newcell_top = birthrule[majcolor][topcount]
                       newcell_bottom = birthrule[majcolor][bottomcount]
                   

                      // either way:

                      if (newcell_bottom == 1) {
                        if (newcell_top == 1) {cel.placeholder_extra = 9; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 8; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_top == 1) {cel.placeholder_extra = 7; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                      };
                } // end section for top-bottom cells

             break;

case 54:     // Triakis-Triangular Tiling   -- Birth case
                 // binary code for the six cellular subdivisions in the hexagon
                   // 000001 = top_inner,
                   // 000010 = top_outer, 
                   // 000100 = left_inner,
                  //  001000 = left_outer,
                  //  010000 = right_inner, 
                  //  100000 = right_outer


                   cellist = cel.neighbors;
                   celdotextra = cel.extra

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   // ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   // sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;

                   cell_left_inner = (celdotextra >> 2) & 1
                   cell_right_inner = (celdotextra >> 4) & 1
                   cell_top_inner = celdotextra & 1
 
                   cell_left_outer = (celdotextra  >> 3) & 1
                   cell_right_outer = (celdotextra >> 5) & 1
                   cell_top_outer = (celdotextra >> 1) & 1

                   nw_right_inner = (nw_neigh >> 4) & 1 
                   nw_left_inner = (nw_neigh >> 2) & 1
                   n_left_inner = (n_neigh >> 2) & 1
                   n_right_inner = (n_neigh >> 4) & 1
                   e_left_inner = (e_neigh >> 2) & 1
                   e_top_inner = e_neigh & 1   
                   se_left_inner = (se_neigh >> 2) & 1
                   se_top_inner = se_neigh & 1  
                   s_right_inner = (s_neigh >> 4) & 1
                   s_top_inner = s_neigh & 1 
                   w_right_inner = (w_neigh >> 4) & 1
                   w_top_inner = w_neigh  & 1 

                   nw_right_outer = (nw_neigh >> 5) & 1
                   nw_left_outer = (nw_neigh >> 3) & 1
                   n_left_outer = (n_neigh >> 3) & 1
                   n_right_outer = (n_neigh >> 5) & 1
                   e_left_outer = (e_neigh >> 3) & 1
                   e_top_outer = (e_neigh >> 1) & 1 
                   se_left_outer = (se_neigh >> 3) & 1
                   se_top_outer = (se_neigh >> 1) & 1 
                   s_right_outer = (s_neigh >> 5) & 1 
                   s_top_outer = (s_neigh >> 1) & 1
                   w_right_outer = (w_neigh >> 5) & 1
                   w_top_outer = (w_neigh >> 1) & 1

                  topcount_inner = cell_top_outer
                              + cell_left_inner + cell_right_inner + nw_right_inner + n_left_inner  // the four side cells
                              + w_right_inner + w_top_inner + nw_left_inner // the three corner cells to the west
                              + n_right_inner + e_top_inner + e_left_inner // the three corner cells to the east

                              + cell_left_outer + cell_right_outer + nw_right_outer + n_left_outer  // the four side cells
                              + w_right_outer + w_top_outer + nw_left_outer // the three corner cells to the west
                              + n_right_outer + e_top_outer + e_left_outer; // the three corner cells to the east

                   topcount_outer = cell_top_inner
                              + cell_left_inner + cell_right_inner + nw_right_inner + n_left_inner  // the four side cells
                              + w_right_inner + w_top_inner + nw_left_inner // the three corner cells to the west
                              + n_right_inner + e_top_inner + e_left_inner // the three corner cells to the east

                              + cell_left_outer + cell_right_outer + nw_right_outer + n_left_outer  // the four side cells
                              + w_right_outer + w_top_outer + nw_left_outer // the three corner cells to the west
                              + n_right_outer + e_top_outer + e_left_outer; // the three corner cells to the east

                   leftcount_inner = cell_left_outer
                                + cell_top_inner + cell_right_inner + s_top_inner + w_right_inner // the four side cells
                                + w_top_inner + nw_left_inner + nw_right_inner // the three corner cells to the top
                                + s_right_inner + se_left_inner + se_top_inner // the three corner cells to the bottom

                                + cell_top_outer + cell_right_outer + s_top_outer +  w_right_outer // the four side cells
                                + w_top_outer + nw_left_outer + nw_right_outer // the three corner cells to the top
                                + s_right_outer + se_left_outer + se_top_outer; // the three corner cells to the bottom

                   leftcount_outer = cell_left_inner
                                + cell_top_inner + cell_right_inner + s_top_inner + w_right_inner // the four side cells
                                + w_top_inner + nw_left_inner + nw_right_inner // the three corner cells to the top
                                + s_right_inner + se_left_inner + se_top_inner // the three corner cells to the bottom

                                + cell_top_outer + cell_right_outer + s_top_outer +  w_right_outer // the four side cells
                                + w_top_outer + nw_left_outer + nw_right_outer // the three corner cells to the top
                                + s_right_outer + se_left_outer + se_top_outer; // the three corner cells to the bottom

                   rightcount_inner = cell_right_outer
                                + cell_left_inner + cell_top_inner + e_left_inner + se_top_inner // the four side cells
                                + n_left_inner + n_right_inner + e_top_inner // the three corner cells to the top
                                +  s_top_inner +  s_right_inner + se_left_inner  // the three corner cells to the bottom

                                + cell_left_outer + cell_top_outer + e_left_outer + se_top_outer // the four side cells
                                + n_left_outer + n_right_outer + e_top_outer // the three corner cells to the top
                                +  s_top_outer +  s_right_outer + se_left_outer  // the three corner cells to the bottom
 
                   rightcount_outer = cell_right_inner
                                + cell_left_inner + cell_top_inner + e_left_inner + se_top_inner // the four side cells
                                + n_left_inner + n_right_inner + e_top_inner // the three corner cells to the top
                                +  s_top_inner +  s_right_inner + se_left_inner  // the three corner cells to the bottom

                                + cell_left_outer + cell_top_outer + e_left_outer + se_top_outer // the four side cells
                                + n_left_outer + n_right_outer + e_top_outer // the three corner cells to the top
                                +  s_top_outer +  s_right_outer + se_left_outer  // the three corner cells to the bottom   

                     newcell_top_inner = birthrule[majcolor][topcount_inner]
                     newcell_top_outer = birthrule[majcolor][topcount_outer]
                     newcell_left_inner  = birthrule[majcolor][leftcount_inner]
                     newcell_left_outer  = birthrule[majcolor][leftcount_outer]
                     newcell_right_inner  = birthrule[majcolor][rightcount_inner]
                     newcell_right_outer = birthrule[majcolor][rightcount_outer]

                      cel.placeholder_extra = newcell_top_inner + (newcell_top_outer << 1) + (newcell_left_inner << 2) + (newcell_left_outer << 3) + (newcell_right_inner << 4) + (newcell_right_outer << 5)
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = majcolor} 
                      else {cel.placeholder_color = background}
                  break;

case 55:   // Snub Hexagonal Tiling --  Birth Case

                  cellist = cel.neighbors;
                  celdotextra = cel.extra;

                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;


/* 
 19 states:

0 background
1 upward_left   001
2 upward_middle  010
3 upward_left_and_middle 011
4 upward_right   100
5 upward_left_and_right 101
6 upward_middle_and_right 110
7 upward_all_three  111

8 downward_left
9 downward_middle
10 downward_left_and_middle
11 downward_right
12 downward_left_and_right
13 downward_middle_and_right
14 downward_all_three

15 centersquare_left
16 centersquare_right
17 centersquare_both
18 hexagon
*/


/*  Here's how to access each kind of cell
cell_upward_left = celdotextra == 1 || celdotextra == 3 || celdotextra == 5 || celdotextra == 7
cell_upward_middle = celdotextra == 2 || celdotextra == 3 || celdotextra == 6 || celdotextra == 7
cell_upward_right =  celdotextra == 4 || celdotextra == 5 || celdotextra == 6 || celdotextra == 7 

cell_downward_left = celdotextra == 8 || celdotextra == 10 || celdotextra == 12 || celdotextra == 14 
cell_downward_middle = celdotextra == 9 || celdotextra == 10 || celdotextra == 13 || celdotextra == 14
cell_downward_right = celdotextra == 11 || celdotextra == 12 || celdotextra == 13 || celdotextra == 14 

cell_centersquare_left = celdotextra == 15 || celdotextra == 17 
cell_centersquare_right = celdotextra == 16 || celdotextra == 17 

cell_hexagon = (celdotextra  == 18)
*/


   // center squares
   if ((cel.ypos % 4 == 0 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 2 && cel.xpos % 2 == 1))  {
          cell_left = celdotextra == 15 || celdotextra == 17
          cell_right = celdotextra == 16 || celdotextra == 17
          nw_downward_right = nw_neigh == 11 || nw_neigh == 12 || nw_neigh == 13 || nw_neigh == 14  
          n_upward_left = n_neigh == 1 || n_neigh == 3 || n_neigh == 5 || n_neigh == 7
          n_upward_middle = n_neigh == 2 || n_neigh == 3 || n_neigh == 6 || n_neigh == 7
          n_upward_right = n_neigh == 4 || n_neigh == 5 || n_neigh == 6 || n_neigh == 7 
          w_hexagon = (w_neigh  == 18)
          e_hexagon =  (e_neigh  == 18)
          sw_upward_middle = sw_neigh == 2 || sw_neigh == 3 || sw_neigh == 6 || sw_neigh == 7
          sw_upward_right = sw_neigh == 4 || sw_neigh == 5 || sw_neigh == 6 || sw_neigh == 7 
          s_downward_left = s_neigh == 8 || s_neigh == 10 || s_neigh == 12 || s_neigh == 14 
          s_downward_middle =  s_neigh == 9 || s_neigh == 10 || s_neigh == 13 || s_neigh == 14
          
          
          leftcount = nw_downward_right + n_upward_left + w_hexagon + e_hexagon + cell_right + sw_upward_middle + sw_upward_right + s_downward_left + s_downward_middle
          rightcount = nw_downward_right + n_upward_left + n_upward_middle + n_upward_right + w_hexagon + e_hexagon + cell_left + s_downward_left + s_downward_middle

          // Apply Birth and Survive rules to each side of the cell
                   
                     newcell_left = birthrule[majcolor][leftcount];
                     newcell_right = birthrule[majcolor][rightcount];


                    // Now return the final cell value for left-right cells


                      if (newcell_right == 1) {
                        if (newcell_left == 1) {cel.placeholder_extra = 17; cel.placeholder_color = majcolor;} 
                        else {cel.placeholder_extra = 16; cel.placeholder_color = majcolor;}
                      }
                      else {if (newcell_left == 1) {cel.placeholder_extra = 15; cel.placeholder_color = majcolor;}
                            else {cel.placeholder_extra = 0; cel.placeholder_color = background;}
                      };
                } // end section for split center square  cells

           // Hexagons
   else if ((cel.ypos % 4 == 2 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 0 && cel.xpos % 2 == 1))  {

               nw_upward_left = nw_neigh == 1 || nw_neigh == 3 || nw_neigh == 5 || nw_neigh == 7
               nw_upward_middle = nw_neigh == 2 || nw_neigh == 3 || nw_neigh == 6 || nw_neigh == 7
               nw_upward_right  =  nw_neigh == 4 || nw_neigh == 5 || nw_neigh == 6 || nw_neigh == 7 
               n_downward_left  = n_neigh == 8 || n_neigh == 10 || n_neigh == 12 || n_neigh == 14 
               n_downward_middle = n_neigh == 9 || n_neigh == 10 || n_neigh == 13 || n_neigh == 14
               n_downward_right = n_neigh == 11 || n_neigh == 12 || n_neigh == 13 || n_neigh == 14 
               ne_upward_left = ne_neigh == 1 || ne_neigh == 3 || ne_neigh == 5 || ne_neigh == 7
               w_centersquare_left = w_neigh == 15 || w_neigh == 17 
               w_centersquare_right  = w_neigh == 16 || w_neigh == 17 
               e_centersquare_left = e_neigh == 15 || e_neigh == 17 
               e_centersquare_right = e_neigh == 16 || e_neigh == 17
               sw_downward_left  = sw_neigh == 8 || sw_neigh == 10 || sw_neigh == 12 || sw_neigh == 14 
               sw_downward_middle  = sw_neigh == 9 || sw_neigh == 10 || sw_neigh == 13 || sw_neigh == 14
               sw_downward_right = sw_neigh == 11 || sw_neigh == 12 || sw_neigh == 13 || sw_neigh == 14 
               s_upward_left = s_neigh == 1 || s_neigh == 3 || s_neigh == 5 || s_neigh == 7
               s_upward_middle = s_neigh == 2 || s_neigh == 3 || s_neigh == 6 || s_neigh == 7
               s_upward_right =  s_neigh == 4 || s_neigh == 5 || s_neigh == 6 || s_neigh == 7 
               se_downward_left  = se_neigh == 8 || se_neigh == 10 || se_neigh == 12 || se_neigh == 14 

             mycount = nw_upward_left + nw_upward_middle + nw_upward_right + n_downward_left + n_downward_middle + n_downward_right + ne_upward_left + w_centersquare_left + w_centersquare_right +  e_centersquare_left + e_centersquare_right + sw_downward_left + sw_downward_middle + sw_downward_right + s_upward_left + s_upward_middle + s_upward_right + se_downward_left
                      
                  if (birthrule[majcolor][mycount]) {cel.placeholder_color = majcolor; cel.placeholder_extra = 18} 
                  else {cel.placeholder_color = background; cel.placeholder_extra = 0};

      } // end section for Hexagons
     //   Upward Trio above the central square
 else if ((cel.ypos % 4 == 3 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 1 && cel.xpos % 2 == 1))   {

               cell_upward_left = celdotextra == 1 || celdotextra == 3 || celdotextra == 5 || celdotextra == 7
               cell_upward_middle = celdotextra == 2 || celdotextra == 3 || celdotextra == 6 || celdotextra == 7
               cell_upward_right =  celdotextra == 4 || celdotextra == 5 || celdotextra == 6 || celdotextra == 7  

               n_hexagon = (n_neigh  == 18)
               ne_centersquare_left = ne_neigh == 15 || ne_neigh == 17 
               w_downward_middle = w_neigh == 9 || w_neigh == 10 || w_neigh == 13 || w_neigh == 14
               w_downward_right = w_neigh == 11 || w_neigh == 12 || w_neigh == 13 || w_neigh == 14 
               sw_hexagon = (sw_neigh  == 18)
               s_centersquare_left = s_neigh == 15 || s_neigh == 17 
               s_centersquare_right = s_neigh == 16 || s_neigh == 17 
               se_hexagon = (se_neigh  == 18) 
               e_downward_left = e_neigh == 8 || e_neigh == 10 || e_neigh == 12 || e_neigh == 14 
               e_downward_middle = e_neigh == 9 || e_neigh == 10 || e_neigh == 13 || e_neigh == 14
               e_downward_right = e_neigh == 11 || e_neigh == 12 || e_neigh == 13 || e_neigh == 14 

               leftcount = n_hexagon + w_downward_middle + w_downward_right + cell_upward_middle + cell_upward_right + sw_hexagon + s_centersquare_left + s_centersquare_right + se_hexagon
               middlecount = n_hexagon + ne_centersquare_left + w_downward_middle + w_downward_right + cell_upward_left + cell_upward_right + e_downward_left + s_centersquare_right + se_hexagon
               rightcount =  n_hexagon + ne_centersquare_left + cell_upward_left + cell_upward_middle + e_downward_left + e_downward_middle + e_downward_right + s_centersquare_right + se_hexagon

                       newcell_upward_right = birthrule[majcolor][rightcount]  

                       newcell_upward_left = birthrule[majcolor][leftcount]  

                       newcell_upward_middle = birthrule[majcolor][middlecount]  

                      // For upward, this works:
                      cel.placeholder_extra = newcell_upward_left + (newcell_upward_middle << 1) + (newcell_upward_right << 2)                           
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = majcolor} 
                      else {cel.placeholder_color = background}

      } // end section for Upward Trio


     //   section for Downwards Trio, above the hexagon
  else if ((cel.ypos % 4 == 1 && cel.xpos % 2 == 0) || (cel.ypos % 4 == 3 && cel.xpos % 2 == 1))  {

               cell_downward_left = celdotextra == 8 || celdotextra == 10 || celdotextra == 12 || celdotextra == 14 
               cell_downward_middle = celdotextra == 9 || celdotextra == 10 || celdotextra == 13 || celdotextra == 14
               cell_downward_right = celdotextra == 11 || celdotextra == 12 || celdotextra == 13 || celdotextra == 14 
/* 
 19 states:

0 background
1 upward_left   001
2 upward_middle  010
3 upward_left_and_middle 011
4 upward_right   100
5 upward_left_and_right 101
6 upward_middle_and_right 110
7 upward_all_three  111

8 downward_left
9 downward_middle
10 downward_left_and_middle
11 downward_right
12 downward_left_and_right
13 downward_middle_and_right
14 downward_all_three

15 centersquare_left
16 centersquare_right
17 centersquare_both
18 hexagon
*/


                  nw_hexagon = (nw_neigh  == 18)
                  n_centersquare_left = n_neigh == 15 || n_neigh == 17 
                  n_centersquare_right = n_neigh == 16 || n_neigh == 17 
                  ne_hexagon = (ne_neigh  == 18)
                  w_upward_middle = w_neigh == 2 || w_neigh == 3 || w_neigh == 6 || w_neigh == 7
                  w_upward_right =  w_neigh == 4 || w_neigh == 5 || w_neigh == 6 || w_neigh == 7 
                  s_hexagon = (s_neigh  == 18) 
                  e_upward_left = e_neigh == 1 || e_neigh == 3 || e_neigh == 5 || e_neigh == 7
                  e_upward_middle = e_neigh == 2 || e_neigh == 3 || e_neigh == 6 || e_neigh == 7
                 se_centersquare_left = se_neigh == 15 || se_neigh == 17 
                 se_centersquare_right  = se_neigh == 16 || se_neigh == 17  

               leftcount = nw_hexagon + n_centersquare_left + n_centersquare_right + ne_hexagon + w_upward_middle + w_upward_right + cell_downward_middle + cell_downward_right + s_hexagon
               middlecount = n_centersquare_left + n_centersquare_right + ne_hexagon + w_upward_right + cell_downward_left + cell_downward_right +  e_upward_left + e_upward_middle + s_hexagon
               rightcount = ne_hexagon + w_upward_right + cell_downward_left + cell_downward_middle + e_upward_left + e_upward_middle + s_hexagon + se_centersquare_left + se_centersquare_right

                      newcell_downward_right = birthrule[majcolor][rightcount]  

                      newcell_downward_left = birthrule[majcolor][leftcount]  

                      newcell_downward_middle = birthrule[majcolor][middlecount]  

/*
8 downward_left
9 downward_middle
10 downward_left_and_middle
11 downward_right
12 downward_left_and_right
13 downward_middle_and_right
14 downward_all_three
*/

                       cel.placeholder_extra = 7 + newcell_downward_left + (newcell_downward_middle << 1) + (newcell_downward_right << 2)                         
                      if (cel.placeholder_extra > 7) {cel.placeholder_color = majcolor} 
                      else {cel.placeholder_color = background; cel.placeholder_extra = 0}


/*
                         if (newcell_downward_left == 0 && newcell_downward_middle == 0 && newcell_downward_right == 0) 
                            {cel.placeholder_extra = 0; cel.placeholder_color = background;} 

                         else if (newcell_downward_left == 1 && newcell_downward_middle == 0 && newcell_downward_right == 0) 
                            {cel.placeholder_extra = 8; cel.placeholder_color = majcolor;} 

                         else if (newcell_downward_left == 0 && newcell_downward_middle == 1 && newcell_downward_right == 0) 
                            {cel.placeholder_extra = 9; cel.placeholder_color = majcolor;} 

                        else if (newcell_downward_left == 1 && newcell_downward_middle == 1 && newcell_downward_right == 0) 
                            {cel.placeholder_extra = 10; cel.placeholder_color = majcolor;} 

                         else if (newcell_downward_left == 0 && newcell_downward_middle == 0 && newcell_downward_right == 1) 
                            {cel.placeholder_extra = 11; cel.placeholder_color = majcolor;} 

                         else if (newcell_downward_left == 1 && newcell_downward_middle == 0 && newcell_downward_right == 1) 
                            {cel.placeholder_extra = 12; cel.placeholder_color = majcolor;} 
                         else if (newcell_downward_left == 0 && newcell_downward_middle == 1 && newcell_downward_right == 1) 
                            {cel.placeholder_extra = 13; cel.placeholder_color = majcolor;} 
                          else if (newcell_downward_left == 1 && newcell_downward_middle == 1 && newcell_downward_right == 1) 
                            {cel.placeholder_extra = 14; cel.placeholder_color = majcolor;} 
   */

      } // end section for Downward Trio
  break;



        case 56:  // Kisrhombile Tiling  -- Birth case

                    // Just like  Deltoidal TriHexagonal (Kites) but split each cell into "leading" and "following"               
              

                   cellist = cel.neighbors;


                   nw_neigh = cellist[0].extra;
                   n_neigh = cellist[1].extra;
                   // ne_neigh = cellist[2].extra;
                   w_neigh = cellist[3].extra;
                   e_neigh = cellist[4].extra;
                   // sw_neigh = cellist[5].extra;
                   s_neigh = cellist[6].extra;
                   se_neigh = cellist[7].extra;



                   celdotextra = cel.extra

                   cell_top_left_leading = celdotextra & 1
                   cell_top_right_leading  = (celdotextra >> 1) & 1
                   cell_mid_left_leading = (celdotextra >> 2) & 1
                   cell_mid_right_leading  = (celdotextra >> 3) & 1
                   cell_bot_left_leading = (celdotextra >> 4) & 1
                   cell_bot_right_leading  = (celdotextra >> 5) & 1

                   cell_top_left_trailing = ( celdotextra  >> ( 0  + 6 )) & 1
                   cell_top_right_trailing  = (celdotextra  >> ( 1 + 6 )) & 1
                   cell_mid_left_trailing = (celdotextra  >> ( 2 + 6 )) & 1
                   cell_mid_right_trailing  = (celdotextra  >> ( 3 + 6 )) & 1
                   cell_bot_left_trailing = (celdotextra  >> ( 4 + 6 )) & 1
                   cell_bot_right_trailing  = (celdotextra  >> ( 5 + 6 )) & 1


                   nw_bot_left_leading = (nw_neigh >> 4) & 1
                   nw_bot_right_leading  = (nw_neigh >> 5) & 1
                   w_bot_right_leading   = (w_neigh >> 5) & 1
                   w_mid_right_leading  = (w_neigh >> 3) & 1  
                   n_mid_left_leading = (n_neigh >> 2) & 1
                   n_bot_left_leading = (n_neigh >> 4) & 1
                   e_top_left_leading = e_neigh & 1
                   e_mid_left_leading = (e_neigh >> 2) & 1
                   se_top_right_leading   = (se_neigh >> 1) & 1
                   se_top_left_leading  = se_neigh & 1
                   s_mid_right_leading   = (s_neigh >> 3) & 1
                   s_top_right_leading  = (s_neigh >> 1) & 1

                   nw_bot_left_trailing = (nw_neigh  >> ( 4 + 6 )) & 1
                   nw_bot_right_trailing  = (nw_neigh  >> ( 5 + 6 )) & 1
                   w_bot_right_trailing   = (w_neigh  >> ( 5 + 6 )) & 1
                   w_mid_right_trailing  = (w_neigh  >> ( 3 + 6 )) & 1  
                   n_mid_left_trailing = (n_neigh  >> ( 2 + 6 )) & 1
                   n_bot_left_trailing = (n_neigh  >> ( 4 + 6 )) & 1
                   e_top_left_trailing = (e_neigh >> (0 + 6)) & 1
                   e_mid_left_trailing = (e_neigh  >> ( 2 + 6 )) & 1
                   se_top_right_trailing   = (se_neigh  >> ( 1 + 6 )) & 1
                   se_top_left_trailing  = (se_neigh >> (0 + 6)) & 1
                   s_mid_right_trailing   = (s_neigh  >> ( 3 + 6 )) & 1
                   s_top_right_trailing  = (s_neigh  >> ( 1 + 6 )) & 1

    

                  top_leftcount_leading = cell_top_left_trailing 
                                           + cell_top_right_trailing +  cell_mid_left_trailing +  w_mid_right_trailing +  nw_bot_left_trailing
                                           + cell_mid_right_trailing +  cell_bot_left_trailing + cell_bot_right_trailing + cell_top_right_leading
                                           +  cell_mid_left_leading +  w_mid_right_leading +  nw_bot_left_leading + nw_bot_right_leading 
                                           +  cell_mid_right_leading +  cell_bot_left_leading +  cell_bot_right_leading

                  top_leftcount_trailing = cell_top_left_leading
                                           + cell_top_right_trailing +  cell_mid_left_trailing + w_mid_right_trailing + nw_bot_left_trailing 
                                           + cell_mid_right_trailing + cell_bot_left_trailing + cell_bot_right_trailing +   w_bot_right_trailing
                                           +  cell_top_right_leading + cell_mid_left_leading + w_mid_right_leading +  nw_bot_left_leading 
                                           + cell_mid_right_leading + cell_bot_left_leading + cell_bot_right_leading

                 top_rightcount_leading =  cell_top_right_trailing
                                            + cell_top_left_leading + cell_mid_right_leading  + n_mid_left_leading + nw_bot_right_leading + n_bot_left_leading 
                                            + cell_bot_right_leading  + cell_bot_left_leading + cell_mid_left_leading + cell_top_left_trailing 
                                            + cell_mid_right_trailing  + n_mid_left_trailing + nw_bot_right_trailing + cell_bot_right_trailing 
                                            + cell_bot_left_trailing + cell_mid_left_trailing  


                  top_rightcount_trailing = cell_top_right_leading
                                   + cell_top_left_leading + cell_mid_right_leading  + n_mid_left_leading + nw_bot_right_leading 
                                  + cell_bot_right_leading  + cell_bot_left_leading + cell_mid_left_leading    
                                  + cell_top_left_trailing + cell_mid_right_trailing  + n_mid_left_trailing + nw_bot_right_trailing 
                                  + cell_bot_right_trailing  + cell_bot_left_trailing + cell_mid_left_trailing + nw_bot_left_trailing


                  mid_rightcount_leading  = cell_mid_right_trailing 
                                   + cell_top_right_leading  + cell_bot_right_leading  + n_bot_left_leading + e_top_left_leading
                                  + e_mid_left_leading  + cell_bot_left_leading + cell_mid_left_leading + cell_top_left_leading   
                                  +  cell_top_right_trailing  + cell_bot_right_trailing  + n_bot_left_trailing + e_top_left_trailing
                                   + cell_bot_left_trailing + cell_mid_left_trailing + cell_top_left_trailing    


                  mid_rightcount_trailing  = cell_mid_right_leading
                                   + cell_top_right_leading  + cell_bot_right_leading  + n_bot_left_leading + e_top_left_leading
                                   + cell_bot_left_leading + cell_mid_left_leading + cell_top_left_leading    
                                   + cell_top_right_trailing  + cell_bot_right_trailing  + n_bot_left_trailing + e_top_left_trailing
                                   + cell_bot_left_trailing + cell_mid_left_trailing + cell_top_left_trailing + n_mid_left_trailing  

              mid_leftcount_leading  =  cell_mid_left_trailing
                                  + cell_top_left_leading + cell_bot_left_leading + s_top_right_leading  + w_bot_right_leading 
                                  + w_mid_right_leading  +  cell_top_right_leading  + cell_mid_right_leading  + cell_bot_right_leading    
                                  + cell_top_left_trailing + cell_bot_left_trailing + s_top_right_trailing  + w_bot_right_trailing 
                                  +  cell_top_right_trailing  + cell_mid_right_trailing  + cell_bot_right_trailing   

                  mid_leftcount_trailing  =  cell_mid_left_leading
                                   + cell_top_left_leading + cell_bot_left_leading + s_top_right_leading  + w_bot_right_leading 
                                   +  cell_top_right_leading  + cell_mid_right_leading  + cell_bot_right_leading  
                                   + cell_top_left_trailing + cell_bot_left_trailing + s_top_right_trailing  + w_bot_right_trailing 
                                   +  cell_top_right_trailing  + cell_mid_right_trailing  + cell_bot_right_trailing   + s_mid_right_trailing  


                  bot_rightcount_leading  = cell_bot_right_trailing
                                  + cell_mid_right_leading  + cell_bot_left_leading + e_mid_left_leading + se_top_right_leading 
                                 +  se_top_left_leading +  + cell_mid_left_leading + cell_top_left_leading + cell_top_right_leading   
                                 + cell_mid_right_trailing  + cell_bot_left_trailing + e_mid_left_trailing + se_top_right_trailing 
                                      + cell_mid_left_trailing + cell_top_left_trailing + cell_top_right_trailing  

                 bot_rightcount_trailing  = cell_bot_right_leading
                                    + cell_mid_right_leading  + cell_bot_left_leading + e_mid_left_leading + se_top_right_leading 
                                    + cell_mid_left_leading + cell_top_left_leading + cell_top_right_leading   
                                    + cell_mid_right_trailing  + cell_bot_left_trailing + e_mid_left_trailing + se_top_right_trailing 
                                    + cell_mid_left_trailing + cell_top_left_trailing + cell_top_right_trailing  +  e_top_left_trailing  

                  bot_leftcount_leading  =  cell_bot_left_trailing
                                 + cell_mid_left_leading + cell_bot_right_leading  + s_mid_right_leading  + se_top_left_leading
                                 +  s_top_right_leading    + cell_top_right_leading  + cell_top_left_leading + cell_mid_right_leading  
                                 + cell_mid_left_trailing + cell_bot_right_trailing  + s_mid_right_trailing  + se_top_left_trailing
                                 + cell_top_right_trailing  + cell_top_left_trailing + cell_mid_right_trailing  

                  bot_leftcount_trailing  =  cell_bot_left_leading
                                     + cell_mid_left_leading + cell_bot_right_leading  + s_mid_right_leading  + se_top_left_leading
                                     + cell_top_right_leading  + cell_top_left_leading + cell_mid_right_leading 
                                     + cell_mid_left_trailing + cell_bot_right_trailing  + s_mid_right_trailing  + se_top_left_trailing
                                     + se_top_right_trailing  + cell_top_right_trailing  + cell_top_left_trailing + cell_mid_right_trailing  


    

                    newcell_top_left_leading = birthrule[majcolor][top_leftcount_leading ]

                    newcell_top_right_leading = birthrule[majcolor][top_rightcount_leading ]

                    newcell_mid_left_leading = birthrule[majcolor][mid_leftcount_leading ]

                     newcell_mid_right_leading = birthrule[majcolor][mid_rightcount_leading ]

                     newcell_bot_left_leading = birthrule[majcolor][bot_leftcount_leading ]

                    newcell_bot_right_leading = birthrule[majcolor][bot_rightcount_leading ]


                     newcell_top_left_trailing = birthrule[majcolor][top_leftcount_trailing ]

                     newcell_top_right_trailing = birthrule[majcolor][top_rightcount_trailing ]

                     newcell_mid_left_trailing = birthrule[majcolor][mid_leftcount_trailing ]

                     newcell_mid_right_trailing = birthrule[majcolor][mid_rightcount_trailing ]

                     newcell_bot_left_trailing = birthrule[majcolor][bot_leftcount_trailing ]

                     newcell_bot_right_trailing = birthrule[majcolor][bot_rightcount_trailing ]

                    cel.placeholder_extra = newcell_top_left_leading + (newcell_top_right_leading << 1) + (newcell_mid_left_leading << 2) + (newcell_mid_right_leading << 3) + (newcell_bot_left_leading << 4) + (newcell_bot_right_leading << 5) + (newcell_top_left_trailing << (6 +  0))  + (newcell_top_right_trailing << (6 +  1)) + (newcell_mid_left_trailing << (6 +  2)) + (newcell_mid_right_trailing << (6 +  3)) + (newcell_bot_left_trailing << (6 +  4)) + (newcell_bot_right_trailing << (6 +  5))

                      if (cel.placeholder_extra > 0) {cel.placeholder_color = majcolor} 
                      else {cel.placeholder_color = background}
                  break;



 case 57:   // Penta-668 Alternating Penta peace signs -- Birth case 
                      cellist = cel.neighbors;
                      nw_neigh = cellist[0].extra;
                      n_neigh = cellist[1].extra;
                     // ne_neigh = cellist[2].extra;
                      w_neigh = cellist[3].extra;
                      e_neigh = cellist[4].extra;
                     // sw_neigh = cellist[5].extra;
                      s_neigh = cellist[6].extra;
                      se_neigh = cellist[7].extra;
                      celdotextra = cel.extra;


                    // if celltype = "bottomish":

                    if ((cel.xpos % 2 == 0 && cel.ypos % 2 == 0) || (cel.xpos % 2 == 1 && cel.ypos % 2 == 1))   {
/*
0000 0
0001 1  top
0010 2  botleft
0011 3  botleft and top
0100 4  botribht
0101 5  botright and top
0110 6  botright and botleft
0111 7  top and botright and botleft
1000 8     bottom     
1001 9     topleft
1010 10    topleft and bottom
1011 11    topright
1100 12    topright and bottom
1101 13    topright and topleft
1110 14    bottom and topleft and topright
                         cell_bottom =     (celdotextra  - 7) & 1;
                         cell_topleft =    ((celdotextra - 7) >> 1) & 1;
                         cell_topright =   ((celdotextra - 7) >> 2) & 1;

                        nw_bottom =  (nw_neigh  - 7) & 1;
                        w_botright =  (w_neigh >> 2) & 1;
                        s_top =  s_neigh & 1;
                        s_botright = (s_neigh >> 2) & 1;
                        n_botleft =  (n_neigh >> 1) & 1;
                        e_top =  e_neigh & 1;
                        e_botleft =  (e_neigh >> 1) & 1;
                        se_topleft =  ((se_neigh - 7) >> 1) & 1; 
                        se_topright = ((se_neigh - 7) >> 2) & 1;

*/

                         cell_bottom =     (celdotextra == 8) || (celdotextra == 10) || (celdotextra == 12) || (celdotextra == 14)
                         cell_topleft =    (celdotextra == 9) || (celdotextra == 10) || (celdotextra == 13) || (celdotextra == 14)
                         cell_topright =    (celdotextra == 11) || (celdotextra == 12) || (celdotextra == 13) || (celdotextra == 14)

                        nw_bottom =  (nw_neigh == 8) || (nw_neigh == 10) || (nw_neigh == 12) || (nw_neigh == 14)
                        w_botright =  (w_neigh == 4) || (w_neigh == 5) || (w_neigh == 6) || (w_neigh == 7)
                        s_top =  (s_neigh == 1) || (s_neigh == 3) || (s_neigh == 5) || (s_neigh == 7)
                        s_botright = (s_neigh == 4) || (s_neigh == 5) || (s_neigh == 6) || (s_neigh == 7)
                        n_botleft =  (n_neigh == 2) || (n_neigh  == 3) || (n_neigh  == 6) || (n_neigh  == 7)
                        e_top =  (e_neigh == 1) || (e_neigh == 3) || (e_neigh == 5) || (e_neigh == 7)
                        e_botleft =  (e_neigh == 2) || (e_neigh  == 3) || (e_neigh  == 6) || (e_neigh  == 7)
                        se_topleft = (se_neigh == 9) || (se_neigh == 10) || (se_neigh == 13) || (se_neigh == 14)
                        se_topright = (se_neigh == 11) || (se_neigh == 12) || (se_neigh == 13) || (se_neigh == 14)





                          topleftcount = nw_bottom + w_botright + cell_topright + cell_bottom + s_top + s_botright;
                          toprightcount = nw_bottom + n_botleft + cell_topleft + cell_bottom + e_top + e_botleft;
                          botcount = cell_topleft + cell_topright + e_top + e_botleft + s_top + s_botright + se_topleft + se_topright;
   
   
                        newcell_bottom = birthrule[majcolor][botcount];

                        newcell_topright = birthrule[majcolor][toprightcount];

                        newcell_topleft = birthrule[majcolor][topleftcount];


                      cel.placeholder_extra = 7 + newcell_bottom + (newcell_topleft << 1) + (newcell_topright << 2);   
                      
                      if (cel.placeholder_extra > 7) {cel.placeholder_color = majcolor} 
                      else {cel.placeholder_color = background; cel.placeholder_extra = 0};


                   }


                   else {  
                            // if celltype == "topish":

                         cell_top = (celdotextra == 1) || (celdotextra == 3) || (celdotextra == 5) || (celdotextra == 7)
                         cell_botleft = (celdotextra == 2) || (celdotextra == 3) || (celdotextra == 6) || (celdotextra == 7)
                         cell_botright = (celdotextra == 4) || (celdotextra == 5) || (celdotextra == 6) || (celdotextra == 7)

                         e_topleft =  (e_neigh == 9) || (e_neigh == 10) || (e_neigh == 13) || (e_neigh == 14)
                         se_top =   (se_neigh == 1) || (se_neigh == 3) || (se_neigh == 5) || (se_neigh == 7)
                         s_topright = (s_neigh == 11) || (s_neigh == 12) || (s_neigh == 13) || (s_neigh == 14)
                         nw_botleft = (nw_neigh == 2) || (nw_neigh == 3) || (nw_neigh == 6) || (nw_neigh == 7)
                         nw_botright =  (nw_neigh == 4) || (nw_neigh == 5) || (nw_neigh == 6) || (nw_neigh == 7)
                         n_topleft =   (n_neigh == 9) || (n_neigh == 10) || (n_neigh == 13) || (n_neigh == 14)
                         n_bottom =   (n_neigh == 8) || (n_neigh == 10) || (n_neigh == 12) || (n_neigh == 14)
                         w_topright =  (w_neigh  == 11) || (w_neigh  == 12) || (w_neigh  == 13) || (w_neigh  == 14)
                         w_bottom =  (w_neigh == 8) || (w_neigh == 10) || (w_neigh == 12) || (w_neigh == 14)
/*
0000 0
0001 1  top
0010 2  botleft
0011 3  botleft and top
0100 4  botright
0101 5  botright and top
0110 6  botright and botleft
0111 7  top and botright and botleft
1000 8    1 bottom
1001 9    2 topleft
1010 10   3 topleft and bottom
1011 11   4 topright
1100 12   5 topright and bottom
1101 13   6 topright and topleft
1110 14   7 bottom and topleft and topright

                         cell_top = celdotextra & 1;
                         cell_botleft = (celdotextra >> 1) & 1;
                         cell_botright = (celdotextra >> 2) & 1;

                         e_topleft =   ((e_neigh - 7) >> 1) & 1;
                         se_top =   se_neigh & 1;
                         s_topright = ((s_neigh - 7) >> 2) & 1;
                         nw_botleft =  (nw_neigh >> 1) & 1;
                         nw_botright =  (nw_neigh >> 2) & 1;
                         n_topleft =   ((n_neigh - 7) >> 1) & 1;
                         n_bottom =  (n_neigh  - 7) & 1;
                         w_topright =  ((w_neigh - 7) >> 2) & 1;
                         w_bottom =  (w_neigh  - 7) & 1;

*/
                        
                            botrightcount = n_topleft + n_bottom + cell_top + cell_botleft + e_topleft + se_top;
                            botleftcount = w_topright + w_bottom + cell_top + cell_botright + se_top + s_topright;
                            topcount =  nw_botleft + nw_botright + n_topleft + n_bottom + cell_botleft + cell_botright + w_topright + w_bottom;

                       newcell_top = birthrule[majcolor][topcount];
                       newcell_botright = birthrule[majcolor][botrightcount];
                       newcell_botleft = birthrule[majcolor][botleftcount];

                      cel.placeholder_extra = newcell_top + (newcell_botleft << 1) + (newcell_botright << 2);                         
                      if (cel.placeholder_extra > 0) {cel.placeholder_color = majcolor} 
                      else {cel.placeholder_color = background};
                  }; // end if-then statement
                  break;   


      case 16:   unweighted_len = len;
                  len = weightrule[majcolor][0]*bx2(cellist[0]) + weightrule[majcolor][1]*bx2(cellist[1]) + weightrule[majcolor][2]*bx2(cellist[2]) 
                        + weightrule[majcolor][3]*bx2(cellist[3]) + weightrule[majcolor][4]*bx2(cellist[4]) + weightrule[majcolor][5]*bx2(cellist[5]) 
                        + weightrule[majcolor][6]*bx2(cellist[6]) + weightrule[majcolor][7]*bx2(cellist[7]) ;

                   if (birthrule[majcolor][len] ) {cel.placeholder_color = majcolor; cel.placeholder_extra = 1 }
                                             else {cel.placeholder_color = background; 
                                                   //cel.placeholder_extra = 0
                                                   };                    
                   break;





      } // end of switch
   }   // end of else section
}   
  




function c1 (a)  {if (a.color != background && a.color != decaygray) {return 1} else {return 0}} ;

// The following function is for rules like B1x2/S23V
function bx2(a)  {if (a.color != background && a.color != decaygray && a.extra == 2) {return 1} else {return 0}} ;  // probably could be just testing for .extra



function velocitybirth (cel, len) {   // relies on the global variable "cellist"
   //  I think it would be more correct to let len = getaliveneighbors(cel.neighbors) which takes decaygray cells into account -- as it stands, they have velocity but won't be taken into account by len.
    cel.placeholder_Xspeed = roundNumber((cellist[0].Xspeed +  cellist[1].Xspeed +  cellist[2].Xspeed +  cellist[3].Xspeed +  cellist[4].Xspeed +  cellist[5].Xspeed +  cellist[6].Xspeed +  cellist[7].Xspeed)/len, 3);
    cel.placeholder_Yspeed = roundNumber((cellist[0].Yspeed +  cellist[1].Yspeed +  cellist[2].Yspeed +  cellist[3].Yspeed +  cellist[4].Yspeed +  cellist[5].Yspeed +  cellist[6].Yspeed +  cellist[7].Yspeed)/len, 3);
   if (cel.placeholder_Xspeed != 0 || cel.placeholder_Yspeed !=0) {
           cel.placeholder_Xtally =  roundNumber((cellist[0].Xtally +  cellist[1].Xtally +  cellist[2].Xtally +  cellist[3].Xtally +  cellist[4].Xtally +  cellist[5].Xtally +  cellist[6].Xtally +  cellist[7].Xtally)/len, 3);
           cel.placeholder_Ytally =  roundNumber((cellist[0].Ytally +  cellist[1].Ytally +  cellist[2].Ytally +  cellist[3].Ytally +  cellist[4].Ytally +  cellist[5].Ytally +  cellist[6].Ytally +  cellist[7].Ytally)/len, 3);
                  
           if  (cel.physicsmessage != "listed") {cellsinmotion.push(cel); cel.physicsmessage = "listed"; }  
     }
}


function Hex_velocitybirth (cel, len) {   // relies on the global variable "cellist"
         //  I think it would be more correct to let len = getaliveneighbors(cel.neighbors) which takes decaygray cells into account -- as it stands, they have velocity but won't be taken into account by len.

         cel.placeholder_Xspeed = roundNumber((cellist[0].Xspeed +  cellist[1].Xspeed +   cellist[3].Xspeed +  cellist[4].Xspeed +  cellist[6].Xspeed +  cellist[7].Xspeed)/len, 3);
             cel.placeholder_Yspeed = roundNumber((cellist[0].Yspeed +  cellist[1].Yspeed +   cellist[3].Yspeed +  cellist[4].Yspeed +    cellist[6].Yspeed +  cellist[7].Yspeed)/len, 3);
           
             if (cel.placeholder_Xspeed != 0 || cel.placeholder_Yspeed !=0) {
                   cel.placeholder_Xtally =  roundNumber((cellist[0].Xtally +  cellist[1].Xtally +  cellist[3].Xtally +  cellist[4].Xtally +    cellist[6].Xtally +  cellist[7].Xtally)/len, 3);
                   cel.placeholder_Ytally =  roundNumber((cellist[0].Ytally +  cellist[1].Ytally +  cellist[3].Ytally +  cellist[4].Ytally +  cellist[6].Ytally +  cellist[7].Ytally)/len, 3);
                
                   if  (cel.physicsmessage != "listed") {cellsinmotion.push(cel); cel.physicsmessage = "listed"; }
     }
}

function Decay_velocitybirth (cel, len) {   // relies on the global variable "cellist" and the globalvariable alivecount
      

         len = getaliveneighbors(cel.neighbors);
            
          
             cel.placeholder_Xspeed = roundNumber((cellist[0].Xspeed +  cellist[1].Xspeed +  cellist[2].Xspeed +  cellist[3].Xspeed +  cellist[4].Xspeed +  cellist[5].Xspeed +  cellist[6].Xspeed +  cellist[7].Xspeed)/len, 3);

             cel.placeholder_Yspeed =   roundNumber((cellist[0].Yspeed +  cellist[1].Yspeed +  cellist[2].Yspeed +  cellist[3].Yspeed +  cellist[4].Yspeed +  cellist[5].Yspeed +  cellist[6].Yspeed +  cellist[7].Yspeed)/len, 3);
           
          if (cel.placeholder_Xspeed != 0 || cel.placeholder_Yspeed !=0) {
                cel.placeholder_Xtally =  roundNumber((cellist[0].Xtally +  cellist[1].Xtally +  cellist[2].Xtally +  cellist[3].Xtally +  cellist[4].Xtally +  cellist[5].Xtally +  cellist[6].Xtally +  cellist[7].Xtally)/len, 3);
                cel.placeholder_Ytally =  roundNumber((cellist[0].Ytally +  cellist[1].Ytally +  cellist[2].Ytally +  cellist[3].Ytally +  cellist[4].Ytally +  cellist[5].Ytally +  cellist[6].Ytally +  cellist[7].Ytally)/len, 3);
                  
           if  (cel.physicsmessage != "listed") {cellsinmotion.push(cel); cel.physicsmessage = "listed"; }  
     }
}

function Decay_Hex_velocitybirth (cel, len) {
            len = getaliveneighbors(cel.neighbors);
             if (cel.neighbors[2].color != background ) {len -= 1}; 
             if (cel.neighbors[5].color != background ) {len -= 1};
             
             cel.placeholder_Xspeed = roundNumber((cellist[0].Xspeed +  cellist[1].Xspeed +   cellist[3].Xspeed +  cellist[4].Xspeed +  cellist[6].Xspeed +  cellist[7].Xspeed)/len, 3);
             cel.placeholder_Yspeed = roundNumber((cellist[0].Yspeed +  cellist[1].Yspeed +   cellist[3].Yspeed +  cellist[4].Yspeed +    cellist[6].Yspeed +  cellist[7].Yspeed)/len, 3);
           
             if (cel.placeholder_Xspeed != 0 || cel.placeholder_Yspeed !=0) {
                   cel.placeholder_Xtally =  roundNumber((cellist[0].Xtally +  cellist[1].Xtally +  cellist[3].Xtally +  cellist[4].Xtally +    cellist[6].Xtally +  cellist[7].Xtally)/len, 3);
                   cel.placeholder_Ytally =  roundNumber((cellist[0].Ytally +  cellist[1].Ytally +  cellist[3].Ytally +  cellist[4].Ytally +  cellist[6].Ytally +  cellist[7].Ytally)/len, 3);
                
                   if  (cel.physicsmessage != "listed") {cellsinmotion.push(cel); cel.physicsmessage = "listed"; }
     }
}

 
     
 
/*
If a cell is about to turn gray and is not already grey, decrement the neighbors' alivecounts
if a cell is about to turn background and is not currently gray, decrement the neighbors alivecounts.
If a cell is currently background and is about to change, increment the neighbors alivecounts.
if a cell is currently grey and is about to change, don't do anything!
Note that cells remain grey wile staying on changelist
if decayval == decayrule[cel.placeholder_color] tests for newly gray but so does placeholder != color


if a cell is about to turn background and is not currently gray or is about turn gray and is not currently gray
==>
if a cell is about to turn background or gray and is not currently gray
==>
if (cel.placeholder_color == background || cel.placeholder_color == decaygray) && cel.color != decaygray {
*/


function updatecells3() {
   for (var j=NewChangeCount; j--;){
      cel = newchangedcells[j];
     if  ((cel.placeholder_color == background || cel.placeholder_color == decaygray) && cel.color != decaygray && cel.color != background ) {   // this line was for LTL's benefit and .extra's beneift
      // non-LTL way:  
     //   if  ((cel.placeholder_color == background || cel.placeholder_color == decaygray) && cel.color != decaygray ) { 
              cel.neighbors[0].alivecount -= 1;
              cel.neighbors[1].alivecount -= 1;
              cel.neighbors[2].alivecount -= 1;
              cel.neighbors[3].alivecount -= 1;
              cel.neighbors[4].alivecount -= 1;
              cel.neighbors[5].alivecount -= 1;
              cel.neighbors[6].alivecount -= 1;
              cel.neighbors[7].alivecount -= 1;
           if (range != 8) {
              cel.neighbors[8].alivecount -= 1;
              cel.neighbors[9].alivecount -= 1;
              cel.neighbors[10].alivecount -= 1;
              cel.neighbors[11].alivecount -= 1;
              cel.neighbors[12].alivecount -= 1;
              cel.neighbors[13].alivecount -= 1;
              cel.neighbors[14].alivecount -= 1;
              cel.neighbors[15].alivecount -= 1;
              cel.neighbors[16].alivecount -= 1;
              cel.neighbors[17].alivecount -= 1;
              cel.neighbors[18].alivecount -= 1;
              cel.neighbors[19].alivecount -= 1;
              cel.neighbors[20].alivecount -= 1;
              cel.neighbors[21].alivecount -= 1;
              cel.neighbors[22].alivecount -= 1;
              cel.neighbors[23].alivecount -= 1;
         }

      }
    // else if ((cel.color == background || cel.color == decaygray) && (cel.placeholder_color != background && cel.placeholder_color != decaygray)) { // part of the bagel project
    else if (cel.color == background && cel.placeholder_color != background) {  // this line was for LTL's benefit   and .extra 's benefit   

     // nonn-LTL way: else if (cel.color == background) {  // Note this 2nd if is necessary only if color conversion (via two or thee cells) is allowed.      
    //   else if (cel.color == background) { 
              cel.neighbors[0].alivecount += 1; 
              cel.neighbors[1].alivecount += 1;
              cel.neighbors[2].alivecount += 1;
              cel.neighbors[3].alivecount += 1;
              cel.neighbors[4].alivecount += 1;
              cel.neighbors[5].alivecount += 1;
              cel.neighbors[6].alivecount += 1;
              cel.neighbors[7].alivecount += 1;
            if (range != 8) {
              cel.neighbors[8].alivecount += 1;
              cel.neighbors[9].alivecount += 1;
              cel.neighbors[10].alivecount += 1; 
              cel.neighbors[11].alivecount += 1;
              cel.neighbors[12].alivecount += 1;
              cel.neighbors[13].alivecount += 1;
              cel.neighbors[14].alivecount += 1;
              cel.neighbors[15].alivecount += 1;
              cel.neighbors[16].alivecount += 1;
              cel.neighbors[17].alivecount += 1;
              cel.neighbors[18].alivecount += 1;
              cel.neighbors[19].alivecount += 1;
              cel.neighbors[20].alivecount += 1;
              cel.neighbors[21].alivecount += 1;
              cel.neighbors[22].alivecount += 1;
              cel.neighbors[23].alivecount += 1;
         }

     };

if ( cel.placeholder_color != decaygray) { 
       cel.Xspeed = cel.placeholder_Xspeed;
       cel.Yspeed = cel.placeholder_Yspeed;
       cel.Xtally = cel.placeholder_Xtally;
       cel.Ytally = cel.placeholder_Ytally;  

         cel.placeholder_Xtally = 0;
         cel.placeholder_Ytally = 0;
         cel.placeholder_Xspeed = 0;
         cel.placeholder_Yspeed = 0;
}

       // not sure if the next line really helps at all
       // preschool keyword
      cel.kilroy_color = cel.color;         // using kilroy_color to look one generation backwards in time.
                                            // only needed for B0 rules, Alternating rules, and Bx2 rules.

      cel.extra = cel.placeholder_extra

      cel.color = cel.placeholder_color;
      cel.message = "just changed" ;
    // cel.decayval = cel.placeholder_decayval;
    // cel.placeholder_decayval = 0;
//***************************************************************


     changedcells[j] = cel;
     };
    
};

function beezero_updatecells () {
   for (var j=NewChangeCount; j--;){
      cel = newchangedcells[j];
      
      if ( (cel.placeholder_color == background || cel.placeholder_color == decaygray) && cel.color != background  && cel.color!=decaygray ) {     
        cel.neighbors[0].alivecount -= 1;
	cel.neighbors[1].alivecount -= 1;
	cel.neighbors[2].alivecount -= 1;
	cel.neighbors[3].alivecount -= 1;
	cel.neighbors[4].alivecount -= 1;
	cel.neighbors[5].alivecount -= 1;
	cel.neighbors[6].alivecount -= 1;
	cel.neighbors[7].alivecount -= 1;
      if (range != 8) {
              cel.neighbors[8].alivecount -= 1;
              cel.neighbors[9].alivecount -= 1;
              cel.neighbors[10].alivecount -= 1;
              cel.neighbors[11].alivecount -= 1;
              cel.neighbors[12].alivecount -= 1;
              cel.neighbors[13].alivecount -= 1;
              cel.neighbors[14].alivecount -= 1;
              cel.neighbors[15].alivecount -= 1;
              cel.neighbors[16].alivecount -= 1;
              cel.neighbors[17].alivecount -= 1;
              cel.neighbors[18].alivecount -= 1;
              cel.neighbors[19].alivecount -= 1;
              cel.neighbors[20].alivecount -= 1;
              cel.neighbors[21].alivecount -= 1;
              cel.neighbors[22].alivecount -= 1;
              cel.neighbors[23].alivecount -= 1;
         }

      }
      else if (cel.color == background && cel.placeholder_color != background ) {  
        cel.neighbors[0].alivecount += 1; 
	cel.neighbors[1].alivecount += 1;
	cel.neighbors[2].alivecount += 1;
	cel.neighbors[3].alivecount += 1;
	cel.neighbors[4].alivecount += 1;
	cel.neighbors[5].alivecount += 1;
	cel.neighbors[6].alivecount += 1;
	cel.neighbors[7].alivecount += 1;
        if (range != 8) {
              cel.neighbors[8].alivecount += 1;
              cel.neighbors[9].alivecount += 1;
              cel.neighbors[10].alivecount += 1; 
              cel.neighbors[11].alivecount += 1;
              cel.neighbors[12].alivecount += 1;
              cel.neighbors[13].alivecount += 1;
              cel.neighbors[14].alivecount += 1;
              cel.neighbors[15].alivecount += 1;
              cel.neighbors[16].alivecount += 1;
              cel.neighbors[17].alivecount += 1;
              cel.neighbors[18].alivecount += 1;
              cel.neighbors[19].alivecount += 1;
              cel.neighbors[20].alivecount += 1;
              cel.neighbors[21].alivecount += 1;
              cel.neighbors[22].alivecount += 1;
              cel.neighbors[23].alivecount += 1;
         }

        };

if ( cel.placeholder_color != decaygray) { 

       cel.Xspeed = cel.placeholder_Xspeed;
       cel.Yspeed = cel.placeholder_Yspeed;
       cel.Xtally = cel.placeholder_Xtally;
       cel.Ytally = cel.placeholder_Ytally;  
         cel.placeholder_Xtally = 0;
         cel.placeholder_Ytally = 0;
         cel.placeholder_Xspeed = 0;
         cel.placeholder_Yspeed = 0;
}

      cel.kilroy_color = cel.color;         // using kilroy_color to look one generation backwards in time.
      cel.extra = cel.placeholder_extra

      cel.color = cel.placeholder_color
      cel.message = "just changed" 
     
     changedcells[j] = cel;
     };
    
};
  






var newchangedcells = [];  // quick global experiment
var NewChangeCount = 0;  // quick global experiment


// Globals used include
// changecount, 

// neighborlist should be a global too (for GC prevention purposes)

var hicount = 0;  // I have no clue why this is here.  A candidate for deletion! 


 //var cel = settypecell;
// var neighborcell = settypecell;
// var neighborlist = [];
 // moving this to outside refresh: var cel = settypecell;
// moving this to outside refresh: var neighborcell = settypecell;
// moving this to outside refresh: var neighborlist = [];
 


function refresh () {   // (rulefunction) {

  var cel = settypecell;
 var neighborcell = settypecell;
 var neighborlist = [];
 

 NewChangeCount = 0;  // quick global experiment


 for (var i=changecount; i--;) {
   cel = changedcells[i];

   // first handle neighbors
   neighborlist = cel.neighbors;
   for (var j=range; j--;) {
      neighborcell = neighborlist[j];
      if (neighborcell.message != generation) {
        neighborcell.message = generation;
       
        algo2_rulecodes (neighborcell, neighborcell.alivecount);

// **********************************
//  To make the overall program run faster,
// the code below can be optimized with a switch according to rulecode and/or global codes.
// similarly, the update3 vs beezero_update distinction can be further refined by rulecode and/or global codes.
// **********************************


        if (birthrule[neighborcell.color][0] != 1) {  
          // Note that the neighborcell.color will often be "background", which is why there must be a rule for background to make B0 rules work.
              if (neighborcell.placeholder_color != neighborcell.color || neighborcell.decayval > 0  || neighborcell.placeholder_extra  != neighborcell.extra){         // trilife

           // if (neighborcell.placeholder_color != neighborcell.color || neighborcell.placeholder_color == decaygray  || neighborcell.placeholder_extra  != neighborcell.extra){         // trilife
        //  if (neighborcell.placeholder_color != neighborcell.color || neighborcell.decayval > 0) { // != neighborcell.decayval
             newchangedcells[NewChangeCount] = neighborcell;
             NewChangeCount += 1;
            } 
        } 
 
         else {

            if (neighborcell.placeholder_color != neighborcell.color || neighborcell.placeholder_color != neighborcell.kilroy_color || neighborcell.decayval > 0) {
               newchangedcells[NewChangeCount] = neighborcell;
               NewChangeCount += 1;
             } 
         }

 
             
      };
    };
 
   // now almost repeat the code to handle cell itself (this suggests that the above really should be a function!) which is first called 8 times above and then once more below.

   if (cel.message != generation) {
       cel.message = generation;

        //con1doLifeRuleToCell2(cel, cel.alivecount);
        // DayandNightRule(cel, cel.alivecount);
       //  MorleyRule(cel, cel.alivecount);
         //  HighLifeRule(cel, cel.alivecount);
          //   rulefunction(cel, cel.alivecount);
         //t_liferule(cel, cel.alivecount);
        // algo2_colorrule(cel, cel.alivecount);
          
        //  algo2_colorrule_withB0 (cel, cel.alivecount);
           
         // algo2_colorrule_withB0andJF (cel, cel.alivecount);
         // algo2_colorruleGenerations(cel, cel.alivecount);
           algo2_rulecodes (cel, cel.alivecount);




      if (birthrule[cel.color][0] != 1) {  

             if (cel.placeholder_color != cel.color || cel.decayval > 0 || cel.placeholder_extra != cel.extra ) { 
         //   if (cel.placeholder_color != cel.color || cel.color == decaygray || cel.placeholder_extra != cel.extra ) { 
        //  if (cel.placeholder_color != cel.color || cel.decayval > 0) { // != cel.decayval
            newchangedcells[NewChangeCount] = cel;
            NewChangeCount += 1;
          } 
        }
        else { // the cell is operating under a B0 rule, so we must consider the kilroy color too

           if (cel.placeholder_color != cel.color || cel.placeholder_color != cel.kilroy_color) {  //  HEY!  ********* this doesn't match the corresponding test for neighbor cell.  Bug??????
                                                                                                    // (Soome code allows for B0 rules to have gnerations and some doesn't.
                                                                                                   // Must regularize, depending on whether it will be allowed.)
               newchangedcells[NewChangeCount] = cel;
               NewChangeCount += 1;
             } 
         }


     }
}
 
   

      if( B0_rule_p) {beezero_updatecells()} else {updatecells3()};
      changecount = NewChangeCount;

      
};
 

function nested_refresh3 () {    //   (rulefunction) {

  var neighborlist = [];
  var neighborcell = settypecell;
  var cel = settypecell;
  
   NewChangeCount = 0;  // quick global experiment

for (var i=0;i<memoryX;i++){
 for (var j=0;j<memoryY;j++) {
   cel = arr[i][j];
  
   if (cel.message != generation) {
       cel.message = generation;

      algo2_rulecodes (cel, cel.alivecount);



      if (birthrule[cel.color][0] != 1) {  
                    if (cel.placeholder_color != cel.color || cel.decayval > 0 || cel.placeholder_extra != cel.extra) { // != cel.decayval

         // if (cel.placeholder_color != cel.color || cel.color == decaygray || cel.placeholder_extra != cel.extra) { // != cel.decayval
         // if (cel.placeholder_color != cel.color || cel.decayval > 0 ) { // != cel.decayval
            newchangedcells[NewChangeCount] = cel;
            NewChangeCount += 1;
          } 
        }
        else { // the cell is operating under a B0 rule, so we must consider the kilroy color too
             if (cel.placeholder_color != cel.color || cel.decayval > 0 || cel.placeholder_color != cel.kilroy_color) {  

           //if (cel.placeholder_color != cel.color || cel.color == decaygray || cel.placeholder_color != cel.kilroy_color) {  
               newchangedcells[NewChangeCount] = cel;
               NewChangeCount += 1;
             } 
         }


     }
   }
 }
 

      if ( B0_rule_p) {beezero_updatecells()} else {updatecells3()};

      changecount = NewChangeCount;
}

  
function geared_refresh (cellquant) {
  //document.getElementById("info_message2").innerHTML=changedcells.length;
  if (changedcells.length > cellquant) {nested_refresh()} else {refresh()};
};
     

// b52 is a compact but double barreled glider gun.

/*
var b52 = ".**....................................$.**.................*..................$...................*.*............*.*..$....................*............*.....$**.......**.......................*..*.$**.*.....**.......................*.*.*$...*.......................*.......*..*$...*.......................**.......**.$*..*.................**.....*..........$.**..................*.................$.....................***...............$....................................**.$....................................**.$.**....................................$*..*...................................$*.*.*................*.*....**.....**..$.*..*.................**....**.....**.*$.....*............*...*...............*$..*.*............*.*..................*$..................*................*..*$....................................**.$"

var phasechangespaceship = "........*...........................$.......***.**.......................$......**...*.**.....................$.....**..*.....*....................$......*.....*...*.***...............$.....**.....*...*.*..*..............$...**.*.**....*.*.*...*.............$....*.*..**...........*.............$.**.*..*..*.........*...............$.**.*.....**.........*.***..........$.*.*.............***.*.*.**.........$**.**...........**.*..*.*.*.........$..............**.*...***..**.....**.$.............*...*......*........*.*$............*.....*..**.*.**.....*..$...........*..*.*......*.*..........$...........*.....**....***..........$.............*..........*...........$..........*.*...........*...........$.........**.*.***...................$........*.*.*...*...................$.......**.*.........................$......*...*.....**..................$....................................$......**.**.........................$"




*/

// The convention is to paste in patterns which point East or SouthEast.  Guns shoot SouthEast (or East).   Diagonal spaceships glide Southeast.

var lifepatterns = {

                "--Breeders & Spacefillers--": {patternstring: "3o"},

       "Spacefiller": {                       rule:  "B3/S23",
patternstring: ".....*.*$....*..*$...**$..*$.****$*....*$*..*$*..*$.*.........***...***$..****.*..*..*...*..*$...*...*.....*...*$....*........*...*$....*.*......*...*$.$...***.....***...***$...**.......*.....*$...***......*******$...........*.......*$....*.*...***********$...*..*..*............**$...*.....************...*$...*...*.............*...*$....*...************.....*$.....**............*..*..*$........***********...*.*$.........*.......*$..........*******......***$..........*.....*.......**$.........***...***.....***$.$...........*...*......*.*$...........*...*........*$...........*...*.....*...*$........*..*...*..*..*.****$.........***...***.........*$.........................*..*$.........................*..*$.......................*....*$........................****$..........................*$........................**$.....................*..*$.....................*.*$"
                },
"Space-Nonfiller": {rule:  "B3/S23",
		    xsize: 37, ysize: 31, 
                    patternstring: "19b3o$18bo2bo$12b3o6bo4b3o$12bo2bobo3bo4bo2bo$12bo2bobo3bo4bo2bo$10bo10bo2bobob3o$10b2o2b2o2bobo4bo5bo$8bo16b2o2b3o$8b3obob2o10bo6bo$6bo8bo9bobo3b3o$6b3o5bo10bo8bo$3bobo25bob3o$2b5obo26bo$b2o6bo21b5o$2o4b2o18bobo$bobo3bo2bo15bo2bo3bobo$8bobo18b2o4b2o$b5o21bo6b2o$bo26bob5o$b3obo25bobo$2bo8bo10bo5b3o$3b3o3bobo9bo8bo$3bo6bo10b2obob3o$5b3o2b2o16bo$5bo5bo4bobo2b2o2b2o$6b3obobo2bo10bo$7bo2bo4bo3bobo2bo$7bo2bo4bo3bobo2bo$8b3o4bo6b3o$15bo2bo$15b3o!"
                    },

"Star Wars test": {xsize: 6, ysize: 3, 
                    rule:  "all",
                    patternstring: "o4bo$2ob3o$o4bo!"
                    },

"Range4 Thin Bug1": {xsize: 9, ysize: 6, rule: "all", patternstring: "3o$3b2o$5b4o$5b4o$3b2o$3o!"}, 


"Changelist Monster #3": {xsize: 36, ysize: 10, rule: "Bugs experiment", patternstring: "$21b2o$3b3o16bo$2b2obo$b2o2bo$2o2b2o28b2o$o2b2o$ob2o$3o12bo$15b2o!"},


"50x50 block": {xsize: 50, ysize: 50, 
                    rule:  "all",
                    patternstring: "50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o$50o!"
                    },

"100x50 block": {xsize: 100, ysize: 50, 
                    rule:  "all",
                    patternstring: "100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o$100o!"
                    },
  

"HighLife Breeder-1": {xsize: 94,
                       ysize: 89,
                       naturalXspeed:  0.16666666667,
                       naturalYspeed:  0.16666666667,
                       rule:  "B36/S23",
   patternstring:   "40bo$40bo$40bo5$43b3o$42bo2bo$41bo3bo$41bo2bo$41b3o4$21b3o2$30b3o$29bobo$29b2o$29bo7$15bo$15bo$15bo7$19bo$19b3o$18bo2b2o$21b4o$20bo6$3o3$9b3o$9b2o$9b2ob2o$11b2obo$12b3o$13bo15$51bo$51bo$51bo8bo$60bo$60bo$57b3o11$91b3o$90bobo$90b2o$90bo!"
        },


"HighLife Breeder-2": {xsize: 51,
                       ysize: 44,
                       naturalXspeed:  0.16666666667,
                       naturalYspeed:  0.16666666667,
                       rule:  "B36/S23",
   patternstring:   "3$12b3o$11bo2bo$10bo3bo$10bo2bo$10b3o5$8b3o$7bo3bo$7bo3bo$7bo3bo$8b3o5$6bo8bo$6bo7b3o$6bo6b3obo$12b2o2b3o$11b2o3b2o$10b3o2b2o$11bob3o$12b3o$13bo6$44b3o$43bo2bo$42bo3bo$42bo2bo$42b3o!"
        },

"HighLife Breeder-3":  {xsize: 100,
                       ysize: 104,
                       naturalXspeed:  0,
                       naturalYspeed:  0,
                       rule:  "B36/S23",
   patternstring:   "5b2o$6bo$6bobo89b2o$7b2o89bo$96bobo$96b2o4$o$3o$3bo$2b2o7$29b3o$28bo$28bo$28bo9$20b2o$21b2o$18bob2o$18b3o$19bo$57b3o$57bo2bo$57bo3bo$58bo2bo$59b3o10$62bo$62bo$62bo$59b3o7$36b3o$35bo3bo$35bo4bo$35bo2bo2bo11bo$36bo4bo10b3o$37bo3bo9b2obo$38b3o9b2o$51b2o33$4b2o$5bo$2b3o$2bo!"
        },

"Crazy Fountain":     {xsize: 28,
                       ysize: 59,
                       naturalXspeed:  0,
                       naturalYspeed:  0,
                       rule:  "B3/S02456",
   patternstring:   "9$9b2o6b2o$8b4o4b4o$9b2o6b2o$9b2o6b2o$8bo2bo4bo2bo$7b2o2b2o2b2o2b2o$7b6o2b6o$8bo2bo4bo2bo5$9b2o6b2o$8bo2bo4bo2bo$9b2o6b2o3$8bo2bo4bo2bo$7bob2obo2bob2obo$7bo4bo2bo4bo$7b2o2b2o2b2o2b2o$7bob2obo2bob2obo$7b6o2b6o$9b2o6b2o$8bo2bo4bo2bo$9b2o6b2o$8bo2bo4bo2bo$9b2o6b2o2$9b2o6b2o$9b2o6b2o2$9b2o6b2o$8bo2bo4bo2bo$8b4o4b4o$8bo2bo4bo2bo$9b2o6b2o$9b2o6b2o2$6bo2b2o2b2o2b2o2bo$6b3o2b6o2b3o$7b6o2b6o$6bobo2bob2obo2bobo$7b6o2b6o$8b4o4b4o$8b4o4b4o!"
        },

      "----Spaceships----": {patternstring: "3o"},
 "Weekender 2c/7": {rule:  "B3/S23",
                       xsize: 15,
                       ysize: 20,
                       naturalXspeed: 0.285714,  // this is the only known 2C/7 spaceship in b3/s23  2/7=.2857142857  round up or down?  Xtally <== roundNumber(x,2).
                       naturalYspeed: 0,
   patternstring:   "$9bo$7b2ob2o$4bobo2bo$4bo$2bobo$bo2bo$bo3b2o$5b2o$5b2o$bo3b2o$bo2bo$2bobo$4bo$4bobo2bo$7b2ob2o$9bo!"
                 },

  "Lightweight Ship c/2"  : {rule:  "B3/S23",xsize: 9, ysize: 8,naturalXspeed: 0.5,naturalYspeed: 0,  rule: ["B3/S23", "B36/S23"], patternstring: "3$4b2o$2b2ob2o$2b4o$3b2o!"},


//  this one has less of a buffer space.  I'm leaving in this comment as a reminder regarding buffer spacing.
//  "lwss"  : {patternstring: "2$b4o$o3bo$4bo$o2bo!", xsize: 7, ysize: 6,naturalXspeed: 0.5,
//   naturalYspeed: 0},


//   "lwss"  : {patternstring: "2$b4o$o3bo$4bo$o2bo!", xsize: 6, ysize: 6,naturalXspeed: 0.5,
//     naturalYspeed: 0},

  "Heavyweight Ship c/2"  : {rule:  "B3/S23",xsize: 7, ysize: 7,naturalXspeed: 0.5, naturalYspeed: 0,  rule: ["B3/S23", "B36/S23"], patternstring: "b6o$o5bo$6bo$o4bo$2b2o!"},


  "X66 c/2" : {
    xsize: 11,
    ysize: 13,
    naturalXspeed: 0.5,
    naturalYspeed: 0,
    rule:  ["B3/S23", "B37/S23"],
    patternstring: "$7bo$8b2o$bo2b3o2bo$2b3o4bo$2b2o2b3o2$2b2o2b3o$2b3o4bo$bo2b3o2bo$8b2o$7bo!"
    },
 
  "Schickship c/2": { 
  rule:  "B3/S23",
  xsize:  26, //17,
  ysize:  11, //11,
   naturalXspeed: 0.5,
   naturalYspeed: 0,
   patternstring: "$21b2o$6bo12b2ob2o$6bo8bo3b4o$10b2o2bobo3b2o$b2o6bo2b2o3bo$10b2o2bobo3b2o$6bo8bo3b4o$6bo12b2ob2o$21b2o!"
    },


  "Birdlike 86P9H3V0.1 c/3": {xsize: 18, ysize: 39, naturalXspeed: 0.33333333, naturalYspeed: 0,
              rule: ["B3/S23", "B36/S23"],
              patternstring: "$9bo$10b2o$10b2o$9bo$11bo$9bobo$9bobo$10bo$11bo$11bo$13b3o$13b3o$10bobo$4bobo4b2o2bo$6bo9bo$7b2o2bo3bo$4bo2b2o2bob2o$3bo3b2o2bo$b4o2bo$3bo3b2o2bo$4bo2b2o2bob2o$7b2o2bo3bo$6bo9bo$4bobo4b2o2bo$10bobo$13b3o$13b3o$11bo$11bo$10bo$9bobo$9bobo$11bo$9bo$10b2o$10b2o$9bo!"
              },


  "Non-monotonic #1 c/4": {rule:  "B3/S23",xsize: 25, ysize: 13, naturalXspeed: 0.25, naturalYspeed: 0,     diagonalcounterpart:  "Big glider c/4 diag",
     patternstring: "$9bob2o$8b3obob3o$2b2o3bo10bobo$2b4o3bo5b2o4b2o$5bob3o4bo2b2obo$9bo4bo$5bob3o4bo2b2obo$2b4o3bo5b2o4b2o$2b2o3bo10bobo$8b3obob3o$9bob2o!" 
    },

  "Glider c/4 diag": {xsize:  3, ysize: 3, naturalXspeed: 0.25, naturalYspeed: 0.25, rule: ["B3/S23", "B36/S23", "B37/S23"], patternstring: "bo$2bo$3o!"
    },



  "Small Orion c/4 diag"  : {
    rule:  "B3/S23",
    xsize:  15, ysize: 15, naturalXspeed: 0.25, naturalYspeed: 0.25,
        patternstring: "$7bobo$8b3o$10bo$8bobo2$5b2obo$2b2o4b2o$bo2b3ob2o$bobobo3b2o$3bo$11bobo$12b2o$12bo!"

    },

  "big_orion diag - fix me"   : {
    rule:  "B3/S23",
    patternstring:  "...**.........$...*.*........$...*..........$**.*..........$*....*........$*.**......***.$.....***....**$......***.*.*.$.............*$......*.*.....$.....**.*.....$......*.......$....**.*......$.......*......$.....**.......$"
    },

    
  "Crab c/4 diag": {
       rule:  "B3/S23",
       xsize:  18,
       ysize: 18,
       naturalXspeed: 0.25,
       naturalYspeed: 0.25,
       patternstring: "7b2o$4bo2b2o$3bobo4bo$5bo5b2o$3b2o5b2o$o2bo2$2bo$2o$3bo$4b2o$3b2o!"

       },

  "Big glider c/4 diag": {rule:  "B3/S23",xsize: 22, ysize: 22, naturalXspeed: 0.25, naturalYspeed: 0.25,        diagonalcounterpart:   "Non-monotonic #1 c/4",
                          patternstring: "$8bo$8bo2$7b5o$7bo2b2o$7bo4b2o$4b3o2bobo$b2obo6bo2bo$4bo2bo4bobo$4b2o7b3o$4b2ob2o6bobo$6bo2bo7b3o$6bo3bo5b3o$8b3o$10b2o6bobo$13bo5b2o$11b3o5bo$12b2obo$12bo3b2o$15b2o!"
       },

  "Dragon-ish c/4 diag": {rule:  "B3/S23",xsize: 29, ysize: 28, naturalXspeed: 0.25, naturalYspeed: 0.25,        diagonalcounterpart:   "Dragon c/6",
patternstring: "$9b2o$7b3obo$7b2ob2o$8b2obo$12bo$3bo10bo$4b2o7bo$13bo2b2o$bo2bo11b3o$2bobo11bobo$2bob2o6b2ob3o$6b2o8b5o$6b3o2b3o7bo$8bo2b2o$12bo6b3o$8bo3b2o5b2o$9bobo7b2o$9bo10b5o$12bo2bo4b2obo2bo$13b2o5bo2b2o2bo$16b5o4b3o$17b2obo$17b2o2bo$19bo$22bo$20b3o!"
      },



"Snail c/5": {rule:  "B3/S23",xsize: 38, ysize: 21, naturalXspeed: 0.2, naturalYspeed: 0, patternstring: "36bo$36bo$37bo$8b3o3b3o17b3o$8b3o6bobo3bo9bob2o$4b4o4bo7bob2o11bo$4b2o5bob2o3bobo3bo6bo$ob2o8bo9b2o3b3obo2bo$bo17bo5bo5bob2o$20b7obo2$20b7obo$bo17bo5bo5bob2o$ob2o8bo9b2o3b3obo2bo$4b2o5bob2o3bobo3bo6bo$4b4o4bo7bob2o11bo$8b3o6bobo3bo9bob2o$8b3o3b3o17b3o$37bo$36bo$36bo!"
     },


"160P10H2V0 c/5": {rule:  "B3/S23",xsize: 40, ysize: 21, naturalXspeed: 0.2, naturalYspeed: 0, patternstring: "$34bo$4b2o20b2o4b2obo$3b3o23b2o4bo$6bo19bo2b2obo2bo$2b3ob2ob3o7b3o7b2obo$2bo3bo4bo2bo3b2o2b2o4bo6b2o$6bo3b2o2b2o4bo6bo7bobo$7bo4bo4b3o4b2o9bob2o$7b10obo4bo13bo$b3o3bo9bo15bo3b2o$7b10obo4bo13bo$7bo4bo4b3o4b2o9bob2o$6bo3b2o2b2o4bo6bo7bobo$2bo3bo4bo2bo3b2o2b2o4bo6b2o$2b3ob2ob3o7b3o7b2obo$6bo19bo2b2obo2bo$3b3o23b2o4bo$4b2o20b2o4b2obo$34bo!"
     },



"Extendable c/5": {rule:  "B3/S23",xsize: 31, ysize: 21, naturalXspeed: 0.2, naturalYspeed: 0, patternstring: "$22b2o$21bo2bo$2b2ob3o4bo8b3o$2bo3b2o3bob2o5bo3bo$3bobobo5b2o4bob4o$3b2ob3o2bo5bobo5bo$2bo2bo2bo2b7o3b2ob3o$bo5bo2bo9b3o3bo$2b5o4b10o5b2o$26b3o$2b5o4b10o5b2o$bo5bo2bo9b3o3bo$2bo2bo2bo2b7o3b2ob3o$3b2ob3o2bo5bobo5bo$3bobobo5b2o4bob4o$2bo3b2o3bob2o5bo3bo$2b2ob3o4bo8b3o$21bo2bo$22b2o!"
     },



  "Spider c/5": {rule:  "B3/S23",xsize: 10, ysize: 33, naturalXspeed: 0.2, naturalYspeed: 0,         diagonalcounterpart: "58P5H1V1 c/5 diag",
 patternstring: "$4bo$2bo2bo2$bo3b2o$2b5o$3bo$2b6o$2bo3bo$2bo3bo$6bo$4bob2o$4bo2bo$3b5o$3b2obo$4b2o2$4b2o$3b2obo$3b5o$4bo2bo$4bob2o$6bo$2bo3bo$2bo3bo$2b6o$3bo$2b5o$bo3b2o2$2bo2bo$4bo!"
      },

   "58P5H1V1 c/5 diag": {rule:  "B3/S23",xsize: 25, ysize: 25, naturalXspeed: 0.2, naturalYspeed: 0.2,   diagonalcounterpart: "Spider c/5", patternstring: "$16bo5bo$15bo7bo$18b4obo$14bo2bo3b2o$14bo2bo2b3o$14bo4bo$15bob3o$15b2ob2o$11b3o4b2o$11b3o$9b2o$9b2o$9b2o$4b3o$2bo4b2o$bo6bo$4b2obo$3bo3b3o$3bo2b4o$3bobo$3b3o$bo2b2o$2b2o!"      
     },



  "Summers2005 c/5 diag" : {
       rule:  "B3/S23",
       xsize: 24, // 22
   ysize: 24, // 22
    naturalXspeed: 0.2,
    naturalYspeed: 0.2,
    patternstring: "6b2o$6bob2o4bo$4b2o3b2o3bo$6bo2bo5bo$2bo6bo5bo$2bo7bo$2obo8bo3bo$o9bo2b2ob2o$bo7b2o3bob2o$b4o3bo3b4ob2obo$2bo2bob2o7bobo2bo$16b2o3bo$6bo2bo8b3o$7bobo9bo$b2o4b3o$3b2o4bo$6b3ob2o$7b3obo$9b2obo$12b2o$9bo2bo$10b2o"
    },


"163P5H1V1 long c/5 diag": {rule:  "B3/S23",xsize: 40, ysize: 40, naturalXspeed: 0.2, naturalYspeed: 0.2, patternstring: "$4b2o$4b3obo$7bo$b2o5bobo$b2o6b2o$2bo7bo$3bo8bo$2bobo7bo$5bo6b2o4b2o$4b3o11b3o$13b2o2bo4bo$7b3o3b3obo5bo$9bob2o7bo$11b2obobobobobob2o$12bo5bo6bob2o$14bo3bo4bo4bo$11b2o5bo3b2ob3o$9b2o3b4o2bo4b2o$9b2o10bo$10bo2b2o3bobo4b2o3bo$19bo7bo3bo$11bo2bo2bo6bobo5bo$12bo3b2o6b2o2b2o3bo$14bo7b2obo3bobobo$14b2ob2obo2b2o7b4obo$17b2obobo6bobobobo2bo$15bobo3bo9bob2o3bo$15b2o6bo6bo4b3o$23b2obo2bo6bo$20bo7bo$21bo2bob2o$22bo2bo$23b5o$25bobo$25b2obo$28b2o$25bo2bo$26b2o!"
      },

"67P5H1V1 asym c/5 diag": {rule:  "B3/S23",xsize: 23, ysize: 23, naturalXspeed: 0.2, naturalYspeed: 0.2, patternstring: "$5bo$6bo$5bo$6bo$4bobo$2bo8b2o$b4o2bo4bo$5b2o2bo2b2o$3bo5bobo$5b3obob2obo$6b2o$13bo2b2o$14bobo$13b2o3b2o$11b3obo2b4o$11bo2b2o5bo$12b2o2bo2b2o$13bo3bob2o$12b2o2bobo$12b2o2b2o$16bo!"
      },


//"name": {xsize: X, ysize: Y, naturalXspeed: 0, naturalYspeed: 0, patternstring: "      "
//      },



 
  "Dragon c/6"  : {
    xsize: 33,
    ysize: 20,
    naturalXspeed:  0.16666666667,
       naturalYspeed:0,
       diagonalcounterpart: "Dragon-ish c/4 diag",
      rule: ["B3/S23", "B37/S23"],
     patternstring: "$16b2o$2bo$2bo15bo$2b3ob2o3bob2ob2o2bo$6bo4bo2bo5b3ob2o2b2o$2b3ob2o3b2obo6b2ob2obo2bo$2bo4bobo12bob2o2b2o$2bo5bo14b2o$7bobo12bo$7bobo12bo$2bo5bo14b2o$2bo4bobo12bob2o2b2o$2b3ob2o3b2obo6b2ob2obo2bo$6bo4bo2bo5b3ob2o2b2o$2b3ob2o3bob2ob2o2bo$2bo15bo$2bo$16b2o!"
    },
  
   "56P6H1V0 c/6": {rule:  "B3/S23",xsize: 15, ysize: 28, naturalXspeed:  0.16666666667,naturalYspeed:0, patternstring: "$11bo$11bo$11bo2$9b3o$12bo$12bo$2bo3b2o4bo$bobobo4bo$5b2o$4b2o2b2o$5bob2obo$5bo5bo$5bo5bo$5bob2obo$4b2o2b2o$5b2o$bobobo4bo$2bo3b2o4bo$12bo$12bo$9b3o2$11bo$11bo$11bo!"
      },

   "114P6H1V0 c/6": {rule:  "B3/S23",xsize: 37, ysize: 20, naturalXspeed:  0.16666666667,naturalYspeed:0, patternstring: "$15bobo$13bo4bo$bobo9b2o2bo$bo2bo8b2obo$4bo4b3o19b2o$2bobo2b5o19bobo$3bo3b2o3bo6b2ob2o3b2o5bo$11bo4b2o5b2o2b2o2bo$7b2obo5bo4bo2b2o5bo3bo$7b2obo5bo4bo2b2o5bo3bo$11bo4b2o5b2o2b2o2bo$3bo3b2o3bo6b2ob2o3b2o5bo$2bobo2b5o19bobo$4bo4b3o19b2o$bo2bo8b2obo$bobo9b2o2bo$13bo4bo$15bobo!"
    },

   "77P6H1V1 c/6 diag": {rule:  "B3/S23",xsize: 38, ysize: 38, naturalXspeed:  0.16666666667, naturalYspeed: 0.16666666667, patternstring: "$35bo$36bo$36bo$32bo2bo$31bo3bo$32b2o$27bo3b2o$26bo2b4o$29bob2o$26b2o2bo$26bob2o$26b3o$21b2o3b2o$20bo4bo$20bob4o$21b3o$19b2o2b2o$19b2o2b2o$17b2obo2bo$14b2ob3o3bo$13bo2bo4bo$13bob2o$15b6o$15bob2o$14b2o$8bob4o$7bo2bob2o$11b2o$8b2obo$8bobo$5bob3o$4bob4o$6bo2$bo2b2o$2b2o!"
    },


   "Seal c/6 diag": {rule:  "B3/S23",xsize: 36, ysize: 38, naturalXspeed:  0.16666666667, naturalYspeed: 0.16666666667, patternstring: "$13bo$13b2o$13b2o2$11b3o$11b3o2$15bo$14bobo$9bo2bo$9bobobobob3o$b3o2bo4bo5b2o$5bo2b2obo2bob2o$b2ob2o2b2ob2o3b5o$3bo6b3o3bo4bo$17bo3bo$12b2o7bo$9b6o3bobo4b2o$10bo4bobo$12b3o2b2ob2ob2ob2o$13b2obo5b5obob2o$15bo2b3o4bob2o3bo$15bo4b2o2b2o$21b2o9bo$19bo3bo3bo2bob2o$18bo4bo9bo$18bo4b3ob5o2bo$19bo2bobo8b2o$21b2obo3b2o4bo$22bo2bob2o$22b4obo6bo$22bobo2bo2b2ob2o$26b2o3bo$27b3ob3o$31b2o!"
     },

      "Just Discovered c/7 diag": {rule:  "B3/S23",xsize: 29, ysize: 29, naturalXspeed:  0.142857142857, naturalYspeed: 0.142857142857, patternstring: "$5bo5bo$5b2o5bo$8bo3bo$6bo4bo$b2o8bo$2bobo5bo3b2o$7b2o4bo2bo$3bo3bo3bo5bo$10b2o4bobo4b2o$6bo2bo6bo6b2o$bo2b2o2b2o6bo3bo$2b2o13b2o2bo4bo$7bo13b2obobo$6bo13bobo2b2o$6bo$7bob3o$8bo3bo$9bo2bo2$11bo2bo$12b2o$13b2o$9b2o$9b2o2bo$14bo$12b3o!"
     },

  "Dart c/3": {
     rule:  "B3/S23",
     xsize: 15,
     ysize: 20,
     naturalXspeed: 0.33333333, // actually .333333333
     naturalYspeed: 0,
          patternstring: "$2bo$bobo$bo2bo$3bo$b4o$2bob2obo$b3o4b2o$8b2o$b3o4b2o$2bob2obo$b4o$3bo$bo2bo$bobo$2bo!"

   },

    "smallish c/3 Greyishship" : {  
       rule:  "B3/S23",   
        xsize: 38,
        ysize: 21,
        naturalXspeed: 0.33333333, // c/3 Actuallly  .333333333
        naturalYspeed: 0,
        patternstring: "9b2o11bo9bo$9bo6b2o5bo7bobo$7bo4bo5b2o3b2o8b2o$8bo3b2o3b3o2bo5bo4bo$4b2obo6bo6b4o2bobo2bobo$3b3o2b13o2b2o4bo4bo$ob4obo21bo5bo$4bo3b17ob2o5bobo$b3o20b2obob2o4bo$2bob20o3bobob4o$b2o25bo$2bob20o3bobob4o$b3o20b2obob2o4bo$4bo3b17ob2o5bobo$ob4obo21bo5bo$3b3o2b13o2b2o4bo4bo$4b2obo6bo6b4o2bobo2bobo$8bo3b2o3b3o2bo5bo4bo$7bo4bo5b2o3b2o8b2o$9bo6b2o5bo7bobo$9b2o11bo9bo!"

    },
    
    "triangular grey ship c/2": {rule:  "B3/S23",xsize: 58, ysize: 99,  naturalXspeed: 0.5,naturalYspeed: 0, patternstring:
"8b5o$b2o4bo4bo$4o8bo$5o6bo$5bo3bo$7b2o$7b2o$2bobo2bobo$3bobobob2o$2b2obobobob2o$5bobobobo$2b2obobobobob2o$5bobobobobo$5bobobobobob2o$5bobobobobobo$4b2obobobobobob2o$5bobobobobobobo$4b2obobobobobobob2o$7bobobobobobobo$4b2obobobobobobobob2o$7bobobobobobobobo$7bobobobobobobobob2o$7bobobobobobobobobo$6b2obobobobobobobobob2o$7bobobobobobobobobobo$6b2obobobobobobobobobob2o$9bobobobobobobobobobo$6b2obobobobobobobobobobob2o$9bobobobobobobobobobobo$9bobobobobobobobobobobob2o$9bobobobobobobobobobobobo$8b2obobobobobobobobobobobob2o$9bobobobobobobobobobobobobo$8b2obobobobobobobobobobobobob2o$11bobobobobobobobobobobobobo$8b2obobobobobobobobobobobobobob2o$11bobobobobobobobobobobobobobo$11bobobobobobobobobobobobobobob2o$11bobobobobobobobobobobobobobobo$10b2obobobobobobobobobobobobobobob2o$11bobobobobobobobobobobobobobobobo$10b2obobobobobobobobobobobobobobobob2o$13bobobobobobobobobobobobobobobobo$10b2obobobobobobobobobobobobobobobobob2o$13bobobobobobobobobobobobobobobobobo8b2o$13bobobobobobobobobobobobobobobobobob2o3b5o$13bobobobobobobobobobobobobobobobobobobob4ob2o$12b2obobobobobobobobobobobobobobobobobobo5b2o$13bobobobobobobobobobobobobobobobobobobobo$12b2obobobobobobobobobobobobobobobobobobo$13bobobobobobobobobobobobobobobobobobobobo$12b2obobobobobobobobobobobobobobobobobobo5b2o$13bobobobobobobobobobobobobobobobobobobob4ob2o$13bobobobobobobobobobobobobobobobobob2o3b5o$13bobobobobobobobobobobobobobobobobo8b2o$10b2obobobobobobobobobobobobobobobobob2o$13bobobobobobobobobobobobobobobobo$10b2obobobobobobobobobobobobobobobob2o$11bobobobobobobobobobobobobobobobo$10b2obobobobobobobobobobobobobobob2o$11bobobobobobobobobobobobobobobo$11bobobobobobobobobobobobobobob2o$11bobobobobobobobobobobobobobo$8b2obobobobobobobobobobobobobob2o$11bobobobobobobobobobobobobo$8b2obobobobobobobobobobobobob2o$9bobobobobobobobobobobobobo$8b2obobobobobobobobobobobob2o$9bobobobobobobobobobobobo$9bobobobobobobobobobobob2o$9bobobobobobobobobobobo$6b2obobobobobobobobobobob2o$9bobobobobobobobobobo$6b2obobobobobobobobobob2o$7bobobobobobobobobobo$6b2obobobobobobobobob2o$7bobobobobobobobobo$7bobobobobobobobob2o$7bobobobobobobobo$4b2obobobobobobobob2o$7bobobobobobobo$4b2obobobobobobob2o$5bobobobobobobo$4b2obobobobobob2o$5bobobobobobo$5bobobobobob2o$5bobobobobo$2b2obobobobob2o$5bobobobo$2b2obobobob2o$3bobobob2o$2bobo2bobo$7b2o$7b2o$5bo3bo$5o6bo$4o8bo$b2o4bo4bo$8b5o!"},

/*
   "Bat ship(nopuff backrake)": {
    xsize: 20, // 18,
    ysize: 29, // 27,
    naturalXspeed: 0.5,
    naturalYspeed: 0, 
   counterpart: "Bat Ship Backrake-js-p8",
    patternstring: "10bobo$10bo2bo$13b2o$15bo$13b4o$5bo6bo4bo$5bob2o5bo2bo$8bo5bo2bo$8bo7bo$10bob4o$10bo3bo$13bo$9b5o2$9b5o$13bo$10bo3bo$10bob4o$8bo7bo$8bo5bo2bo$5bob2o5bo2bo$5bo6bo4bo$13b4o$15bo$13b2o$10bo2bo$10bobo!"
    },

*/

   "Batship (nopuff backrake)": {
    xsize: 20,
    ysize: 29,
    naturalXspeed: 0.5,
    naturalYspeed: 0, 
   counterpart: "Batship Backrake #1",
    rule: ["B3/S23","B37/S23"], //  note counterpart wont work in drylife - so create separate entry for drylife

    patternstring: "10bobo6bo$10bo2bo$13b2o$15bo$13b4o$5bo6bo4bo$5bob2o5bo2bo$8bo5bo2bo$8bo7bo$10bob4o$10bo3bo$13bo$9b5o2$9b5o$13bo$10bo3bo$10bob4o$8bo7bo$8bo5bo2bo$5bob2o5bo2bo$5bo6bo4bo$13b4o$15bo$13b2o$10bo2bo$10bobo6bo!"
    },

   "P24 Turner c/3": {rule:  "B3/S23",xsize: 34, ysize: 82, naturalXspeed: 0.3333333, naturalYspeed: 0, patternstring: 
"28bo$29b2o$29b2o$28bo$30bo$31bo$27bo2bo$28bob2o$15bo13b2obo$14bobo13bobo$14bobo10bob2o2bo$16bo14b3o$26bobo4bo$16b2o9b6o$14bobo$15bobo9b6o$15b3o8bobo4bo$31b3o$14bobo10bob2o2bo$15b2o13bobo$15bo13b2obo$13bobo12bob2o$13bobo11bo2bo$9b2o2b2o16bo$9b3o13bo2bo2bo$25bobo2b3o$9b3o14b2o$8bob3o14b3o$8bo18bobo$10bob2o12b2ob2o$8bo3b2o16bo$9b3o14b5o$11bo14b2o2bo$9b2o13bob2obo$7b3o19bo$6bo2bo12b7o$bo6bo7bo3bob2o2bo$ob3o3b2o5bo2bobo2b2o$8b3ob2o3bo5b2o$8b2o4b3o$bo6b2o3bo$bo6b2o3bo$8b2o4b3o$8b3ob2o3bo5b2o$ob3o3b2o5bo2bobo2b2o$bo6bo7bo3bob2o2bo$6bo2bo12b7o$7b3o19bo$9b2o13bob2obo$11bo14b2o2bo$9b3o14b5o$8bo3b2o16bo$10bob2o12b2ob2o$8bo18bobo$8bob3o14b3o$9b3o14b2o$25bobo2b3o$9b3o13bo2bo2bo$9b2o2b2o16bo$13bobo11bo2bo$13bobo12bob2o$15bo13b2obo$15b2o13bobo$14bobo10bob2o2bo$31b3o$15b3o8bobo4bo$15bobo9b6o$14bobo$16b2o9b6o$26bobo4bo$16bo14b3o$14bobo10bob2o2bo$14bobo13bobo$15bo13b2obo$28bob2o$27bo2bo$31bo$30bo$28bo$29b2o$29b2o$28bo!"
   },


   "Asymmetrical c/3 by Bell": {rule:  "B3/S23",xsize: 23, ysize: 19, naturalXspeed:0.33333333, naturalYspeed: 0, patternstring: "$2bobo$5bo10bo$2bo2bobo7bobo$3bo3bobo7b2o$b4o5b2o3bobo$4b7obo3b2o$12bobo$bo3b7o3bo2bo$9bo9bo$2b2obob2o10b2o$5bobo10bobo$20b2o2$20bo$18bobo$18bobo$19bo!"},


  "Glider puller c/2": {rule:  "B3/S23",xsize:  12, ysize: 18, naturalXspeed: 0.5,naturalYspeed: 0,  
       patternstring: "7bo2bo$11bo$7bo3bo$8b4o3$4b2o$2bo4bo$ob2o4b2o$2bo6bo$9bo$5bo2bo$6bo2$7bo2bo$11bo$7bo3bo$8b4o!"},


   "3 engine cordership c/12": {
    rule:  "B3/S23",
    xsize: 63,
    ysize: 58,
     naturalXspeed:  0.08333333,  // diagonal C/12  Approximately  .08333333333
      naturalYspeed:  0.08333333,
     patternstring: 
"50b2o$50b2o4$50b3o$50b4o3bo$48b2o8bo$48b2obo7bo$35b2o7b2o2b2o7bobo$36b2o6b2o4b5o3bo$35bo5bob2o8bo$39b2ob2o$40b3o$41bo2$35bobo$35bo2bo2$38bo$34bo4bo16bobo$35bo2bo17bobo$36b3o11bo3b2obo$37bo11b2o2bo2bo3bo$47bo3bobo6b2o$50bo4bobo4bo$48bobo6bob3o$57bob2o$33bobo$26b2o3b2obo$26b5ob2o3b2o$26bob2obobo3b2o$27b2o4bob2o2bo$25bobo6bobobo$25b2o9bobo$20b3o$20b4o3bo$11bo6b2o8bo$7b6o5b2obo7bo$6b2ob2o2bo4b2o7bobo$6b2o3bob2o5b5o3bo$8b4obo9bo$2o7b2o$2o7$8b2o16bobo$8b2o16bobo$20bo3b2obo$19b2o2bo2bo3bo$17bo3bobo6b2o$20bo4bobo4bo$18bobo6bob3o$27bob2o!"
   },

 "10 engine cordership c/12": {
    rule:  "B3/S23",
    xsize: 90,
    ysize: 90,
     naturalXspeed:  0.08333333,  // diagonal C/12  Approximately  .08333333333
      naturalYspeed:  0.08333333,
     patternstring: 
"$56b2o$56b2o7$51b3o10b2o$45bo6bo2bo8b2o$44bobo9bo$44bobo6bobo5$72b2o$37b2o33b2o$36bo$37b2o5$35bo44b2o$35b2o43b2o$35bo2bo2$36bobo$37bo5$25b3o$19bo6bo2bo55bo$18bobo9bo51b2o$18bobo6bobo52b2ob2o$84bo$82b2o2$83b2o2$11b2o39b2ob3o28bo$10bo41b2obo3bo23bobo$11b2o40bobo3bo24bo2b2o$53bo7bo$54b3obo2bo$57bo3bo$55bo4bo$9bo45bo3bo$9b2o33b2o10b3o$9bo2bo31b4o$48bo$10bobo31b3obob2o$b2o8bo32bo3bo3bo10b2obo$b2o41bo4bo2bo10b2obobo2bo$48bo3bo12bo2bo3bo$45b2o4bo10bobo6bo$50bo13bo5bo$47b3o22bo$59bo12bo$56b2o$9b2o45b2ob2o$9b2o47bo$56b2o2$57b2o2$60bo$57bobo$17b2o39bo2b2o$17b2o7$25b2o$25b2o$37b2obo$37b2obobo2bo$39bo2bo3bo$36bobo6bo$38bo5bo$46bo$46bo!"
   },

   "Day&Night P20 c/2": { xsize: 27,
                       ysize: 12,
                       naturalXspeed: 0.5,  
                       naturalYspeed: 0,
                       rule:  "B3678/S34678",
                       patternstring: "16bo$12b2ob2o4bo$12b8obobo$2b3ob2o3bob9o2bo$3b7o2b14o$27o$27o$3b7o2b14o$2b3ob2o3bob9o2bo$12b8obobo$12b2ob2o4bo$16bo!"
                   },

   "Day&Night big spark c/2": {xsize: 52,
                       ysize: 11,
                       naturalXspeed: 0.5,  
                       naturalYspeed: 0,
                       rule:  "B3678/S34678",
                       patternstring: "41bo$28bo8b2ob2o4bo$o15b2obo7b2o8b8obobo$14b6o7b3ob2o3bob9o2bo$14b7ob3o2b8o2b14o$15b37o$14b7ob3o2b8o2b14o$14b6o7b3ob2o3bob9o2bo$o15b2obo7b2o8b8obobo$28bo8b2ob2o4bo$41bo!"
                 },

"Day&Night bullet spark c/2": {xsize: 9,
                       ysize: 10,
                       naturalXspeed: 0.5,  
                       naturalYspeed: 0,
                       rule:  "B3678/S34678",
                       patternstring: "4bo$4b2o$3b4o$2ob5o$9o$b8o$bob5o$3b4o$4b2o$4bo!"
                 },

   "Day&Night 2c/7 EvanClark": {   xsize: 52,
                       ysize: 16,
                       naturalXspeed: 0.285714,  
                       naturalYspeed: 0,
                       rule:  "B3678/S34678",
   patternstring:   "29bo3bobo$3bobo18bobo2bo4bo$11b2o12bo4b5o2bob2o$2b5obobo4bo2b3obo3b4ob4o2b5o5bo$2b4obob3ob2ob2o4bo2bo2bobob12o2bob2o$ob11o4b3o3b2o3b2ob12o3b4o$2b7ob2obo3b4ob2ob3o3b15obobo$2b3obo4bo2bob5ob7ob11o5b4obo$2b3obo4bo2bob5ob7ob11o5b4obo$2b7ob2obo3b4ob2ob3o3b15obobo$ob11o4b3o3b2o3b2ob12o3b4o$2b4obob3ob2ob2o4bo2bo2bobob12o2bob2o$2b5obobo4bo2b3obo3b4ob4o2b5o5bo$11b2o12bo4b5o2bob2o$3bobo18bobo2bo4bo$29bo3bobo!"
        },

"Morley p20 c/2": {   xsize: 18,
                       ysize: 7,
                       naturalXspeed: 0.5,  
                       naturalYspeed: 0,
                       rule:  ["B368/S245", "B36/S245"],
   patternstring:   "12bobo$8b2obob3o$2o2bo2b2o6bobo$6o2b3obo3b2o$6o2b4o3b3o$2o2bo2b2o2bo5bo$8b2o!"
        },
 "Morley Razor c/4":{   xsize: 8,
                       ysize: 4,
                       naturalXspeed: 0.25,  
                       naturalYspeed: 0,
                       rule:  ["B368/S245", "B36/S245"],
   patternstring:   "4b2o$ob3ob2o$b4ob2o$o3b2o!"
        },

"Morley c/4 diag":{   xsize: 16,
                       ysize: 17,
                       naturalXspeed: 0.25,  
                       naturalYspeed: 0.25,
                       rule:   ["B368/S245", "B36/S245"],
   patternstring:   "5bo$2bo$2obo2b2o$4b2o$3obo2bobo$2bo2b2o3bo$ob2ob2obo$2bobobobo$4bob3o$3b2obob2obo$5bobob2obo$8bob2o3bo$9bob5o$11b2o$13b2o$11b3o$11bo!"
        },


"Morley Enterprise 4c/23":{   xsize: 12,
                       ysize: 12,
                       naturalXspeed: 0.25,  
                       naturalYspeed: 0.25,
                       rule:   ["B368/S245", "B36/S245"],
   patternstring:   "2$2b3o2$3bo3b2o$3b4o2bo$3b4o2bo$3bo3b2o2$2b3o!"
        },




"Morley slowship 13c/170": {   xsize: 68,
                       ysize: 62,
                       naturalXspeed: 0.076470589,  // 13c/170
                       naturalYspeed: 0,
                       rule:  "B368/S245",
   patternstring:   "26bo$24b4o$25bo8bo$7b4o14b3o6b2o$7b4o14b3o6b2o$25bo8bo$24b4o$26bo5$11b4o27bo$12b2o27bo$11bo2bo25bobobo$12b2o27bo2bo$41bo2bo$30bo9bobobo$41bo$28b2o12bo4$55bo$38b2o11b2o2bo10b2o$24b4o10b2o11b2o12b3o$25b2o11b2o11b2o12b3o$24bo2bo10b2o11b2o2bo10b2o$25b2o28bo4$50bo$18b2o29bobo$17bo2bo10b2o15b4o2bo$18b2o11b2o8b11o2bo$17b4o10b2o8b11o2bo$31b2o15b4o2bo$49bobo$50bo3$21b2o12bo$34bo$23bo9bobobo$34bo2bo$5b2o27bo2bo$4bo2bo25bobobo$5b2o27bo$4b4o27bo5$19bo$17b4o$18bo8bo$4o14b3o6b2o$4o14b3o6b2o$18bo8bo$17b4o$19bo!"
        },

"Low Morley slowship 7c/150":{   xsize: 67,
                       ysize: 24,
                       naturalXspeed: 0.046666666666667,  
                       naturalYspeed: 0,
                       rule:  "B36/S245",
   patternstring:   "2$39bobo$15bobo15bobo4bo$6bo6b4ob2ob2o10bobo4bo3bo$5bob2o3bo2bobo3b3o8bo3bo2bobo2bo$5bob2o3bo2bobo3b3o8bo3bo2bobo2bo$6bo6b4ob2ob2o10bobo4bo3bo$15bobo15bobo4bo$39bobo2$31bo2bo2bo$30b2obo2bo12bo$22b2obobobo4bob3o11bo11bo$21b2obo2bo2bo2b3o3bo10bo3bo4bobo$20bo2bo2bo2bo2b3o3bo10b2o4b2o2bo3bo$20bo2bo2bo2bo2b3o3bo10b2o4b2o2bo3bo$21b2obo2bo2bo2b3o3bo10bo3bo4bobo$22b2obobobo4bob3o11bo11bo$30b2obo2bo12bo$31bo2bo2bo!"
        },



"HighLife Bomber c/6 diag": {xsize: 21, ysize: 15, naturalXspeed:  0.008823529411765, naturalYspeed: 0, rule: "B36/S23", patternstring: "4bo7bo$4bo7bo$2b2ob2o5bo$2bo3bo$2o5b2o6b2o$2bo3bo7bo$2b2ob2o7b2ob2o$4bo8b2o2b2o$4bo6b3o6bo$10bobo5bobo$10bo6b3o$12b2o2b2o$12b2ob2o$16bo$14b2o!"
    },

"B3/S2456 c/2 bullet": {      xsize: 12,
                       ysize: 6,
                       naturalXspeed: 0.5,
                       naturalYspeed: 0,
                       rule:  "B3/S2456",
   patternstring:   "2bob2o$2bo4b2o2bo$3ob2o2b4o$3ob2o2b4o$2bo4b2o2bo$2bob2o!"
        },



"B3/S2456 c/5 asym": {      xsize: 25,
                       ysize: 10,
                       naturalXspeed: 0.2,
                       naturalYspeed: 0,
                       rule:  "B3/S2456",
   patternstring:   "$bo3bo2bo$bob2o3bob2o10bo$4bob2o4bo2b2obob3o$bob2o3bobob2o3bob4o$bo3bo4bo4bo6b2o$12bob2o2bo2bo$12b2o4b4o$12bo!"
        },

 
"B3/S2456 c/5 ship2": {      xsize: 35,
                       ysize: 15,
                       naturalXspeed: 0.2,
                       naturalYspeed: 0,
                       rule:  "B3/S2456",
   patternstring:   "$23bo5bo$24b3o3bo$5bo3bo15b3o2bobo$4b2o2bo2bo4b2o3bo6bob4o$9bobo3bob2o2b7o2bob2o$4b3o2b4o2b2o2b2ob6o2bobo$bob4o2bo5bo2bo9bo$4b3o2b4o2b2o2b2ob6o2bobo$9bobo3bob2o2b7o2bob2o$4b2o2bo2bo4b2o3bo6bob4o$5bo3bo15b3o2bobo$24b3o3bo$23bo5bo!"
        },

"B3/S2456 c/5 ship1": {      xsize: 29,
                       ysize: 17,
                       naturalXspeed: 0.2,
                       naturalYspeed: 0,
                       rule:  "B3/S2456",
   patternstring:   "$2bo$3bo13bo5bo$bo2bo5bobo5b3o2bo$4b2o2b2ob2o5b2ob2o3bo$4b2o2bobo5bo4bo2b4o$3bob2o2b13o3b3o$3bo7b12o$22b2o$3bo7b12o$3bob2o2b13o3b3o$4b2o2bobo5bo4bo2b4o$4b2o2b2ob2o5b2ob2o3bo$bo2bo5bobo5b3o2bo$3bo13bo5bo$2bo!"
        },



 
"B3/S2456 c/6 ship1": {      xsize: 28,
                       ysize: 15,
                       naturalXspeed: 0.166666666666667,
                       naturalYspeed: 0,
                       rule:  "B3/S2456",
   patternstring:   "$14bobo7bo$3bo10b3obo6bo$3b2o5bo2b7o2b2o2bo$b3obob2ob2obo4bo2bo3bo$2b2ob4obob7o2bo2bo$6bobobo2b4o2bo3bo$5bob2o2bo$6bobobo2b4o2bo3bo$2b2ob4obob7o2bo2bo$b3obob2ob2obo4bo2bo3bo$3b2o5bo2b7o2b2o2bo$3bo10b3obo6bo$14bobo7bo!"
        },


"2x2 and HotRep c/3": {xsize: 12, ysize: 10, naturalXspeed:  0.333333333, naturalYspeed: 0, rule: ["B368/S12578", "B36/S125"], patternstring: "$7bobo$b3o$4bobo2b2o$4bobo2b2o$b3o2bo2b2o$6bo2b2o2$7bobo!"
    },


"Quench slowship 3c/340": {xsize: 19, ysize: 17, naturalXspeed:  0.00882353, naturalYspeed: 0, rule: "B367/S35678", patternstring: "4$5b8o$4bob7o$4b9o$5b9o$4b11o$5b9o$4b9o$4bob7o$5b8o!"
    },



"Explodeship c/93 diag": {   xsize: 17,
                       ysize: 17,
                       naturalXspeed:  0.01075269, 
                       naturalYspeed: 0.01075269,                        
                       rule:  "B36/S2456",
   patternstring:   "$9bo$11bo$6bo2b2obo$4b6o3b2o$4b7ob4o$3b4o3b6o$4b2o4bob2o$4b2o3bo2bo$bob3o2b3o$3bob3obo$2bo3bo$3bob4o$4b4o$4b3o$5b2o!"
        },




"Even&Odd G10 c/6": {   xsize: 24,
                       ysize: 12,
                       naturalXspeed:  0.16666666667,
                       naturalYspeed: 0,
                       rule:  "B013468/S02",
                       momentary_counterpart: "Even&Odd G10 shooting",
   patternstring:   "$7bo$6b2o6b2o2bobo$6b2o5b3o2b2o$2b3o2b4o2b3ob5o$3b13o2b4o$3b13o2b4o$2b3o2b4o2b3ob5o$6b2o5b3o2b2o$6b2o6b2o2bobo$7bo!"
        },
/*  this pattern shoots just one of the smallest glider; the next pattern shoots a wider spaceship

"Even&Odd G10 shooting": {   xsize: 28,
                       ysize: 12,
                       naturalXspeed:  0.16666666667, 
                       naturalYspeed: 0,
                       rule:  "B013468/S02",
                       counterpart: "Even&Odd G10 c/6",
   patternstring:   "$7bo$6b2o6b2o2bobo$6b2o5b3o2b2o$2b3o2b4o2b3ob5o3bo$3b13o2b4o4bo$3b13o2b4o4bo$2b3o2b4o2b3ob5o3bo$6b2o5b3o2b2o$6b2o6b2o2bobo$7bo!"
        },
*/


"Even&Odd G10 shooting": {   xsize: 33,
                       ysize: 15,
                       naturalXspeed:  0.16666666667, 
                       naturalYspeed: 0,
                       rule:  "B013468/S02",
                       counterpart: "Even&Odd G10 c/6",
   patternstring:   "$25bo2bo$7bo21bo$6b2o6b2o2bobo9bo$6b2o5b3o2b2o10bo$2b3o2b4o2b3ob5o6b2o$3b13o2b4o$3b13o2b4o$2b3o2b4o2b3ob5o$6b2o5b3o2b2o8b2o$6b2o6b2o2bobo9bo$7bo22bo$29bo$25bo2bo!"
        },

"Even&Odd newl90 c/6": {   xsize: 41,
                       ysize: 9,
                       naturalXspeed:  0.16666666667, 
                       naturalYspeed: 0,
                       rule:  "B013468/S02",
                       momentary_counterpart: "Even&Odd newl90 shooting",
   patternstring:   "$20bo2bo6bo$19bob3o7bo$2bo16b4o7bo$bob3o3b5o6b3ob2obo4bo$4b2obobo2b3ob5ob6obo$3bo4b6o3b5o4b2o3bo$17bo3bo!"
        },

"Even&Odd newl90 shooting": {   xsize: 41,
                       ysize: 9,
                       naturalXspeed:  0.16666666667, 
                       naturalYspeed: 0,
                       rule:  "B013468/S02",
                       counterpart: "Even&Odd newl90 c/6",
   patternstring:   "$20bo2bo6bo5bo$19bob3o7bo6bo$2bo16b4o7bo4b3obo$bob3o3b5o6b3ob2obo4bo3b2obo$4b2obobo2b3ob5ob6obo8bo$3bo4b6o3b5o4b2o3bo4bo$17bo3bo!"
        },




"B3/S135 c/2 fleet": {   xsize: 286,
                       ysize: 163,
                       naturalXspeed:  0.5, 
                       naturalYspeed: 0,
                       rule:  "B3/S135",
   patternstring:   "275bo$275bo$277bo2b2obo$191bo4b3o79bo3b4o$191b2o2bo2b2o78bo5b2o$189b3ob6o28b2o14b2o8bo23b2o3b4o$189bo3b3o20bo7bo2b2o15b3o2bo4bobo4b2o17b2obo$188bo3bo21b3obobobo2b4o15bob5obo4bo3b2o$213b3obo3bob4o19b2o2bo2bo2b2ob4o$188bo3bo21bob4o26bo5b2ob2o3bo$189bo3b3o17b3obo3bob4o$189b3ob6o15b3obobobo2b4o$191b2o2bo2b2o16bo7bo2b2o47bo$69b3o60b2o57bo4b3o28b2o47bo$64bo3bo2b2o57bo2b2o143bo2bobo$64bo4b3o56bo2b3o112b2o5bo25bo2b4o$62b2obobo61bo115b4o5bobo4b2o16bo4b2o$67bo60b2o115bo2b3obo4bo3b2o15b2o2b4o$66bo2bo57b2o2b2obo112b2o4bo2b2ob4o18bobo$69b3o54bo6b4o85bo4b2o23b2ob2o3bo$70b2o28b2o33b2o77bo6b2obo2b2o$41b3o25b3o25bo2b2o24bo6b4o24bobo48b3obobob2o3b4o$40bo2b2o21bo2bo25b3ob3o25b2o2b2obo26bobo3b2o42b3obo3bo5b2o$38bo2b3o23bo28b2obo28b2o32bobo2b2o43bob4o$38b2o22b2obobo26bob2o31bo29bo4bob3o28bo13b3obo3bo5b2o46b2o2bo2b2obo$2bo7b2o24b2obo24bo4b3o22b3obo2bo26bo2b3o25bo3b2obo25bo4b3o12b3obobob2o3b4o45b2o2bo3b4o$2bo3bo3b2o22bo2bo3bo22bo3bo2b2o20b2o4b2ob2o26bo2b2o26b4o28bo4b2o14bo6b2obo2b2o46bo2bo5b2o$4b4ob3o21bobo5b3o25b3o31b2o27b2o25bob4o26bo3bob3o22bo4b2o48b2o3b4o$6bo2bo24bo2b2o3b2o49b2o4b2ob2o57b4o26bo2bo2bo82b2obo$3bo3bo25bobo5b3o50b3obo2bo57bo3b2obo25b3o$3bob2o2bo24bo2bo3bo52bob2o61bo4bob3o$2bo6b3o24b2obo56b2obo62bobo2b2o23b3o$bo2b2o4b2o26b2o55b3ob3o59bobo3b2o22bo2bo2bo$2bo6b3o26bo2b3o53bo2b2o32b2o25bobo27bo3bob3o18bo8b2o$3bob2o2bo30bo2b2o55b2o26bo2b2o2b2o56bo4b2o14bobob2o4bo2b2o45b2o2bo2bobo$3bo3bo33b3o81bo2b2o2b4o56bo4b3o16b2ob2ob3ob3o24bo21b2o2bo2b4o$6bo2bo116b4obo65bo17bo3b2o2b2obo27bobo4b2o13bo2bo4b2o$4b4ob3o115b2o91bo2b2o27bo4bo3b2o15b2o2b4o$2bo3bo3b2o57b2o58bobo83bo3b2o2b2obo23bo2bo2b2ob4o18bobo$2bo7b2o53bo3b2o58bo2b2o27bo54b2ob2ob3ob3o23b2ob2o3bo$61bob4ob3o30bo31b2o26b2ob3o47bobob2o4bo2b2o$67b2o31bob2o25bo2b2o25b2o4b4o49bo8b2o$62bo3bo28bobo5b2o24bobo28b2o5b2o20b2o2b2o2bo$67bobo26bobobob2o23b2o32bo3b4o21bobo3b4o$66b2o2b2o22bo4bobo24b4obo29b4obo26b2o3b2o79bo$71b2o21bo2b2o26bo2b2o2b4o54bo2b2o3b2o56bo4b2o16b2o$37b2o4b2o21b2o2b2o22bo33bo2b2o2b2o24b4obo22b2obo62b2obo2b2o15b2o3bo$36bo3bo2b2o22bobo26b2o36b2o25bo3b4o44b2o5bo33b2o3b4o14bobobob3o$37bo3b4o17bo3bo27bo65b2o5b2o20b2obo18bo4bobo2bob2obo32b2o17bo5b2o$38b5o24b2o25bo2b2o60b2o4b4o21bo2b2o3b2o12b2o2b2o2bo2bob4o50bo3b3o$b3obo2bo52bob4ob3o23bo4bobo59b2ob3o26b2o3b2o19bo2b2o3b2o51b2obo$2b4obob2o27bobo24bo3b2o25bobobob2o57bo28bobo3b4o12b2o2b2o2bo2bob4o$4bo5b2o26b2ob2o26b2o24bobo5b2o84b2o2b2o2bo13bo4bobo2bob2obo$2b2o3bob2o31b2o56bob2o29b2o78b2o5bo$4b2o2bo29b2ob2o58bo27b2o3b2o$b4o33bobo86b4o2b2o$2bo123b3o3bo$38b5o118bo$2bo34bo3b4o20b2o3bo60b4o23bo2bo30bob2obo63b2o$b4o31bo3bo2b2o21b2ob4o59bob3o21b4o5b2o25bob4o20bo37bo2b2o$4b2o2bo28b2o4b2o22bo3b2o25bob2o33b2o22b2o3bo2b2o22bob2o3b2o16bobo2bob2obo29bo2b4o$2b2o3bob2o53bobo4b2o23b4o2b2o28bob3o25bo2b4o25bob4o16b2o2bo2bob4o28b4o20b3o$4bo5b2o52bo30bo2b2o3b2o26b4o28b4o24b2ob2obo21bo2b2o3b2o48bo4b4o$2b4obob2o56bo34b2o112b2o2bo2bob4o28b4o14bo2b2o4b2o$b3obo2bo56b5o25b3o28b3o3bo30b4o24b2ob2obo18bobo2bob2obo29bo2b4o14b2o3b4o$68b2o25bobo29b4o2b2o27bo2b4o25bob4o20bo37bo2b2o18b3o$35bo5b2o22b5o24bob4o29b2o3b2o23b2o3bo2b2o22bob2o3b2o61b2o$36b2o3b2o24bo30b2o33b2o23b4o5b2o25bob4o$33b2ob3ob3o21bo29bob4o58bo2bo30bob2obo$34b2o3b2o23bobo4b2o22bobo63bo$34bo3bo28bo3b2o22b3o$39bobo24b2ob4o29b2o$38b2o2b2o21b2o3bo24bo2b2o3b2o151bo4b2o$43b2o51b4o2b2o28bo123bo4b2o$38b2o2b2o54bob2o23bob2o2bob3o58b2obo60bob3o$2b2o4b2o29bobo87b4o2b2o23bo31bobob4o57b4o$bo3bo3b2o23bo3bo87bo2b2o3b2o24b2o30b3o3b2o75bob2o$bo3bo2b2o24b2o3b2o86b3o28b3o5b2o26bob4o22bo2bo31b4o19bo$3bo3bo25b2ob3ob3o23bo3bo57b2o2bo25bo4b2o2b2o22b2ob2obo23b7o30bob3o13bo2b3o$2bo33b2o3b2o23b2ob4o57b5o22bo3bo2b4o53b2o3b2o28bo4b2o17b4o$6b4o25bo5b2o20b2o2bo3b2o25b2o33b2o28bo27b2ob2obo26b4o28bo4b2o20b3o$7bob3o51bob2o4b2o26bo2bo27b5o59bob4o23b3o58b2o$10b2o88bob3o23b2o2bo30bo28b3o3b2o22bo61b2o$7bob3o50bo2bo29bo2bo4b2o22b3o27bo3bo2b4o24bobob4o22bo$6b4o52b3ob2o28bo2bo2b3o21bo2b2o3b2o22bo4b2o2b2o25b2obo25b3o$2bo64b2o27b2obo2bo26b4o2b2o21b3o5b2o56b4o$3bo3bo29bo4b2o18b3ob2o57bob2o2bob3o24b2o59b2o3b2o$bo3bo2b2o27b2o4b2o17bo2bo33b2o31bo27bo60b7o$bo3bo3b2o28bo2b2o178bo2bo54b2o$2b2o4b2o25bo3bobo21bob2o4b2o23b2obo2bo178b3o$63b2o2bo3b2o23bo2bo2b3o174bo3b3o$34bob5o25b2ob4o22bo2bo4b2o174bo4b2o$38bob3o23bo3bo29bob3o179b2o$41b2o56bo2bo32b2o24bo$38bob3o55b2o35b2o24bo63bo$3bobo3b2o23bob5o92b4o23b2o5b2o22bob2obo28b3o$2bob4o2b2o117b2o3bo25bo3bo2b2o26bob2o27b2o$b4obob3o24bo3bobo88b2o30bo2b4o24bo4b2o23b2ob2o$obo4bo31bo2b2o87bobo29b4o24bobobob2o23bobo53bo$o36b2o4b2o89b2o57b2obo25bobo30bob2o18bo2bo$3bo33bo4b2o54b2o35b2o26b4o25b2o29b2ob2o32bo16bo2b2obo$b5o93bo2bo31b2o26bo2b4o23b2o32b2o28bo2b3o17bobob3o$4b2o94bob3o26bobo26bo3bo2b2o24b2obo28b3o32b4o20b2o$b5o63b3o26bo4b2o25b2o28b2o5b2o22bobobob2o26bo37b3o17b3o$3bo64bo2b2o26bo2b3o24b2o3bo26bo31bo4b2o64b2o17bo$o65b6o25bobo2bo30b4o24bo33bob2o64b3o$obo4bo29bo4b2o20bo2b2o66b2o54bob2obo63b4o$b4obob3o26bob2o2b2o18bobo33b2o34b2o119bo2b3o$2bob4o2b2o25bo2b4o20bo2bobo190bo$3bobo3b2o28bo23bo3b2ob2o25bobo2bo152bob2o$37bo33b2o26bo2b3o174bo$40bo22bo3b2ob2o26bo4b2o62b2o111b2o$38b5o21bo2bobo30bob3o57b2o3b2o23bob2obo81bob3o$41b2o20bobo33bo2bo31b2o25b4ob3o22b2o3b4o80bob4o$38b5o21bo2b2o29b2o35b2o24bo2b3o24b2o5b2o24b3o57b2o$40bo25b6o62b2o56bo3b4o23bo2b2o27bo27b3o$37bo30bo2b2o58bobo27bo2bo29b2obo26b3o28bo27bo$39bo29b3o58b2o29bo2b2o26bo27bobo34bo$37bo2b4o85b2o3bo26bo2bo27bo29bo35bob2obo$37bob2o2b2o88b4o57b2obo24bo34bo2bob4o$8b3o26bo4b2o91b2o24bo2b3o25bo3b4o20bobo33bo2b2o3b2o$b3o3bo2b2o121b4o24b4ob3o22b2o5b2o24b3o30bo2bob4o$bobobo2b3o118b2o3bo27b2o3b2o22b2o3b4o23bo2b2o30bob2obo$2bo2b2o123b2o35b2o23bob2obo26b3o30bo$4bobo124bobo121bo$2bo5bo92b3o30b2o119bo$bo2bo3b3o27bo4b2o55bo2b2o30b2o$bo2b2o3b2o27bo4b2o53bo2b3o30b2o$bo2bo3b3o29bob3o24b2o27b2o$2bo5bo30b4o20bobo3b4o23b2obo59bo2bo34b2o$4bobo28b3o24b2o2bobo2b2o23bo4bo57b3o5b2o29b2o$2bo2b2o29b3obo21b2ob2o4b2o28b3o58bobo2b2o20b3o5b2o58bo$bobobo2b3o27bo2b2o20b3o36b2o58bo2b4o21b3obobo60b2o23b2o$b3o3bo2b2o30b2o19bo4bo32b3o27b2o2b2o26b4o25b3o64bob3o18b4o$8b3o27bo2b2o22bobob2o25bo4bo24bo8b2o56bo27bobobo33bo2b4o15bo2b2o$36b3obo29b2o24b2obo27b2o4b4o26b4o26bo26b2o2b4o36b2o18b2o$35b3o27bobob2o27b2o28b2o2b3o27bo2b4o23b3o25b2o4b2o31bo2b4o$39b4o20bo4bo29bo2b3o25bob2o29bobo2b2o21b3obobo24bo2b4o31bob3o$40bob3o18b3o34bo2b2o23bo30b3o5b2o20b3o5b2o24bobo31b2o$38bo4b2o17b2ob2o4b2o28b3o23bo2b2o27bo2bo35b2o21bo35bo$38bo4b2o17b2o2bobo2b2o55bo68b2o22bo$63bobo3b4o56bob2o90bobo$69b2o57b2o2b3o86bo2b4o$127b2o4b4o83b2o4b2o$126bo8b2o83b2o2b4o$131b2o2b2o84bobobo$198b2o$195bo2b2o$193bo2b4o$196b2o$194bo66b3o$194bo25b2o2bo37b4o17b2o$196b2o23bobob2o37b2o18b2o$193bo2b4o20bo5b2o34b4o17b2o$195bo2b2o21bo2b3o34b3o17b2o$198b2o22bo$223bo$223bo$222bo$221bo2b3o$220bo5b2o$221bobob2o$220b2o2bo!"
        },



      "----Puffers and Rakes----": {patternstring: "3o"},

  "Bship": {
   rule:  "B3/S23",
   xsize: 30,
   ysize:  17,
    naturalXspeed: 0.5,
   naturalYspeed: 0,
   patternstring:"15b2o$14b4o$14b2ob2o$16b2o$24b4o$23bo3bo$3b3o7bo13bo$2bo3bo4b3o5b2o2bo2bo$2bo3bo3b3o6b3o$2bo3bo4b3o5b2o2bo2bo$3b3o7bo13bo$23bo3bo$24b4o$16b2o$14b2ob2o$14b4o$15b2o!"

   },

    "Spacerake c/2": {
     rule:  "B3/S23",
     xsize: 25,
     ysize: 21,
       naturalXspeed: 0.5,
   naturalYspeed: 0,
    patternstring: "$3b4o$2bo3bo12bo2bo$6bo16bo$2bo2bo13bo3bo$20b4o4$13bo4b2o$10b4o3b2ob2o$9b5o4bo2bo$8bo9bo2bo$9b2o8b2o$10bo2$12b2o5bo2bo$11b4o8bo$11b2ob2o3bo3bo$13b2o5b4o!"

     },


   "Batship Backrake #1": {
     rule:  "B3/S23",
    xsize: 20,
    ysize: 29,
    naturalXspeed: 0.5,
   naturalYspeed: 0,
    counterpart: "Batship (nopuff backrake)",
   patternstring:  "10bobo$10bo2bo$13b2o$15bo$13b4o$5bo6bo4bo$5bob2o5bo2bo$8bo5bo2bo$8bo7bo$10bob4o$10bo3bo$b6o6bo$o5bo2b5o$6bo$o4bo3b5o$2b2o9bo$7bo2bo3bo$10bob4o$6bobo7bo$8bo5bo2bo$6b3o5bo2bo$12bo4bo$13b4o$15bo$13b2o$10bo2bo$10bobo!"
     },

 "Siderake shooting MWSS P24": {
     rule:  "B3/S23",
    xsize: 50,
    ysize: 28,
    naturalXspeed: 0.5,
   naturalYspeed: 0,
    counterpart: "Siderake non-shooter",
   patternstring:  "$34b2o$30b4ob2o$30b6o$31b4o2$46b2o$33bo10b2ob2o$34bo5bo3b4o$3bo25bo2b3o3b2obo3b2o$bo3bo22bobo7bo3bo$6bo21bob5o3b2obo3b2o$bo4bo11bo13b3o5bo3b4o$2b5o10bo26b2ob2o$17b3o11b2o13b2o$29bo4bo$35bo$29bo5bo$b3o20b2o4b6o$4bo8bo8b2ob2o$4bo6bobo4bo3b4o$bo2bo5bo2bo5bo3b2o$2b3o5bo6bo2bo$10bo2bo5bo3b2o$11bobo4bo3b4o$13bo8b2ob2o$24b2o!"
     },

"Siderake non-shooter": {
     rule:  "B3/S23",
    xsize: 49,
    ysize: 29,
    naturalXspeed: 0.5,
   naturalYspeed: 0,
    counterpart: "Siderake shooting MWSS P24",
   patternstring:  "$30b6o$29bo5bo$35bo$29bo4bo$31b2o2$44b4o$33bo9bo3bo$34b2o11bo$31b3o5b2o2bo2bo$30b3o6b3o$4b2o25b3o5b2o2bo2bo$b3ob2o27b2o11bo$b5o25bobo9bo3bo$2b3o39b4o2$33b2o$29b4ob2o$22b4o3b6o$21bo3bo4b4o$17bo7bo$12b7o2bo2bo$11bo2b3ob2o$12b7o2bo2bo$17bo7bo$21bo3bo$22b4o!"
     },

  "Slowpuff c/2": {
   rule:  "B3/S23",
   xsize: 23,
   ysize:  25,
   naturalXspeed: 0.5,
   naturalYspeed: 0,
   englishname: "slow puffer train",
      patternstring: "6bo$4bo3bo$9bo$4bo4bo8b3o$5b5o7b5o$17b3ob2o$20b2o2$18bo$7bo8bo3bo$4bobobo12bo$5obob4o3bo5bo$11bo3b7o$5obob4o$4bobobo$7bo$15b4o$14b6o$14b4ob2o$18b2o$5b5o$4bo4bo$9bo$4bo3bo$6bo!"

   },

 
 



    "P78 frothing puffer c/2": {    
      rule:  "B3/S23",  
      xsize: 23,
      ysize: 33,
      naturalXspeed: 0.5,
      naturalYspeed: 0,
     patternstring:
"14bo$14b4o$15b3o$15bo3bo$17b3o$4bo10bo4bo$4bob2o8b6o$7b4o10b2o$9b2o5b\
2o3bo$3bob2obo3bo2bo2b2o$2bo2bo4b3o4bobo$o2b2o2b2o5bo3b3o$b3o8b3o5bo$o\
5bobo7bo3bo$2b2o4bo5b2o3bo$bo2b5o8b2o$2bo11b2o$bo2b5o8b2o$2b2o4bo5b2o\
3bo$o5bobo7bo3bo$b3o8b3o5bo$o2b2o2b2o5bo3b3o$2bo2bo4b3o4bobo$3bob2obo\
3bo2bo2b2o$9b2o5b2o3bo$7b4o10b2o$4bob2o8b6o$4bo10bo4bo$17b3o$15bo3bo$\
15b3o$14b4o$14bo!"

     },

/*
"colliding rakes no spark c/2":  {      xsize: 26,
      ysize: 79,
      naturalXspeed: 0.5,
      naturalYspeed: 0,
     patternstring:
"$20b2o$11b4o4b4o$10bo3bo4b2ob2o$14bo6b2o$10bo2bo2$8b2o$8b2o8b2o$7bo3bo5bo2bo$8bo3bo4bo2b2o$8bo4bo2bo2b2o$10bobo3b4o3$20b2o$19b4o$2b2o15b2ob2o$b4o16b2o$b2ob2o$3b2o38$4b2o$2b2ob2o$2b4o16b2o$3b2o15b2ob2o$20b4o$21b2o3$11bobo3b4o$9bo4bo2bo2b2o$9bo3bo4bo2b2o$8bo3bo5bo2bo$9b2o8b2o$9b2o2$11bo2bo$15bo6b2o$11bo3bo4b2ob2o$12b4o4b4o$21b2o!"
     },
*/

"colliding rakes no spark":  { 
      rule:  "B3/S23",    
       xsize: 95,
      ysize: 79,
      naturalXspeed: 0.5,
      naturalYspeed: 0,
     patternstring:
"$79bo2bo$83bo6b2o$79bo3bo4b2ob2o$80b4o4b4o$89b2o2$81bo$79bo4bo3bo$71b2ob2o3bo3bo4b2o$71bo2bo8bo5b2o$72b3o13b2o$77bo2bo$78b2o3$61bo28b2o$61bobo24b2ob2o$61b2o9b2o14b4o$70b2ob2o14b2o$70b4o$46bo24b2o$46bobo$46b2o3$31bo$31bobo$31b2o3$16bo$16bobo$16b2o3$bo$bobo$b2o2$2b2o$2bobo$2bo3$17b2o$17bobo$17bo3$32b2o$32bobo$32bo3$47b2o$47bobo$47bo24b2o$71b4o$71b2ob2o14b2o$62b2o9b2o14b4o$62bobo24b2ob2o$62bo28b2o3$79b2o$78bo2bo$73b3o13b2o$72bo2bo8bo5b2o$72b2ob2o3bo3bo4b2o$80bo4bo3bo$82bo2$90b2o$81b4o4b4o$80bo3bo4b2ob2o$84bo6b2o$80bo2bo!"

     },


"colliding rakes big spark":  {   rule:  "B3/S23",   xsize: 139,
      ysize: 48,
      naturalXspeed: 0.5,
      naturalYspeed: 0,
     patternstring:
"$130b2o$121b4o4b4o$120bo3bo4b2ob2o$124bo6b2o$120bo2bo3$112b3o13b2o$111b4o13bobo$49b3obo57bo3bo12bob2o$49b3o2bo57b3o14b2o$53b3o56b3o3b2o9bo$52b3o5b3o55b2o$50b2obo6bo2bo$51b2o6bo4bo65b2o$59b3o3bo35bo27b4o$30bo30b2o2b2o33bo11b2o15b2ob2o$30bo31bob2obo32b3o8b4o16b2o$30bo17bo10b2obob3obo4bo37b2ob2o$4bob2o19bo30bo3b3obob2o2b3o38b2o$2b3ob2o10b3o6bobo4b2o23bo3bo4b2ob2o2bo10bo$bo5bo19bo6b2o9b3o7bo8bo4b2o3b2o9bo$2b4o16b2o15bo5b3o6b2o10bob3o14b3o$21bo2bo12b2ob2o11bo14b3o18b3o$2b4o16b2o15bo5b3o6b2o10bob3o18bo$bo5bo19bo6b2o9b3o7bo8bo4b2o3b2o14bo$2b3ob2o10b3o6bobo4b2o23bo3bo4b2ob2o2bo41b2o$4bob2o19bo30bo3b3obob2o2b3o40b2ob2o$30bo17bo10b2obob3obo4bo30b3o8b4o16b2o$30bo31bob2obo36bo11b2o15b2ob2o$30bo30b2o2b2o38bo27b4o$59b3o3bo68b2o$51b2o6bo4bo$50b2obo6bo2bo58b2o$52b3o5b3o53b3o3b2o9bo$53b3o60b3o14b2o$49b3o2bo60bo3bo12bob2o$49b3obo61b4o13bobo$116b3o13b2o3$124bo2bo$128bo6b2o$124bo3bo4b2ob2o$125b4o4b4o$134b2o!"

     },




   "Switch engine c/12": {
     rule:  "B3/S23",
     xsize: 67,
     ysize: 60,
      naturalXspeed: 0.08333333,  // diagonal C/12  Approximately  .08333333333
      naturalYspeed: 0.08333333,
     patternstring: "bo$2o2$22b3o$23bo2bo$27bo$24bobo!"

   }, 


 "Switch engine (gliders) c/12": {
     rule:  "B3/S23",
     xsize: 7,
     ysize: 28,
      naturalXspeed: 0.08333333,  // diagonal C/12  Approximately  .08333333333
      naturalYspeed: 0.08333333,
     patternstring: "26b2o$25bobo$12b2o12bo$11bobo$12bo3$2o44b3o$2o44bo2bo$45bo3bo$45b2o$46bobo$47b2ob2o$48bo2bo$26b2o10b2o9b2o$24b2obo9bo2bo$24b3o11bobo$33bo5bo$33bo$17bo$16bobo10bo$17b2o9b3o$29b2o5$52b2o$52b2o3$24b2o$24b2o3$43bo$43b2o$45bo$41b4o$32b2o6bo$32b2o10bo$40bo$41bo2bo3$49bo14b2o$46bo17bobo$64bobo$52b2o10bobo$48bo3b2o10bobo$49bo2b2o$50b2o$63b3o$62bo3bo$61bo4bo$60bo2b3o$61bo$65bo$65bo$65bo!"

   }, 

 "Forward Rake Cordership": {rule:  "B3/S23",xsize: 169, ysize: 175,  naturalXspeed: 0.08333333,        naturalYspeed: 0.08333333, 
patternstring: "2$148b2o$148b2o7$156b2o$156b2o3$108b2o$108b2o$105bo$104b3o$103b2o2bo$103bob4o35b3o$103bo4bo35bo2bo$103bo2b2o35bo3bo$105b2o9b2o25b4o12bo$116b2o26bo14bob2o$101bo56bobob2o$101bobo48bo4b3o4b2o$101b2o48bobo3b3obo2bo2bo$158bo2b3o3bo$144b3o20bo$124b3o10bo22b4ob2o$121b2obob2o7b2ob3o20bo2bo$120bo3bob3o5bo2bob3o22bo$120bob2ob5o8b2ob2o19b2o$120b2o3b3obo8bo2b3o$121bo4b2o6b7o2b3o$115bobo19bo3bo2bo$115b3o19b7o$115bo2bo18b2o2bo$117bo21bobo$117bo22bo$69bo$69bobo$69b2o43b2o$113bo2bo$113b2obo$115b4o$119bo$115b2o3bo$98bobo14bo3bo$98bobo15b3o$92bo3b2obo$91b2o2bo2bo3bo$89bo3bobo6b2o$92bo4bobo4bo$89bo2bo6bob3o$90b2o7bob2o$52bo33bo$53b2o30b3o$46b2o4b2o30bo3b2ob3o$45bo2bo24bob3o5b2ob7obo$46b2o23b2obo3bo5bobobo3bobo$72bo4b2o6bob3o3bo$42bo30b4obo$41bobo21b2o$41bobo21b2o$42bo2$53b2o$53b2o3$73b2o17b2o$68bo4b2o16b3o$69b2o19bo$68b2o14b3o2b2o$40bo20b2o19b3o3b3o3b3o$40b2o19b2o20b3o4bobo3bo$39bobo41b2o7b5o$92bo3$60b2o$58b5o$57bo4bo4bo$57bo2b3o4bo$57b2o2bo5bo$59b2o2$48bo35bo$47bobo35b2o$48bo35b2o3$49b3o3$52b2o$51b2obo7b2ob3o$51b2ob2o5b3ob2obo$51b2ob2o5bob2o4bo$61bo8bo$61bo4bobobo$52bo13bo4bo$51b3o8bo7bo$50b3obo8bo36bo$49b4obo9bo3bo32b2o$48b3ob2o46b2o$24bo28bo12b2o$24b2o$19b2o2bobo26b3o$18bobo$18bo$18b2obo$20b2o$14b2o$14b2o3$30b2o$29b5o$28b2ob5o7b2o71bo$28b2o3b3obo4b2ob2o70b2o$22b2o4b2o5bo2bo8b2o67b2o$22b2o13b2o6bo3bo$37bo8b3o$30b2o$29b4o$29b5o$34bo$34b2o$31bobo$30b3o$30bobo$31b2o$33bo$33b2o$33b2o97bo$133b2o$132b2o3$29b2ob3o$29b2obo3bo$30bobo3bo$30bo7bo$31b3obo2bo$34bo3bo$32bo4bo$32bo3bo$22bo10b3o$21b2o$20b2o5b3o$21b2o125bo$149b2o$2b2o23bo120b2o$2b2o21bo2bo$25bo2$25bob2o$26bo3$10b2o$10b2o12bo$23bo$22b2ob4o$23bob5o$23bo6bo$24b3o2b3o132bo$25bobob2o134b2o$25b2ob2o134b2o$26b3o$27bo!"
    },

 "Day&Night wickstretcher c/3": {   xsize: 24,
                       ysize: 23,
                       naturalXspeed: 0.33333333,  
                       naturalYspeed: 0,
                       rule:  "B3678/S34678",
                       patternstring:   "b2obo$b3obo5bobo$6o5b2obo$b4o2bo2b5o4b2o$8ob6o$b14o2b6o$16obob2ob2o$b20obo$16o2bo3bo$b15obobobo$23o$b22o$23o$b15obobobo$16o2bo3bo$b20obo$16obob2ob2o$b14o2b6o$8ob6o$b4o2bo2b5o4b2o$6o5b2obo$b3obo5bobo$b2obo!"
        },


 "Day&Night double rake c/3": {   xsize: 207,
                       ysize: 61,
                       naturalXspeed: 0.33333333,  
                       naturalYspeed: 0,
                       rule:  "B3678/S34678",
                       patternstring:   "3b4o$b2o4bo124b2o$b7o122bo$2ob2ob2o121bob5o23b2o$3bobo124bob2ob2o20bo$3b4o122b2ob2obo20bob5o$bo2bobo124b2o2bo5b4o12bob2ob2o$b6o123b2o2bo4b2o4bo10b2ob2obo$4bobo109bo14b5o3b7o12b2o2bo$b2ob3o113bo9b6o2b2ob2ob2o11b2o2bo$3bobo109b2obob2o9bob3o5bobo14b5o$3b2ob2o109bo2b2o10bobo6b4o12b6o$2b6o100b5obob2ob2o10b2o2bo3bo2bobo13bob3o$2bo4bo98b9ob2o14b2obo3b6o14bobo$3b4o100b3ob2obo3b2o10bob2ob2o5bobo13b2o2bo37b3obobo$106bob4ob4obo11b6o3b2ob3o14b2obo39bo2b2o$113bo27bobo13bob2ob2o30b3o5bo3bo$108b2o22b2o7b2ob2o11b6o30bo3bo3b2o2b2o$140b6o47b7ob2o2bo$140bo4bo13b2o31b7obo2bo$141b4o48b4ob3obobo$192bo4bo2bo3$184b2o$184bo$179b2o3bo3bo$168b2o9b8ob2o$151b2o13b6ob2o3bob11o$151b3o4bo7b11o2b13o$150bob5o10b26o$151b3o4bo7b11o2b13o$151b2o13b6ob2o3bob11o$168b2o9b8ob2o$179b2o3bo3bo$184bo$184b2o3$192bo4bo2bo$141b4o48b4ob3obobo$140bo4bo13b2o31b7obo2bo$140b6o47b7ob2o2bo$108b2o22b2o7b2ob2o11b6o30bo3bo3b2o2b2o$113bo27bobo13bob2ob2o30b3o5bo3bo$106bob4ob4obo11b6o3b2ob3o14b2obo39bo2b2o$3b4o100b3ob2obo3b2o10bob2ob2o5bobo13b2o2bo37b3obobo$2bo4bo98b9ob2o14b2obo3b6o14bobo$2b6o100b5obob2ob2o10b2o2bo3bo2bobo13bob3o$3b2ob2o109bo2b2o10bobo6b4o12b6o$3bobo109b2obob2o9bob3o5bobo14b5o$b2ob3o113bo9b6o2b2ob2ob2o11b2o2bo$4bobo109bo14b5o3b7o12b2o2bo$b6o123b2o2bo4b2o4bo10b2ob2obo$bo2bobo124b2o2bo5b4o12bob2ob2o$3b4o122b2ob2obo20bob5o$3bobo124bob2ob2o20bo$2ob2ob2o121bob5o23b2o$b7o122bo$b2o4bo124b2o$3b4o!"
        },



"HighLife p48 rake": {   xsize: 25,
                       ysize: 26,
                       naturalXspeed:  0.16666666667, 
                       naturalYspeed: 0.16666666667,
                       rule:  "B36/S23",
                       patternstring:   "$9bo5b2o$9bo6b2o$9bo3bob2o$13b3o$14bo5bo$19b3o$18b2obo$17b2o$18b2o$4b3o3$7bo$6b3o$5b2ob2o$4b2ob2o$3b2ob2o3bo$4b3o3b3o$5bo3b2ob2o$8b2ob2o$7b2ob2o$8b3o$9bo!"
        },




"Morley Rake1": {     xsize: 49,
                       ysize: 58,
                       naturalXspeed: 0.5, 
                       naturalYspeed: 0,
                       counterpart:  "Morley Rake1 (half)",
                       rule:  "B368/S245",
                       patternstring:   "6$34bo$32b4o$34b2o$34bo$33bo2$33bobo$34b2o$30b6o$32bo2bo$31bo2$31b2o$32bo$32bo$24b2o5b2o4bo$23b2obo8b3o$22bo9bo3b2o$20b3o2bob3o5bobo$22bo7b2ob3o$23b2obo3bobobo$24b2o$14b2o$14b2o19bo2bo$14bob2o12bobo2bobobo$14b4o5b3o2bo2b2ob3o3bo$23b3o2b2obobo6b2o$23b3o2b2obob3o2b4o$23b3o2bo2b2obo5bo$30bobo2$26bo$25b3o$26bobo$23bobo3bo$25b2o2b2o$24b2o2b3o$26b2obo$22bob2o2$24bobo$25bobo$22bobo3bo$23b2o3b2o$26b4o$28bo!"
        },



"Morley Rake1 (half)": {     xsize: 49,
                       ysize: 58,
                       naturalXspeed: 0.5, 
                       naturalYspeed: 0,
                       counterpart:  "Morley Rake1",
                       rule:  "B368/S245",
                       patternstring:   "6$34bo$32b4o$34b2o$34bo$33bo2$33bobo$34b2o$30b6o$32bo2bo$31bo2$31b2o$32bo$32bo$24b2o5b2o4bo$23b2obo8b3o$22bo9bo3b2o$20b3o2bob3o5bobo$22bo7b2ob3o$23b2obo3bobobo$24b2o2$35bo2bo$30bobo2bobobo$23b3o2bo2b2ob3o3bo$23b3o2b2obobo6b2o$23b3o2b2obob3o2b4o$23b3o2bo2b2obo5bo$30bobo!"
        },




"Morley Rake2": {     xsize: 89,
                       ysize: 77,
                       naturalXspeed: 0.5, 
                       naturalYspeed: 0,
                       rule:  "B368/S245",
                       patternstring:   "5$78bobo$74b2obob3o$66b2o2bo2b2o6bobo$66b6o2b3obo3b2o$66b6o2b4o3b3o$66b2o2bo2b2o2bo5bo$74b2o3$39bo$40bo15b3o10b2o$37b2o16bob2o2b2o2bo2b2o2bo5bo$37b2ob2o13b2o4b6o2b4o3b3o$35bob2obo14bobo3b6o2b3obo3b2o$33b3o2bo17b3o2b2o2bo2b2o6bobo$35bob3o16b3o10b2obob3o$33bo5bo33bobo$33bo2b2o$32b2o3bo$18bo13bo3bo14b2o$12bo4bo15bobo7b2o2bo2b2o2bo5bo$14bo3bo14bo2bo6b6o2b4o3b3o$12b2o18bo2bo7b6o2b3obo3b2o$12b2obo17b2o8b2o2bo2b2o6bobo$32b4o15b2obob3o$11b3o41bobo4$49bobo$26b4o15b2obob3o$27b2o8b2o2bo2b2o6bobo$26bo2bo7b6o2b3obo3b2o$27bo2bo6b6o2b4o3b3o$27bobo7b2o2bo2b2o2bo5bo$26bo3bo14b2o$3b3o20b2o3bo$4b2o21bo2b2o$5bo21bo5bo33bobo$29bob3o16b3o10b2obob3o$27b3o2bo17b3o2b2o2bo2b2o6bobo$29bob2obo14bobo3b6o2b3obo3b2o$31b2ob2o13b2o4b6o2b4o3b3o$31b2o16bob2o2b2o2bo2b2o2bo5bo$34bo15b3o10b2o$33bo3$68b2o$60b2o2bo2b2o2bo5bo$60b6o2b4o3b3o$60b6o2b3obo3b2o$60b2o2bo2b2o6bobo$68b2obob3o$72bobo!"
        },

"Low Morley MessyRake 7c/300": { xsize: 147,
                       ysize: 32,
                       naturalXspeed: 0.0233333333,  // 7c/300
                       naturalYspeed: 0,
                       rule:  "B36/S245",
                       patternstring:   "21b4o24b4o24b4o$130b3obo$31b2o26b2o54b2o12bobobo2bo7b2o$31bobo25bobo53bobo11bobobo3bo6bobo$31bobo25bobo53bobo11bobobo3bo6bobo$31b2o26b2o54b2o12bobobo2bo7b2o$130b3obo5$34bobo$17bo16b2obo36bo$16bob2o13bo4bo34bob2o$16bob2o13bo4bo34bob2o53bo$17bo16b2obo36bo53bobobo$34bobo77bo11b2o3bo11bo$113bob2o9b2o3bo10bob2o$83b3o27bob2o9b2o3bo10bob2o$114bo11b2o3bo11bo$128bobobo$130bo3$35bobo$33bo2bo$16b2o13bob2o3bo34b2o$o14bobo12b2ob3ob2o33bobo$o14bobo12b2ob3ob2o33bobo$o15b2o13bob2o3bo34b2o$33bo2bo$35bobo!"
        },

"Drylife c/2 Rake": { xsize: 35,
                       ysize: 27,
                       naturalXspeed: 0.5,
                       naturalYspeed: 0,
                       rule:  "B37/S23",
                       patternstring:   "$21bob2o$21b2o2bo$18bo3bo2bobo$16b7obob2o$17bo10bobo$17b15o$9bo6b2o13b2o$7bo2bo5b12o3b3o$6bo19bo3b3o$6bo8b8ob2o4bo$6bobo3bo5bobo3bo7bo$12b6ob5o6bobo$20bo12bo$12b6ob5o6bobo$6bobo3bo5bobo3bo7bo$6bo8b8ob2o4bo$6bo19bo3b3o$7bo2bo5b12o3b3o$9bo6b2o13b2o$17b15o$17bo10bobo$16b7obob2o$18bo3bo2bobo$21b2o2bo$21bob2o!"
        },

"Drylife 9c/28 Rake": { xsize: 29,
                       ysize: 76,
                       naturalXspeed: 0.32142857,
                       naturalYspeed: 0,
                       rule:  "B37/S23",
                       patternstring:   "$9b2obobo$9b2o3bo4bo$11bo7b2o$12bo5b2o$12bo$13b3o$13b3o$15bobo$17bo2$16b2o$16bo5b2o$15bo7b2o$13b2o3bo4bo$13b2obobo4$18bo$15bob2o$14b3o3b2o$13bo4bobobo$15bob2o3bo$12bobo6bo$16bo3bo$12bo3bo2bo2$12bo3bo2bo$16bo3bo$12bobo6bo$15bob2o3bo$13bo4bobobo$14b3o3b2o$8bo6bob2o$2bobo3bobo7bo$bo8bo$bo2bo$4bo$2b2o16bo$3bo13bob2o$16b3o3b2o$15bo4bobobo$17bob2o3bo$14bobo6bo$18bo3bo$14bo3bo2bo2$14bo3bo2bo$18bo3bo$14bobo6bo$17bob2o3bo$15bo4bobobo$16b3o3b2o$17bob2o$20bo4$15b2obobo$15b2o3bo4bo$17bo7b2o$18bo5b2o$18b2o2$19bo$17bobo$15b3o$15b3o$14bo$14bo5b2o$13bo7b2o$11b2o3bo4bo$11b2obobo!"
        },

"Even&Odd c/2 Clean Rake": {   xsize: 81,
                       ysize: 35,
                       naturalXspeed:  0.5, 
                       naturalYspeed: 0,
                       rule:  "B013468/S02",
   patternstring:   "$73bo$37bo37bo$37bo12bo3bo10b2obo3b3obo$51b3o4bo6b2obo3b3obo$34bo7bo7b5ob2o17bo$33bo6b2o9bo2b2obo15bo$17bo16b2o3bobo9bo2b2obo$34bo2bob2o7b2o$bo33b2o2bo9bo7bo$17b3obo13b2o3bobobo8b2o17bo$18bobo2bo9bo2b2ob3obo11b2o17bo$16bo3bobo15b2ob2o10bob2o7b2obo3b3obo$18bo2bobo14b2o13bo2bo7b2obo3b3obo$21bo15bo15bo2bo17bo$53b4o15bo$55bo$51bo3bob2o$53bo3bo16bo$51b2obo10b2o9bo$51bo12b2ob2o3b4obo$50bo6bo6b2ob2o3b4obo$51bo4bo8b2o9bo$50bo2b2o19bo$56bo2$55bo$50bo2b2o20bo$50bo2b2o11b2o9bo$50bob3o10b2ob2o3b4obo$54b2o9b2ob2o3b4obo$66b2o9bo$75bo!"
        },

"Growing c/2 diag Rake":   {   xsize: 17,
                       ysize: 14,
                       naturalXspeed:  0.5, 
                       naturalYspeed: 0.5,
                       rule:  "B026/S1",
   patternstring:   "o8$12bo$11bo$14bo$13bo$16bo$15bo!"
        },


"JF Backrake c/5 p30":   {   xsize: 51,
                       ysize: 47,
                       naturalXspeed:  0.2, 
                       naturalYspeed: 0,
                       rule:  "JustFriends",
   patternstring:   "2$15bo$15bob14o10bo$33bo2b2o$8bo9b4o3b2obobob2obo4bobo$8bob8o4bo4b2obo2bo5b2o2b2o$16bo4bo19bo$19bo21b3o$9b9o2b10o11bo2bo$37bo4bo$36bobo2bo3bo$8bob2o30bo$8bo27bobo2bo3bo$13bo23bo4bo$12bob4o2b10o11bo2bo$12bo6bo21b3o$16bo4bo19bo$5bo3b2ob6o4bo4b2obo2bo5b2o2b2o$5bo5bo6b4o3b2obobob2obo4bobo$5bo27bo2b2o$6bo8bob14o10bo$15bo2$18bo$7b2o9bob14o10bo$6bo29bo2b2o$7bo5bo7b4o3b2obobob2obo4bobo$7bo3b2ob7o4bo4b2obo2bo5b2o2b2o$19bo4bo19bo$15bo6bo21b3o$15b6o2b10o11bo2bo$40bo4bo$11bo27bobo2bo3bo$11bob2o30bo$39bobo2bo3bo$40bo4bo$12b9o2b10o11bo2bo$22bo21b3o$19bo4bo19bo$11bob8o4bo4b2obo2bo5b2o2b2o$11bo9b4o3b2obobob2obo4bobo$36bo2b2o$18bob14o10bo$18bo!"
        },


"JF Backrake c/5 p60":   {   xsize: 55,
                       ysize: 46,
                       naturalXspeed:  0.2, 
                       naturalYspeed: 0,
                       rule:  "JustFriends",
   patternstring:   "2$17bo$19b15o2b3o2b4o$37bob2obobo$10bo10b3o3b2obobob2obo$12b6o6b2o10b2o2bo5b2o$19b3obo6bo16bo$19bob2o19b2ob3o$9bo2b7o4b10o6b3ob2o2bo$39b2ob2o$39bobo4bo$12b2o33b2o$10bo3bo24bobo4bo$14b2o23b2ob2o$14bob3o4b10o6b3ob2o2bo$14bo4bob2o19b2ob3o$11bo7b3obo6bo16bo$12bob4o6b2o10b2o2bo5b2o$5bo5bobo7b3o3b2obobob2obo$5bo31bob2obobo$5b2o12b15o2b3o2b4o$17bo$20bo$12bo9b15o2b3o2b4o$40bob2obobo$10bo2bo10b3o3b2obobob2obo$13b8o6b2o10b2o2bo5b2o$11bo10b3obo6bo16bo$15bo6bob2o19b2ob3o$17b5o4b10o6b3ob2o2bo$42b2ob2o$12bo29bobo4bo$12b4o34b2o$42bobo4bo$42b2ob2o$13b9o4b10o6b3ob2o2bo$22bob2o19b2ob3o$22b3obo6bo16bo$12b9o6b2o10b2o2bo5b2o$12bo11b3o3b2obobob2obo$40bob2obobo$22b15o2b3o2b4o$20bo!"
        },

"HexRake (NE)":  {   xsize: 60,
                       ysize: 69,
                       naturalXspeed:  0.2,   // these speeds may be buggy, given the orientation problem.
                       naturalYspeed:  0.2,
                       rule:  "Hex: B36/S1245H+B25/S346H",
   patternstring:   "11b2o$10b5o$10b2o2b2o$11bo3bo$11b2o2b2o2b2o$12b5ob5o$14b2o2b2o2b2o$19bo3bo$11b2o6b2o2b2o$10b5o5b5o$10b2o2b2o6b2o$11bo3bo$11b2o2b2o2b2o$12b5ob5o$14b2o2b2o2b2o$19bo3bo$19b2o2b2o$20b5o$22b2o10$9b3o$9bo2bo$9bo3bo31b2o$10bo2bo30b5o$11b3o30b2o2b2o$45bo3bo$21b3o21b2o2b2o2b2o$21bo2bo21b5ob5o$21bo3bo22b2o2b2o2b2o$o5bo15bo2bo27bo3bo$2bobob2o15b3o19b2o6b2o2b2o$2bo3b2o36b5o5b5o$2bobob3o35b2o2b2o6b2o$2bo42bo3bo$b2o42b2o2b2o2b2o$3b4o39b5ob5o$4b3o3bo37b2o2b2o2b2o$5bo2b2o43bo3bo$5b3o45b2o2b2o$6b3o2bo42b5o$12bo14b2o27b2o$10b4o2bo9b3o$10b4o3b2o8b2o$12bo3b2o6bo3bobo$18bo$21b3obo4bobo$21b2o3bobo3bobo$22b2o4b2o2bo$22b3ob2ob2obo$24bo2b6o$28b2o3bo9b3o$43bo2bo$43bo3bo$44bo2bo$45b3o2$55b3o$55bo2bo$55bo3bo$56bo2bo$57b3o!"
        },

"HexRake (E)":  {   xsize: 74,
                       ysize: 65,
                       naturalXspeed:  0.2,   // these speeds may be buggy, given the orientation problem.
                       naturalYspeed:  0.2,
                       rule:  "Hex: B36/S1245H+B25/S346H",
   patternstring:   "2$9bo$5bo$6b5o$6bo$6b2o2bobo$5b4o$5b2ob2o2b4o$6b2o5b3o$7bobo4bo$10bo14b3o$6b2o4bo12bo2bo17b2o6b2o$7b2obo14bo3bo15b5o3b5o$7b4o15bo2bo15b2o2b2o2b2o2b2o$9b2o16b3o16bo3bo3bo3bo$46b2o2b2o2b2o2b2o$47b5o3b5o$11bobo35b2o6b2o$12b2o$12bobo35b2o6b2o$49b5o3b5o$49b2o2b2o2b2o2b2o$13b2o16b3o16bo3bo3bo3bo$12b4o15bo2bo15b2o2b2o2b2o2b2o$13b2obo14bo3bo15b5o3b5o$13b2o4bo12bo2bo17b2o6b2o$18bo14b3o$16bobo4bo$16b2o5b3o$16b2ob2o2b4o$17b4o$19b2o2bobo$20bo$21b5o$21bo$26bo9$29b3o$29bo2bo17b2o6b2o$29bo3bo15b5o3b5o$30bo2bo15b2o2b2o2b2o2b2o$31b3o16bo3bo3bo3bo$50b2o2b2o2b2o2b2o$51b5o3b5o$53b2o6b2o2$54b2o6b2o$53b5o3b5o$53b2o2b2o2b2o2b2o$35b3o16bo3bo3bo3bo$35bo2bo15b2o2b2o2b2o2b2o$35bo3bo15b5o3b5o$36bo2bo17b2o6b2o$37b3o!"
        },

"Forward Hexrake":  {   xsize: 108,
                       ysize: 58,
                       naturalXspeed:  0.2,   // these speeds may be buggy, given the orientation problem.
                       naturalYspeed:  0,
                       rule:  "Hex: B36/S1245H+B25/S346H",
   patternstring:   "46b2o$46b2o$44bo3bo$43b2o$31b3o7bobo21bo$29b6o6b2ob3o16b4o$29b2ob2o5b3ob3o17b3o$28b2o2bo4bo2bo2b2o17b4o$28bo6bob2o17bo6bo$28b3obo2bob3o4bo11bo2bo5bo$28b2o2b3ob3o2b2obo9b7o2b2obo$28bo9b3o14bobo5bobobo$26bo2bo3b4o3bo15bobobo2b5o$27bo7bo20bobobo3bo$7bo17bo3bo2bo22b4o7bo4b2o$5b2o18bo2bo3bo23b3o10b5o$3bob2obo17bo3b4o21b2o11b2o2b2o$bob3o25bo36bo3bo9bo23bo$3b2o25b2o35b2o2b2o7b4o20b4o$obo5b2o17b2o38b5o8b3o21b3o$4bobobo18bobo38b2o9b4o20b4o$5b2o2bo15b2obo51bo23bo$b5obo18bobob2obo$2bob2o19b2o3bo$bo23b3o2bo$23bo4bo7bo41bo23bo$34b2o29b2o9b4o20b4o$23b4o7b3o26b5o8b3o21b3o$24b2o7bobo26b2o2b2o7b4o20b4o$21bo2bo37bo3bo9bo23bo$22bo21bo16b2o2b2o$42b2o4bo12b5o$42bo2bo16b2o$16bo2bo22b4obo$17bo22b2o2bobo$41bo2b3o28b2o$41bob4o26b5o$31b3o5b4o13bo15b2o2b2o$30bo2bo5bo14b4o14bo3bo21bo$29bo3bo4b4o12b3o14b2o2b2o19b4o$29bo2bo6bo13b4o14b5o20b3o$29b3o19bo2bo17b2o21b4o$96bo$49bobo3$94bo$69b2o21b4o$54b2o11b5o20b3o$52b3o11b2o2b2o19b4o$51b2o13bo3bo21bo$50b2obo11b2o2b2o$49bo2bo12b5o$50bob3o11b2o$48bo$49b2o$49bo$48b2o!"
        },

"Forward Hexrake2":  {   xsize: 55,
                       ysize: 64,
                       naturalXspeed:  0.2,   // these speeds may be buggy, given the orientation problem.
                       naturalYspeed:  0,
                       rule:  "Hex: B36/S1245H+B25/S346H",
   patternstring:   "10bo2bo$11b4o$11b4ob2o$10b3o2b4o$12b2o3b2ob2o$13b3o3b3o$13b2ob2o3b2o$16b4o2b3o10b2o$17b2ob4o11b2o$20b4o8bo3bo$21bo2bo7bo4bo4bo$42b2o$41b3o2$35b3o$35b2o$36bo4bo4bo$42bo3bo$42b2o$42b2o5$9b3o$9b4o$9b2ob2o$10b4o$11b3o2$21b3o$21b4o$21b2ob2o5b3o$22b4o5b4o$23b3o5b2ob2o$32b4o$33b3o$3b5o$3bob3o35b3o$43b4o$4b2o37b2ob2o$6b2o36b4o$6b2o37b3o$9b2o3bo$10b2o3bo$9b4ob4ob2o$10bo2b2o3bo2bo6b2o$17b3o8bob3o$15bobo2b2o5b2o2b2o$16bo2bo2bo5bo2b2obo$20bo9b2o2b2o$33b2o$34b2o$35bobob2o$2o34bob2obo$o36b4obo7b2o$b2o37bo8bob2o$3bo42b4ob2o$46b3ob5o$48bo2b4o$30b2o15b4o3bo$30bo17bobo$31b2o$33bo!"
        },

"Fleas Rake":  {   xsize: 5,
                       ysize: 7,
                       naturalXspeed:  0,   // this speed is obviously wrong
                       naturalYspeed:  0,
                       rule:  "Fleas",
   patternstring:   "5b2o$2o4bo$b6o2$b6o$2o4bo$5b2o!"
        },

"Bricks Rake #1": {xsize: 4,
                       ysize: 3,
                       naturalXspeed:  1,   
                       naturalYspeed:  0,
                       rule:  "Bricks",
   patternstring:   "2o$3bo$3bo!"
        },
  
"5c/12 BulletRule SideRake": {xsize: 104,
                       ysize: 52,
                       naturalXspeed:  0.41666666,   
                       naturalYspeed:  0,
                       rule:  "2356/357/4",
   patternstring:   "3.C.C$4.B$.3A2.2BA$ABCA.4A$.3A2.2BA$4.B$3.C.C13$71.2A$71.2A17.A$88.ABABA$80.AC6.ABABA$71.2A6.A.BA4.2A4.A$71.2A6.ABC2A4.ABABA$79.2A.B5.ABABA$90.A$71.A$70.AB2A6.C.C$69.2AC2A4.2A2.C3.2ACA$70.B2.CBA2.A3B4.AB3A$72.3BA2.2A2.C3.2ACA$72.ACBA4.C.C$72.CB4$82.CB$82.ACBA4.C.C$82.3BA2.2A2.C3.2ACA$80.B2.CBA2.A3B4.AB3A$79.2AC2A4.2A2.C3.2ACA$80.AB2A6.C.C$81.A$100.A$89.2A.B5.ABABA$81.2A6.ABC2A4.ABABA$81.2A6.A.BA4.2A4.A$90.AC6.ABABA$98.ABABA$81.2A17.A$81.2A!"
        },

"B-Brian SideRake": {xsize: 15,
                       ysize: 9,
                       naturalXspeed:  1,   
                       naturalYspeed:  0,
                       rule:  "Brian's Brain",
   patternstring:   "6.BA$5.2A.BA$6.B2.BA$.AB.2A.B2.BA$.B.2B2.2B2.BA$B6.B2.BA.BA$2.2B3.A.BA2.BA$2.2A4.BA$7.BA!"
        },

"2x2 Backrake":  {     xsize: 141,
                       ysize: 140,
                       naturalXspeed: 0.5, 
                       naturalYspeed: 0,
                       rule:  "B36/S125",
                       patternstring:   "$38b2o9b2o$39b2o7bobobobo$37bo6b2ob2obo3bo$39b7obo4bobo$37bo2b2o3b2o2bo2b4o$42b2o5bo2b2o3bo$40bo2bo3bobo3b2obobo$42bo6bob3o$40bobo6bo3b2obob2o53bobo9b2o$46b2o3bo2bo3b3o54bo6bobo3b2o$45b2o4b3o5b2o52bo3bo7bo3b2o$46bo2bo2b2obob4o52b2o4b3o2bob3o$45bobobobob4o57bob2o5b2obo3bo$46b2o2b2o4b2obo55bo2b2obo2b2o3bob2o$116bo7bob3o2b3o$59b2o56b2o5bobobo4b2o$116b2o5b2obo3bobo2bo$46b2o2b2o4b2obo60bobo2b2o3bobo$45bobobobob4o68bobo4b2ob2o$46bo2bo2b2obob4o61b3o3b2o2bo$45b2o4b3o5b2o59bo3bo6bo3bo$46b2o3bo2bo3b3o61b2o2b2obo2bo$40bobo6bo3b2obob2o73b3o$42bo6bob3o80b2o$40bo2bo3bobo3b2obobo74b3o$42b2o5bo2b2o3bo64b2o2b2obo2bo$37bo2b2o3b2o2bo2b4o64bo3bo6bo3bo$10b3o13b2o11b7obo4bobo67b3o3b2o2bo$8b2o7b2o6bobob2o6bo6b2ob2obo3bo42bo27bobo4b2ob2o$10bobo3bob2o5b2ob2o9b2o7bobobobo40b4o21bobo2b2o3bobo$8bo7b2o4b2ob2ob4o6b2o9b2o43bo3bo6bo2bobo12b2obo3bobo2bo$21b2o2bo5b2o2b2o57bobo6bobo4bo13bobobo4b2o$8bo7b2o4bo8bob3o66bobo2bo2bo13bob3o2b3o$10bobo3bob2o3b2o9bo74bob2o8bo2b2o3bob2o$8b2o7b2o3b2o78bobo2bo2bo3bob2o5b2obo3bo$10b3o81bobo6bobo4bo3b4ob3o2bob3o$94bo3bo6bo6bo2bo9bo3b2o$4b2o38bo50b4o11bo3bo7bobo3b2o$3bo38bobo22b3o27bo14bobo10b2o$2b2obob3o27bobo2bo21b3o4bo$2b2o3bob2o26bobo3bo23b3ob2o16b3o$3bob5o33b3o27b2o19bo21b2o10b2o$4b2o6bo28b4obob4o22bo12bo5bob2o17bo2b2o8bobobobo$5b2o6bo28b3o2b5o14bo2b5o3bo9bo3b3ob3o4bobo9bobo6b2ob2obo3bo$5bobo32bob3o22bo4b2o2b3o13bo3b2o15b2obob2ob4obo4bobo$5bobo30bo2bo2b3ob2obo19bo4b3o14bobo2bo2bo3bo6bo3b2o3bo2b2o2bo2b4o$39b2o4b2ob5o21bob3o12b2o4b2o4bob4o2b2o2bo12bo2b2o3bo$46bo3bobo17b5o2bo12bo3b3o8bo3bo2bo13bobo3b2obobo$52bo37b2o12b4o5b2o13bob3o$47bo3bo50bo9b2o14bo3b2obob2o$45b4obo25bo26bo21b2o3bo2bo3b3o$45b2o28bo48b2o4b3o5b2o$47bo2b3o72bo2bo2b2obob4o$46bo2bo74bobobobob4o$12b2o38bo72b2o2b2o4b2obo$15b2o33bo$12bo27bo97b2o$13bobo22b4o$37bo3bo6bo2bobo71b2o2b2o4b2obo$37bobo6bobo4bo8bobo59bobobobob4o$17bo27bobo2bo2bo6bo4bo59bo2bo2b2obob4o$18bo34b3o2bo3bo2bo58b2o4b3o5b2o$15bo29bobo2bobo8bo5bobo9b2o44b2o3bo2bo3b3o$16bo20bobo6bobo6bobob2o8bo6bobo3b2o35bobo6bo3b2obob2o$37bo3bo6bo6bo3bo7bo3bo7bo3b2o36bo6bob3o$38b4o14b2o9b2o4b3o2bob3o36bo2bo3bobo3b2obobo$4b2o9b2o3b2o18bo27bob2o5b2obo3bo36b2o5bo2b2o3bo$4b2o6b3ob2o3b2o46bo2b2obo2b2o3bob2o29bo2b2o3b2o2bo2b4o$12bob2o4bo49bo7bob3o2b3o30b7obo4bobo$12b3o4b2obo14b3o2b2o3b2o22b2o5bobobo4b2o27bo6b2ob2obo3bo$12bob2o4bob2o11b2obo4b2o3b2o20b2o5b2obo3bobo2bo28b2o7bobobobo$4b2o6b3ob2o3b2obo10b3ob4o4bo26bobo2b2o3bobo30b2o9b2o$4b2o9b2o5bob2o13bobo4b2obo29bobo4b2ob2o$22b2o11b3ob4o4bob2o25b3o3b2o2bo$21b2o2bo9b2obo4b2o3b2obo22bo3bo6bo3bo$21bo3b2o10b3o2b2o5bob2o23b2o2b2obo2bo$20b3ob2o2bo20b2o36b3o$19bobo5bobo18b2o2bo35b2o$19bob2obo23bo3b2o33b3o$20b3o2bobob2o16b3ob2o2bo20b2o2b2obo2bo$23bobo3b3o14bobo5bobo17bo3bo6bo3bo$23b3o4b2o14bob2obo24b3o3b2o2bo$24b3ob4o15b3o2bobob2o21bobo4b2ob2o$23b2o2bo22bobo3b3o15bobo2b2o3bobo$21b3o3b2obo19b3o4b2o11b2o5b2obo3bobo2bo$21b2obobo24b3ob4o12b2o5bobobo4b2o$23bobo4b2o18b2o2bo15bo7bob3o2b3o$23bo3b2o19b3o3b2obo11bo2b2obo2b2o3bob2o$22b7o2bo16b2obobo14bob2o5b2obo3bo$22b4obo22bobo4b2o8b2o4b3o2bob3o$31b2o17bo3b2o11bo3bo7bo3b2o$24b2o3bo19b7o2bo10bo6bobo3b2o$24b2o5bo17b4obo12bobo9b2o$23b3o2bo29b2o$30b2o19b2o3bo$23b2o3bo22b2o5bo$22b3o6bo18b3o2bo$22b3o4bo27b2o$25b2o4b2o17b2o3bo$24bo2bo21b3o6bo$21bob2o3bo2bo17b3o4bo$21b2obo2bo24b2o4b2o$22bob2ob2ob2o19bo2bo$20bo4b3o20bob2o3bo2bo$22bo2bo4bo17b2obo2bo$21b3o25bob2ob2ob2o$23b2obob3o16bo4b3o$23b2o2bob2o18bo2bo4bo$24bo3b3o17b3o$23b2o2bo22b2obob3o$24bo5b2o18b2o2bob2o$25b2o3b2o19bo3b3o$24b2o3b3o18b2o2bo$51bo5b2o$29b2o21b2o3b2o$28b3o20b2o3b3o$29b2o$56b2o$29b3o23b3o$30b2o24b2o$29b3o$18b2o2b2obo2bo27b3o$16bo3bo6bo3bo25b2o$18b3o3b2o2bo27b3o$21bobo4b2ob2o12b2o2b2obo2bo$16bobo2b2o3bobo14bo3bo6bo3bo$12b2o5b2obo3bobo2bo13b3o3b2o2bo$13b2o5bobobo4b2o17bobo4b2ob2o$12bo7bob3o2b3o13bobo2b2o3bobo$11bo2b2obo2b2o3bob2o10b2o5b2obo3bobo2bo$10bob2o5b2obo3bo13b2o5bobobo4b2o$9b2o4b3o2bob3o14bo7bob3o2b3o$9bo3bo7bo3b2o11bo2b2obo2b2o3bob2o$11bo6bobo3b2o11bob2o5b2obo3bo$9bobo9b2o13b2o4b3o2bob3o$36bo3bo7bo3b2o$38bo6bobo3b2o$36bobo9b2o!"
        },



  "----Replicators----": {patternstring: "3o"},


"HighLife Replicator": {   xsize: 5,
                       ysize: 5,
                       naturalXspeed:  0.16666666667, 
                       naturalYspeed: 0.16666666667,
                       rule:  "B36/S23",
                       patternstring:   "2b3o$bo2bo$o3bo$o2bo$3o!"
        },

 "Low Morley Replicator": {xsize: 3,
                       ysize: 19,
                       naturalXspeed:  0,  // hard to say what the natural speed of this replicator is!
                       naturalYspeed: 0,
                       rule:  "B36/S245",
                       patternstring:   "b2o$obo$obo$obo$obo$b2o8$b2o$obo$obo$obo$obo$b2o!"
        },



"B368/S12578 Replicator": {   xsize: 5,
                       ysize: 1,
                       naturalXspeed:  0.307692307692308,     //  4c/13
                       naturalYspeed: 0,
                       rule:  "B368/S12578",
                       patternstring:   "o$o$o$o$o!"
        },


    "----Guns----": {patternstring: "3o"},



  "pure gosperglidergun" : {
   rule:  "B3/S23",
   xsize: 40, // 38,
   ysize: 13, //11,
   naturalXspeed: 0,
   naturalYspeed: 0,
       patternstring:  "$27bo$27bobo$10bo17bobo4b2o$10b2o16bo2bo3b2o$b2o2b2o4b2o15bobo$b2o2b2o4b3o13bobo$5b2o4b2o7bobo4bo$10b2o9b2o$10bo10bo!"
    },

  "gosperglidergun" : {
   rule:  "B3/S23",
   xsize: 44, 
   ysize: 15,  
   naturalXspeed: 0,
   naturalYspeed: 0,
   counterpart:   "Queen Bee shuttles",
       patternstring:  "$31bobo$30bo2bo$20bo8b2o10b2o$bo17bobo5b2o3bo8b2o$b3o3b2o10b2obo6b2o5b2o$4bo2b2o10b2ob2o6bo2bo$b3o15b2obo8bobo$bo17bobo$20bo9bo$31bo$29b3o!"

    },

   
   "P22 Epstein glidergun": {
     rule:  "B3/S23",
    xsize: 45, 
    ysize: 21,
    naturalXspeed: 0,
   naturalYspeed: 0,
    patternstring: "18b2o$19bo7bo$19bobo14b2o$20b2o12b2o2bo$24b3o7b2ob2o$24b2ob2o7b3o$24bo2b2o12b2o$25b2o14bobo$35bo7bo$43b2o2$2o23bo$bo21bobo$bobo13b3o4b2o$2b2o3bo8bo3bo$6bob2o6bo4bo$5bo4bo6b2obo9bo$6bo3bo8bo3b2o6bo$7b3o13bobo3b3o$25bo$25b2o!"
        },



  "lwssgun" : {
    rule:  "B3/S23",
     xsize: 64,
  ysize:  33,
  naturalXspeed: 0,
  naturalYspeed: 0,
   patternstring: "34b2o$36bo$23b2o12bo$23b2o4bo7bo8b2o9b2o$20b2o5b2o8bo8b2o5b2o2b2o2b2o$12b2o5b3o5bo2b2o4bo16bobo2bo2b2o$12b2o6b2o6b5ob2o18b3o$23b2o4bo25b2o$23b2o$34bobo$37bo11b4o$33bo3bo10bo3bo$34b4o14bo$48bo2bo3$25bo20b2o2b3o2b2o$25b2o19bo2b5o2bo$24bobo20b9o$44b3o9b3o$39bo4bo2bo7bo2bo$11b2o25b2o5b2o9b2o$10b3o3b2obo18bobo$2o5bob2o5bo3bo2bo$2o5bo2bo4bo4bo2b2o26b2o$7bob2o4b4o5b2o25bobo$10b3o3bo7b3o14bo4b2o6bo7b2o$11b2o11b2o14bobo2bo2bo2bo2bo7b2o$23b2o15b2obob3o6bo$23bo16b2ob2o6bobo$40b2obo7b2o$40bobo$41bo!"

  },
  "thicker lwssgun": {
    rule:  "B3/S23",
     xsize: 64,
  ysize:  33,
  naturalXspeed: 0,
  naturalYspeed: 0,
  patternstring: 
"35bobo$33bo3bo$25bo7bo$24b4o4bo4bo8b2o$23b2obobo4bo12b2o$12b2o8b3obo2b\
o3bo3bo$12b2o9b2obobo6bobo$24b4o$25bo$36bo8bo2bo$31bo2bobo12bo$31b2o2b\
2o8bo3bo$30bobo13b4o2$32b2o$32b2o$32bobo11b2o7b2o$46bo9bo$23b2o22b9o$\
24b2o18b3o2b5o2b3o$23bo20bo2bo2b3o2bo2bo$12b2o31b2o9b2o$11bo3bo24b2o$\
2o8bo5bo7bo14b2o$2o8bo3bob2o4bobo16bo9bo$10bo5bo3b2o27bobo$11bo3bo4b2o\
15b2o9bobo11b2o$12b2o6b2o15b3o7bo2bo11b2o$22bobo14b2obo5bobo$24bo14bo\
2bo6bobo$39b2obo8bo$37b3o$37b2o!"

  },
"even thicker lwssgun": {
    rule:  "B3/S23",
    xsize: 64,
  ysize:  33,
  naturalXspeed: 0,
  naturalYspeed: 0,
   patternstring: 
"35bobo$35bo2bo$20bo6bo10b2o$19bobo5bo8bo3b2o4b2o$18bob2o6bo9b2o6b2o$\
12b2o3b2ob2o9b2o2bo2bo$12b2o4bob2o5b3o2bo2bobo$19bobo7b4o$20bo9b2o$38b\
2o$37b4o13b2o$37b2ob2o10b2ob2o$39b2o11b4o$53b2o2$26b3o$28bo$27bo2$36b\
3o$36bo$8bo8bo2bo16bo$7bobo10bo$2o3b2o3bo5b2o3bo2bo$2o3b2o3bo4bobob2o\
3b4o24bobo$5b2o3bo14b4o15b3o5bo3bo$7bobo5b2o8bo2bo10b2o2bo2bobo7bo5b2o\
$8bo16b4o8bo2bo2b2o7bo4bo4b2o$24b4o8bo19bo$24bo11bo10b3o2bo3bo$36bo15b\
obo$37bo2bo$39b2o!"

  },

"hwssgun": {rule:  "B3/S23",patternstring:  "52bo$51bobo$50bo3bo$49bo3bo$34b2ob6o5bo3bo$34b2ob6o4bo3bo$34b2o12bobo$34b2o5b2o6bo$34b2o5b2o$34b2o5b2o$41b2o$34b6ob2o$34b6ob2o4$44bo$44b2o$43bobo$34b2o18b2o$34bo14bo5bo$22bo9bobo13b2o5bobo5bo$21bobo8b2o14bobo5b2o3bobo$11b2o7bob2o36bobo17bo$10bobo6b2ob2o35bo2bo16b2o$9bo6b3obob2o36bobo15b2o4b2o$2o7bo2bo2bo2bo2bobo37bobo13b3o4b2o2b2o$2o7bo6b2o4bo40bo4bobo7b2o4b2o2b2o$10bobo55b2o9b2o$11b2o56bo10bo2$23bobo3bo6b2o14b2o$24b2o3b2o3bo2bo14bo2bo$24bo3bobo$34bo2bo14bo2bo$35bo2bo12bo2bo9bo$36bobo12bobo9b2o$13bo7bo15bo14bo10bobo8bobo$11bobo5b4o49bo3bo$3b2o4b2o8b2o2bo2b2o8b2o14b2o6b2o10bo12b2o$3b2o4b2o11b2o2b2o8b2o14b2o6bo2bo7bo4bo8b2o$9b2o7bo10b2o33bo7bo$11bobo4bo10b3o32bo7bo3bo$13bo4bo10b2o33bo9bobo$26b2o7b2o16b2o5bo2bo$26b2o7bobo14bobo5b2o$37bo14bo$37b2o12b2o"},

 "gliderlessgun": {rule:  "B3/S23",patternstring:  ".......*..........................................$..**...*.*....*...................................$..*..**..*.*.**.*..***..**........................$....**.......**.*.*.**..**........................$...***.......*.......***.........*................$.......................*.......***................$.......................*......*........***........$..............................**.......*..*.......$.........**..............*.............*..........$.........**.............*..............*...*......$.........................**............*..........$........................*.*.............*.*.......$..................................................$.......................*.*.....***................$........................*.....*..*..............**$**............***.......*......**...........**.*.*$**...........*...*..........................**.*..$.............**.**..............................*.$.................................**.........**.**.$..............................**.............*.*..$.............................................*.*..$..............................................*...$.............**.**.............*.*................$**...........*...*.............**.................$**............***.................................$...........................**.....................$...........................*.*....................$.............................*....................$.............................**...................$..................................................$.........**.......................................$.........**.......................................$..................................................$.......................*..........................$.......................*..........................$...***.......*.......***..........................$....**.......**.*.*.**..**........................$..*..**..*.*.**.*..***..**........................$..**...*.*....*...................................$.......*..........................................$"},
    
    

    "LWSSfactoryperiod46": {rule:  "B3/S23",patternstring:  "$.........**..*.*...................................$..**....***.*...*..................................$..**...**......*...................................$........*.*****......................**...*........$.........***.........................***.*.**....**$.....................................***....*....**$.........***............................*...*......$........*.*****..........................***.......$..**...**......*...................................$..**....***.*...*........................***.......$.........**..*.*........................*...*......$.....................*...............***....*....**$...................**................***.*.**....**$....................**...............**...*........$...................................................$...................................................$..**...................*..*........................$..**.......................*...................****$.......................*...*..................*...*$........................****......................*$..............................................*..*.$..***...***........................................$.*..*...*..*.......................................$.....*.*...........................................$.**.......**.......................................$.**.......**.......................................$....*...*..........................................$....**.**..........................................$..***...***........................................$..**.....**........................................$..*.......*........................................$...................................................$...................................................$...................................................$...................................................$...................................................$...................................................$...................................................$...................................................$...................................................$...................................................$...................................................$...................................................$..**.....**........................................$..**.....**........................................$$"},



"Highlife p22 Glider Gun": {
	 xsize: 37,
 	 ysize:  24,
 	 naturalXspeed: 0,
 	 naturalYspeed: 0,
	 rule: "B36/S23",
 	 patternstring: 
"21bo$19b3o$18bo$18b2o8$15b3o$15bobo$15b3o$16bo$35b2o$2o33bo$bo31bobo$bobo20bo8b2o$2b2o20bo$12b2o9bob2o$11b2obo9bo$12b2o10bo!"
   },

"Highlife p24 LWSS Gun": {
  xsize: 63,
  ysize:  63,
  naturalXspeed: 0,
  naturalYspeed: 0,
  rule: "B36/S23",
  patternstring: "38bo$36b3o$35bo$35b2o2$33bo$32bobo$31bo3bo$32bobo$33bo$32bobo2$32b3o3$52b2o$17b2o33bo$18bo31bobo$18bobo23b2o4b2o$19b2o22b4o$23b3ob2o13b2o3bo$15bo7bobob3o5bo7b4o$15b3o5b3ob2o7bo7b2o$18bo15b3o$17b2o$38bo2bo$42bo$38bo3bo$39b4o2$30b2o$31b2o$20bo9bo$19b3o$19bobo17b2o$20bo17b2o$2o22b2o14bo$bo23b2o$bobo20bo$2b2o8b2o$11b4o20bo9bo7b2o$10b2o3bo19bo3bo4b3o5b2obo$11b4o19bob2o3bo3b2o2bo3b2o$12b2o6b3o12bo3bo3bo15b2o$20bobo5b2o5bo23bobo$19bo3bo3bobo31bo$20bobo4bo33b2o$21bo4b2o5$45b3o$45bobo$18b2o25b3o$19bo26bo$16b3o$16bo2$43b2o$44bo$41b3o$41bo!"
     },

"Highlife p48 MWSS Gun": {
  xsize: 65,
  ysize:  57,
  naturalXspeed: 0,
  naturalYspeed: 0,
  rule: "B36/S23",
  patternstring: "43bo$43b3o$46bo$45b2o5$47b3o$47bobo$21bo26bo$19b3o$18bo29bo$18b2o$48bo$15b3o10b2o$14bo3bo10bo17bobo$14bo3bo10bobo16b2o$30b2o10b2o5b2o$15b3o19b4o3bo3b3o4bo$15bobo19bo2bo3bo2bo3bo3bo$15bobo19b4o3bo2bobo3b2obo$15b3o24b2o3bo3bo3bo$55bo5b2o$61bobo$35b2o26bo$2o33bo5bobo19b2o$bo31bobo5b2o$bobo29b2o7bo$2b2o3bo17b2ob3o$6b4obo12b3obobo$5b2obobob2o11b2ob3o$6b4obo7bo15bobo$7bo9bobo15b2o$18b2o16bo2$8bo$8b3o37bo$11bo13bo3bobo14bo3bo$10b2o11bobo3b2o20bo$17bo2b2o2b2o4bo15bo4bo$17bo4bo24b5o$17bo4bo$14b5o$17bobo$18b5o$14bo4bo11b2o$14bo4bo11bo$15b2o2bo12b3o$34bo4$29b2o$29bo$30b3o$32bo!"
     },


"HighLife Bomber Gun": {
  xsize: 54,
  ysize:  95,
  naturalXspeed: 0,
  naturalYspeed: 0,
  rule: "B36/S23",
  patternstring: "o$3o$3bo$2b2o20$20b3o$19bo$19bo$19bo26$36b3o$36bo2bo$36bo3bo12bo$37bo2bo12bo$38b3o12bo$50b3o34$4b2o$5bo$2b3o$2bo!"
     },

"Morley Half-bow p404gun": {
  xsize: 68,
  ysize:  37,
  naturalXspeed: 0,
  naturalYspeed: 0,
  rule: "B368/S245",
  patternstring: "3bo2bobo2bo$3b4ob4o$3bobobobobo$4bo5bo$2b2o7b2o$2b2o7b2o35bo$3bo2b3o2bo11b4o20b2o4b2o3bobo$3b9o11b4o19bo2b3ob5o2bo$5b5o36bo2b3ob5o2bo3b4o$47b2o4b2o3bobo3b4o$48bo4$b2o24bobo$b2o24b4o$b2o26b2o11b2o$b2o26b2o11b2o$27b4o11b2o$27bobo12b2o6$44b4o3bo$10b2o32b3o3b2o$10bo31b3obob3o$2o9b2obo11bobo13b3obo3b2o$2o11bob2o9b4o11b4o4bo$2o10bo4bo10b2o12b3obo3b2o$2o14bo11b2o12b3obob3o$10b7o9b4o14b3o3b2o$12b3o11bobo15b4o3bo!"
     },


"Low Morley p24 Gun1": {
  xsize: 76,
  ysize:  54,
  naturalXspeed: 0,
  naturalYspeed: 0,
  rule: "B36/S245",
  patternstring: "4bo$3b3o$b3obo$2o3b2o$b2o3b2o$2bob3o$2b3o$3bo$24bo$23b4o$22bobo2bo$22bobo2bo$23b4o24b2o$24bo25bobo$50bobo$50bobo$50bobo$51b2o$71bobo$71b2o$68bobob2o$69b4ob2o$68b2ob4o$70b2obobo$71b2o$70bobo2$52b2o$35b4o12bo$34bo4bo10bobo$34b6o10bo2bo16$42bobo$43b2o$42b2obobo$40b2ob4o$41b4ob2o$40bobob2o$43b2o$43bobo!"
     },

"Low Morley p24 Gun2": {
  xsize: 74,
  ysize:  45,
  naturalXspeed: 0,
  naturalYspeed: 0,
  rule: "B36/S245",
  patternstring: "23bo$22b4o$21bobo2bo$21bobo2bo$22b4o24b2o$23bo25bobo$49bobo$49bobo$49bobo$50b2o11$34b4o$2b2o29bo4bo$bo2bo28b6o$6o$bo2bo$bo2bo$2b2o64b6o$68bo4bo$69b4o9$16bo$14b4o$13bo2bobo36b2o$13bo2bobo36bobo$14b4o37bobo$16bo38bobo$55bobo$55b2o!"
     },



"Day&Night p128 Rocket Gun": {
  xsize: 73,
  ysize:  85,
  naturalXspeed: 0,
  naturalYspeed: 0,
  rule: "B3678/S34678",
  patternstring: 
"4b2o$2b4o24b2o$2b3o25b2o$b5o23b4o$ob3obo21bob3o$ob3obo21bob4o$b5o23b5o$b5o23b6o$b5o23b6o$b5o23b7o$b5o23b7o$b5o23b8o$ob3obo21bob7o$ob3obo21bob8o$ob3obo21bob8o$b5o23b8o$b5o23b8o$b5o23b7o$b5o23b7o$b5o23b9o$b5o23b9o$ob3obo21bob9o$ob3obo21bob9o$ob3obo21bob8o$ob3obo21bob8o$b5o23b11o$b5o23b13o$ob3obo21bob12o$ob3obo21bob14o$b5o23b15o$2b3o25b16o19b6o$2b4o23b6o7b4o17b10o$4b2o23b2o2b11o19b3o4b3o$65b2o2b2o$35b7o4$47b2ob2o$17bo29b6o$16b3o27b6obo$15b5o27b8o$14b7o25bob8o$15b5o27b8o$16b3o27b6obo$17bo29b6o$47b2ob2o4$35b7o$65b2o2b2o$4b2o23b2o2b11o19b3o4b3o$2b4o23b6o7b4o17b10o$2b3o25b16o19b6o$b5o23b15o$ob3obo21bob14o$ob3obo21bob12o$b5o23b13o$b5o23b11o$ob3obo21bob8o$ob3obo21bob8o$ob3obo21bob9o$ob3obo21bob9o$b5o23b9o$b5o23b9o$b5o23b7o$b5o23b7o$b5o23b8o$b5o23b8o$ob3obo21bob8o$ob3obo21bob8o$ob3obo21bob7o$b5o23b8o$b5o23b7o$b5o23b7o$b5o23b6o$b5o23b6o$b5o23b5o$ob3obo21bob4o$ob3obo21bob3o$b5o23b4o$2b3o25b2o$2b4o24b2o$4b2o!"
   },

   "Day&Night p200 Rocket Gun": {
  xsize: 17,
  ysize:  33,
  naturalXspeed: 0,
  naturalYspeed: 0,
  rule: "B3678/S34678",
  patternstring: "5b3o2b3o$3b12o$b16o$b16o$3bo10bo$4b10o8$2ob3o$7o$b7o$9o$b7o$7o$2ob3o8$4b10o$3bo10bo$b16o$b16o$3b12o$5b3o2b3o!"
    },



"Day&Night Snail Gun": {
  xsize: 89,
  ysize:  35,
  naturalXspeed: 0,
  naturalYspeed: 0,
  rule: "B3678/S34678",
  patternstring: 
"72b2o5b2o$5b3o2b3o$3b12o27b3ob3o23b2o5b2o$b16o23b11o15b2ob3o2b5o2b3o$b16o21b15o13b20o$3bo10bo23b4o2b3o2b4o14b5o2b5o2b5o$4b10o26b5ob5o8b3o5b20o$45bo12bo3bo6b3o2b5o2b3ob2o$42b2o3b2o7b4ob4o7b2o5b2o$56b4ob4o$58bo3bo9b2o5b2o4$2ob3o$7o79bo$b7o77b4o$9o72b8o$b7o77b4o$7o79bo$2ob3o4$58bo3bo9b2o5b2o$56b4ob4o$42b2o3b2o7b4ob4o7b2o5b2o$45bo12bo3bo6b3o2b5o2b3ob2o$4b10o26b5ob5o8b3o5b20o$3bo10bo23b4o2b3o2b4o14b5o2b5o2b5o$b16o21b15o13b20o$b16o23b11o15b2ob3o2b5o2b3o$3b12o27b3ob3o23b2o5b2o$5b3o2b3o$72b2o5b2o!"
     },


"Even&Odd Glider Gun": {
  xsize: 16,
  ysize:  6,
  naturalXspeed: 0,
  naturalYspeed: 0,
  rule: "B013468/S02",
  patternstring: "10b2o$9b3obo$10b3ob2o$3o7b3ob2o$9b3obo$3o7b2o!"
     },


"B368/S12578 52pGun": {
  xsize: 65,
  ysize:  47,
  naturalXspeed: 0,
  naturalYspeed: 0,
  rule: "B368/S12578",
  patternstring: "$28bobobobobo$28bobobobobo7$32bo$31bobo2$31b3o2$31bobo$32bo10$32bo$31bobo2$31b3o$31bo2$33bo$2b2o26bo$26b3ob4o$2b2o4bobo5bobo6bob5obo27b2o$25b2o4b2o$2b2o3b5o3b5o5b2o3bo30b2o$29bo3bobob3o5b5o3b5o$2b2o4bobo5bobo10bo3bob2o2b2o3b2obob2ob2obob2o2b2o$29bo4b2o9b5o3b5o$2b2o26bo3b2o2bo22b2o$30bo5bo$33bo2bo24b2o$36bo!"
     },

     "----Stillships c/0----": {patternstring: "3o"},
  "1234+Hat": {
               rule:  "B3/S23",
               xsize: 14,
               ysize: 13,
               naturalXspeed: 0,
               naturalYspeed: 0,
               momentary_counterpart: "1234+Hat+LWSS",
              patternstring: "$7b2o$8bo$7bo$bo4bob3o$b3o2bobo2bo$4bobob3obo$b3o2bobo2bo$bo4bob3o$7bo$8bo$7b2o!"
              },

   "1234+Hat+LWSS": {
               rule:  "B3/S23",
               xsize: 14,
               ysize: 13,
               naturalXspeed: 0,
               naturalYspeed: 0,
               counterpart: "1234+Hat",
              patternstring: "$7b2o$8bo$7bo$bo4bob3o4bo2bo$b3o2bobo2bo7bo$4bobo2b2obo2bo3bo$b3o2bobo2bo4b4o$bo4bob3o$7bo$8bo$7b2o!"

              },

 "HexCallahan P42 Gun": {
           
               xsize: 27,
               ysize: 19,
               naturalXspeed: 0,
               naturalYspeed: 0,
               rule: "Hex-B2oS2m34",
               patternstring: "2$9bo$8bobo$9b5o$8b2o3bo$10b5o$2bo6b2obo7bo$3b2o6b2o7b2o$b3ob2o5bo5b3ob3o$3bobo7bo5bobobo$3bob3o11b4obo$4b2obo12bo2b2o$6b2o4bo$6b2o4bobo$8bo5bo$13b2o$13bo!"

              },

"B-Brain Glider Gun": {
               xsize: 66,
               ysize: 45,
               naturalXspeed: 0,
               naturalYspeed: 0,
               rule: "Brian's Brain",
               patternstring: "2$46.A.B.A5.A$46.2B.A7B$7.A.B.A5.A26.BA2.A4.B2.A$7.2B.A7B27.A.B.2AB3A$5.BA2.A4.B2.A27.B.2BAB.2AB.B$6.A.B.2AB3A30.2A3.B2A2BA$6.B.2BAB.2AB.B32.AB2.A$7.2A3.B2A2BA28.2B$11.AB2.A30.2A$7.2B$7.2A37.2B$46.2A2$46.2B$46.2A2$61.B$24.AB33.B2A$22.AB.AB19.AB.AB.AB.AB.A3.BA$22.AB22.AB.AB.AB.AB.A2B.B$59.B.A.B$59.2A.A$11.AB44.A.BA.BA$10.B46.2B.B.B$9.ABA46.3A.B$58.3A2B$57.A2B2A.B$58.B4.A$17.AB39.AB2.B$16.B$15.ABA3$7.2B$7.2A14.AB$22.B$3.B8AB8.ABA$5.2BA2B.B.A.B$5.B3.A.2B3.A$4.ABA3.A3BA2.B$10.A3.B2.A11.AB$10.B4.AB11.B$27.ABA!"

              },


// Experiments

    "1234+Hat-experiment": {rule:  "B3/S23",xsize: 14,
               ysize: 13,
               naturalXspeed: 0,
               naturalYspeed: 0,
               diagonalcounterpart: "diag-ship-1",
               patternstring: "$7b2o$8bo$7bo$bo4bob3o$b3o2bobo2bo$4bobob3obo$b3o2bobo2bo$bo4bob3o$7bo$8bo$7b2o!"

              },

    "diag-ship-1":  {
                 rule:  "B3/S23",
                 //"$3bo5bo$2bobo3bobo$bo2bo4bo$2b2o$7b5o$6bo4bo$5bob2o$2bo2bobobo$bobobo2bobo$2bo2bo3bobo$5b2o3bobo$11b2o!",
                 xsize: 14,
                 ysize: 14,

               //"$3bo2b2o$2bobo2bo$bo2bobo$2b2obo4bo$4bo3b3o$bobo3bo$b2o3bobo$5bobobo$5bo2bobo$4b2o3b2o!",
                //xsize: 12,
                //ysize: 12,

             //"$5bo$5b3o$8bo$5b2obo$b2obob2o$2bob2o5bo$2bo2bo3b3o$3b2o3bo$7bobo$6bobobo$6bo2bobo$5b2o3b2o!",
             //xsize: 13, ysize: 14,  

              //"$b2o2b2o$bobo2bo$2bob2o$3bo4b2o$bobo3bo2bo$b2o4b2obo$5b2obob2o$4bob2o$4bo$5b3o$7bo!",
              //xsize: 13,
              //ysize: 13,


//"$3bo2b2o$2bobo2bo$bo2bobo$2b2obo4bo$4bo3b3o$bobo3bo$b2o3bobo$5bobobo$5bo2bobo$4b2o3b2o!",
//              xsize: 12,
//             ysize: 12,

              naturalXspeed: 0,
              naturalYspeed: 0,
              diagonalcounterpart: "1234+Hat-experiment",
              patternstring: "$2bo4b2o$bobo4bo$2b2o3bo$6bo$5bo4bo$4bo4bobo$bobo6b2o$b2o$6bo$5bobo3bo$6b2o2bobo$11b2o!"

           },

     "e1-orthogonal": {xsize: 13, ysize: 17, naturalXspeed: 0, naturalYspeed: 0,               diagonalcounterpart: "e1-diag",
patternstring: "$8bo$6bo2bo$10bo$b2o2bo4bo$b2o2bo2b4o$5bo5bo$6b5o2$6b5o$5bo5bo$b2o2bo2b4o$b2o2bo4bo$10bo$6bo2bo$8bo!"

           },

      "e2-orthogonal": {rule:  "B3/S23",xsize: 13, ysize: 25,naturalXspeed: 0, naturalYspeed: 0,            diagonalcounterpart: "e1-diag",
       patternstring: "2$9b3o4$9bo$9b2o$b2o$b2ob3o2bobo$5bo5bo$6b5o2$6b5o$5bo5bo$b2ob3o2bobo$b2o$9b2o$9bo4$9b3o!" 

           },
      "e1-diag": {rule:  "B3/S23",xsize: 19, ysize: 19, naturalXspeed: 0, naturalYspeed: 0,             diagonalcounterpart:"e2-orthogonal",
      patternstring: "$7b2o$7b2o3$9b2o$8b3o4b3o$b2o6bob3o$b2o3bo3b4o$5b3o3bo$5b2obo$7b3o$7b2o$7b2o2$6bo$6bo$6bo!"

          },
      
       "rabbits - lifespan 17331": {rule:  "B3/S23",xsize: 7, ysize: 3, naturalXspeed: 0, naturalYspeed: 0,   patternstring: "o3b3o$3o2bob$bo!"
              },

    "Hat + LWSS": { rule:  "B3/S23",xsize: 6, ysize: 7,  
                   naturalXspeed: 0, naturalYspeed: 0, momentary_counterpart: "Hat",patternstring: "$bo$b3o4b4o$4bo2bo3bo$b3o7bo$bo5bo2bo!" },

   
     "drill-orthogonal": {rule:  "B3/S23",xsize: 14, ysize: 13, naturalXspeed: 0, naturalYspeed: 0, 
                diagonalcounterpart: "drill-diag",
                patternstring: "$b2o$bobo$3b3o$2bo3bo$2b2o2b5o$6b2ob3o$2b2o2b5o$2bo3bo$3b3o$bobo$b2o!"
                },

    // "drill-diag": {xsize: 17, ysize: 17, naturalXspeed: 0, naturalYspeed: 0, patternstring: "$11b2o$12bo$9b3o$9bo3$7b2ob2o$3b2o2b2obo$3bo6bobo$bobo3b2o3b2o$b2o4bob2ob2o$8bob2obo$13b2o$13bobo$14b2o!",
    //            diagonalcounterpart: "drill-orthogonal",
    //            },

     "drill-diag": {rule:  "B3/S23",xsize: 15, ysize: 15, naturalXspeed: 0, naturalYspeed: 0,               diagonalcounterpart: "drill-orthogonal",
                     patternstring: "$7bo$5b3o$4bo$3bobo$2bobobob2o$2bo2b2obobo$b2o$5b2ob3o$5bo4bo$7bo$7bo3b2o$9bo3bo$12b2o!"

                },
 

/*
"2x2 Big Ship p3": {   
   xsize: 30,
   ysize: 15,
    naturalXspeed: 0,
    naturalYspeed: 0,
    momentary_counterpart: "2x2 Big Ship shooting c3", 
   rule:  "B36/S125",
   patternstring: "$7bo5b2o$4b2o2bo2bo$2b4o3bo4b5o$2bob2o3b3o6bo$8b2o4bo3bob3o2bo$5bobob2o6b5o2bo$5bo9b3obo4bo2bo$5bobob2o6b5o2bo$8b2o4bo3bob3o2bo$2bob2o3b3o6bo$2b4o3bo4b5o$4b2o2bo2bo$7bo5b2o!"
   },

*/

"2x2 Big Ship p3": {   
   xsize: 42,
   ysize: 15,
    naturalXspeed: 0,
    naturalYspeed: 0,
    momentary_counterpart: "2x2 Big Ship shooting c3", 
   rule:  "B36/S125",
   patternstring: "$7bo5b2o$4b2o2bo2bo$2b4o3bo4b5o$2bob2o3b3o6bo$8b2o4bo3bob3o2bo$5bobob2o6b5o2bo$5bo9b3obo4bo2bo$5bobob2o6b5o2bo$8b2o4bo3bob3o2bo$2bob2o3b3o6bo$2b4o3bo4b5o$4b2o2bo2bo$7bo5b2o!"
   },





"2x2 Big Ship shooting c3": {   
   xsize: 42,
   ysize: 15,
    naturalXspeed: 0,
    naturalYspeed: 0,
    counterpart:  "2x2 Big Ship p3",
   rule:  "B36/S125",
   patternstring: "$7bo5b2o$4b2o2bo2bo26bo$2b4o3bo4b5o18b3o$2bob2o3b3o6bo11bobo2bo2bobo$8b2o4bo3bob3o2bo11b3o$5bobob2o6b5o2bo7b2o3b3o$5bo9b3obo4bo2bo4b2obo2bobo$5bobob2o6b5o2bo12b3o$8b2o4bo3bob3o2bo4bobo5bo$2bob2o3b3o6bo$2b4o3bo4b5o$4b2o2bo2bo$7bo5b2o!"
   },


"Fizzy Ship1 shooting": {   
   xsize: 41,
   ysize: 18,
    naturalXspeed: 0,
    naturalYspeed: 0,
    counterpart:  "Fizzy Ship1",
   rule:  "B3/S2456",
   patternstring: "$11b2o$12bo$12b2o$11b3o2b2o2bo$11bob8o2bo$12b3o3b6o$14bo2b2o3b4o5b5o2bo$19bobobo2bo4bo3b4o$19bobobo2bo4bo3b4o$14bo2b2o3b4o5b5o2bo$12b3o3b6o$11bob8o2bo$11b3o2b2o2bo$12b2o$12bo$11b2o!"
   },





"Fizzy Ship1": {   
   xsize: 41,
   ysize: 18,
    naturalXspeed: 0,
    naturalYspeed: 0,
    momentary_counterpart:  "Fizzy Ship1 shooting",
   rule:  "B3/S2456",
   patternstring: "$11b2o$12bo$12b2o$11b3o2b2o2bo$11bob8o2bo$12b3o3b6o$14bo2b2o3b4o$19bobobo2bo$19bobobo2bo$14bo2b2o3b4o$12b3o3b6o$11bob8o2bo$11b3o2b2o2bo$12b2o$12bo$11b2o!"
   },



     "----Still-lifes----": {patternstring: "3o"},



  
   "biloaf": { rule:  "B3/S23",xsize: 8, ysize: 8,naturalXspeed: 0,
   naturalYspeed: 0,patternstring: "b2o$o2bo$obobo$bo2bo$2b2o!"
     },



 
  "lake": { rule:  "B3/S23",xsize: 11, ysize: 11, patternstring: "4b2o$3bo2bo$3bo2bo$b2o4b2o$o8bo$o8bo$b2o4b2o$3bo2bo$3bo2bo$4b2o!"},

  "Hat" : { rule:  "B3/S23",xsize: 6, ysize: 7,  naturalXspeed: 0, naturalYspeed: 0, momentary_counterpart: "Hat + LWSS",patternstring: "$bo$b3o$4bo$b3o$bo!"},

  
      "----Oscillators----": {patternstring: "3o"},

   "pentadecathlon": { rule:  "B3/S23",xsize: 10, ysize: 9,patternstring: "10o"},
   "relay": { rule:  "B3/S23",
             xsize: 35, ysize: 13, patternstring: "29b2o$27bo4bo$26bo6bo$25bo8bo$4b2o19bo8bo$2bo4bo17bo8bo$bo6bo17bo6bo$o8bo7bo9bo4bo$o8bo5b2o12b2o$o8bo6b2o$bo6bo$2bo4bo$4b2o!"
         },

  "dual Hertz": {rule:  "B3/S23",
   xsize: 14,
   ysize: 23,
patternstring: "$b2ob2o$bo3bo$2b3o2$4b3o$3bo3bob2o$3bo3bobobo$2obobobo2bo$2obo3bo$4b3o2$6b3o$5bo3bob2o$2bo2bobobob2o$bobobo3bo$2b2obo3bo$6b3o2$8b3o$7bo3bo$7b2ob2o!"
    },





  "star": {    rule:  "B3/S23",       xsize: 13,
           ysize: 13,
           patternstring: "6bo$6bo$4b2ob2o2$2bobo3bobo$2bo7bo$2o9b2o$2bo7bo$2bobo3bobo2$4b2ob2o$6bo$6bo!"

          },



  "cross": { rule:  "B3/S23",xsize: 10, ysize: 10, patternstring: "3bo2bo$3bo2bo$2b2o2b2o$3o4b3o3$3o4b3o$2b2o2b2o$3bo2bo$3bo2bo!"},
  
  "crossHH": {rule:  "B3/S23",xsize: 13, ysize: 13, patternstring: "2b4ob4o$2bo2bobo2bo$3o2b3o2b3o$o11bo$o11bo$3o7b3o$2bo7bo$3o7b3o$o11bo$o11bo$3o2b3o2b3o$2bo2bobo2bo$2b4ob4o!"},
   
  "Pure Queen Bee shuttles": {rule:  "B3/S23",xsize: 46, ysize: 11, naturalXspeed: 0,
   naturalYspeed: 0,
   counterpart: "gosperglidergun", 
      patternstring: "2$11bo21bo$9bobo18b4o$2b2o4bobo11b2o5b4o9b2o$2b2o3bo2bo11b2o5bo2bo9b2o$8bobo18b4o$9bobo18b4o$11bo21bo!"  
   },

   "Queen Bee shuttles": {rule:  "B3/S23",xsize: 50, ysize: 17, naturalXspeed: 0,
   naturalYspeed: 0,
   counterpart: "gosperglidergun", 
      patternstring: "5$20bo16bobo$bo17bobo15bo3bo$b3o3b2o10b2obo4b2o12bo5b2o$4bo2b2o10b2ob2o3b2o8bo4bo4b2o$b3o15b2obo18bo$bo17bobo15bo3bo$20bo16bobo2$32bo$31bobo$32b2o!"   
   },


  "ring shuttle": {rule:  "B3/S23",
     xsize: 49,
     ysize: 23,
     patternstring: "31b2o$31b2o5b2o$38b2o3$7b2o8b2o17b2o$7b2o9bo17b2o$18bobo21b2o$19b2o21b2o$b2o$b2o21bo$5b2o16b2o$5b2o16bobo4$2o$2o41bo$41b3o$40bo$40b2o8$7b2o$8bo$5b3o$5bo41b2o$24b2o21b2o$23b4o$22b3obo$23b3obo$24b3o15b2o$25b2o15b2o$46b2o$46b2o$5b2o21b2o$5b2o21bobo$11b2o17bo9b2o$11b2o17b2o8b2o3$9b2o$9b2o5b2o$16b2o!"
     },

   "ring of fire": { rule:  "B3/S23", xsize: 36,
  ysize: 32,
    patternstring: "$17bo$15bobobo$13bobobobobo$11bobobobobobobo$9bobobo2b2obobobobo$7bobobobo6bo2bobobo$5bobobo2bo10bobobobo$6b2obo14bo2bobobo$4bo3bo18bob2o$5b3o20bo3bo$3bo25b3o$4b2o27bo$2bo3bo24b2o$3b4o23bo3bo$bo29b3o$2b3o29bo$bo3bo23b4o$3b2o24bo3bo$2bo27b2o$4b3o25bo$3bo3bo20b3o$5b2obo18bo3bo$4bobobo2bo14bob2o$6bobobobo10bo2bobobo$8bobobo2bo6bobobobo$10bobobobob2o2bobobo$12bobobobobobobo$14bobobobobo$16bobobo$18bo!"

    },

  "pi portraitor": {rule:  "B3/S23",xsize: 22, ysize: 22, patternstring: "5b2o8b2o$5bo2b6o2bo$6b2o6b2o$3b3o10b3o$3bo2bobo4bobo2bo$2obobo4b2o4bobob2o$obobo12bobobo$2bo16bo$bo2bo12bo2bo$bo18bo$bo3bo5b3o2bo3bo$bo3bo5bo2bobo3bo$bo18bo$bo2bo8bo3bo2bo$2bo9bo6bo$obobo12bobobo$2obobo4b2o4bobob2o$3bo2bobo4bobo2bo$3b3o10b3o$6b2o6b2o$5bo2b6o2bo$5b2o8b2o!"
  },


   "galaxy relay": { rule:  "B3/S23",   xsize: 42,
    ysize: 23,
    patternstring: "$32b4o$31bo4bob2o$31bo4bo3bo$34b2o4bo$14b2o15b2o4bo2bo$14b2o14bo2bo3bo2bo$30bo2bo4b2o$30bo4b2o$30bo3bo4bo$24b2o5b2obo4bo$7b2o15bo2bo7b4o$4bo20b3o$3bobo2b2o15b3o$bobob3o2bo$bo2b6o$4b2ob2o17b2o$3b6o2bo14b2o$2bo2b3obobo$3b2o2bobo$8bo$4b2o!"

   },

   "Pulsar": {rule:  "B3/S23",
     xsize: 13,
     ysize: 13,
     patternstring: "2b3o3b3o2$o4bobo4bo$o4bobo4bo$o4bobo4bo$2b3o3b3o2$2b3o3b3o$o4bobo4bo$o4bobo4bo$o4bobo4bo2$2b3o3b3o!"
    },


   "Quasar": {rule:  "B3/S23",
   xsize: 29,
   ysize: 29,
   patternstring: "10b2o5b2o$11b2o3b2o$8bo2bobobobo2bo$8b3ob2ob2ob3o$9bobobobobobo$10b3o3b3o2$8b3o7b3o$2b2o3bobobo5bobobo3b2o$3b2o2b2ob3o3b3ob2o2b2o$o2bobobobo2bo3bo2bobobobo2bo$3ob2o2b2o9b2o2b2ob3o$bobobo3b2o7b2o3bobobo$2b3o19b3o2$2b3o19b3o$bobobo3b2o7b2o3bobobo$3ob2o2b2o9b2o2b2ob3o$o2bobobobo2bo3bo2bobobobo2bo$3b2o2b2ob3o3b3ob2o2b2o$2b2o3bobobo5bobobo3b2o$8b3o7b3o2$10b3o3b3o$9bobobobobobo$8b3ob2ob2ob3o$8bo2bobobobo2bo$11b2o3b2o$10b2o5b2o!"
    },

   "Super Quasar p16": {  rule:  "B3/S23", xsize: 35,
   ysize: 36,
   patternstring: 
"9b2o13b2o$8bo17bo$11bo11bo$9b2o13b2o4$11bo11bo$bo10bo9bo10bo$o2bo9b2o\
5b2o9bo2bo$o2bo10bo5bo10bo2bo$2bo4bo6bo5bo6bo4bo$8bo17bo$9bo15bo$9b3o\
11b3o6$9b3o11b3o$9bo15bo$8bo17bo$2bo4bo6bo5bo6bo4bo$o2bo10bo5bo10bo2bo\
$o2bo9b2o5b2o9bo2bo$bo10bo9bo10bo$11bo11bo4$9b2o13b2o$11bo11bo$8bo17bo\
$9b2o13b2o!"
   },

 "HighLife Replicators + Eaters": {  rule:  "B3/S23", xsize: 39,
   ysize: 39,
   rule:  "B36/S23",
   patternstring: "o$3o$3bo$2b2o5$17bo$12b3o3bo$11bo$11bo$11bo2bo2bo$17bo$17bo$10bo3b3o$11bo13bo$20b3o3bo$19bo$19bo$19bo2bo2bo$25bo$25bo$18bo3b3o$19bo11$35b2o$35bobo$37bo$37b2o!"
   },

"HighLife Replicator 'Pulsar'": { rule:  "B3/S23",  xsize: 33,
   ysize: 31,
   rule:  "B36/S23",
   patternstring: "15b3o2$13bobobobo$6bo6bo5bo6bo$5b3o5bobobobo5b3o$4b2ob2o15b2ob2o$5b2ob2o5b3o5b2ob2o$2bo3b2ob2o11b2ob2o3bo$b3o3b3o13b3o3b3o$2ob2o3bo15bo3b2ob2o$b2ob2o21b2ob2o$2b2ob2o19b2ob2o$3b3o21b3o$4bo23bo4$4bo23bo$3b3o21b3o$2b2ob2o19b2ob2o$b2ob2o21b2ob2o$2ob2o3bo15bo3b2ob2o$b3o3b3o13b3o3b3o$2bo3b2ob2o11b2ob2o3bo$5b2ob2o5b3o5b2ob2o$4b2ob2o15b2ob2o$5b3o5bobobobo5b3o$6bo6bo5bo6bo$13bobobobo2$15b3o!"
   }



// Note that this is the last entry, so there is no trailing comma.

 };


//******************************************************************************************************
//            End of Life  Patterns
//******************************************************************************************************* 

</script>

<div  id="RLEdata"; style="display: none;" > 
#N Turtle with tagalong c/3
#O David Bell and Dean Hickerson
#C An extensible tagalong for the c/3 orthogonal turtle spaceship.
#C www.conwaylife.com/wiki/index.php?title=Turtle
# naturalXspeed: 0.333333333333
# naturalYspeed: 0
x = 72, y = 13, rule = B3/S23
$59bo7b3o$59b2ob2obo2b2o$22bo10b2o25bo4b3o$22b2o20b3o13bo3bobo2bo$10bo
10b5o6bo2b2o10bo12bo4bo4bo$8b3o2b3o3bo6bo10bo5bo4b2o3bo2bo3bo4bo4bo$b
2o3bo2bobo2b2o4b2o2bobo3b3o4b2o2bobo3b3o4b2o4bo3bobo2bo$3b2obobo2bobo
6bo5bo4b2o3bo6bo10bo5bo4b3o$2bo7b3o2bo2b2o10bo7b5o6bo2b2o5b2ob2obo2b2o
$12bo14b3o9b2o18bo7b3o$16b2o21bo10b2o!

#  JustFriends


#N Big Glider Backrake c/5 p30
#C David I. Bell, August 2000
# naturalXspeed: 0.20
# naturalYspeed: 0 
x = 88, y = 62, rule = JustFriends
2$14bo$14b16o2bo7bo$35b2o3bo$7bo9b3o2b4obob3o7bobo$7b8o6b2o3bo2bo3bo8b
2o$15bo3bo17bo2bo$41bo$8b9o2b10o14bo$41b3o$35bobo4bo$7b4o23b2ob2o2bo2b
o$7bo27bobo4bo$41b3o$12b5o2b10o14bo$10bo30bo$7bo7bo3bo17bo2bo12bo$9bob
4o6b2o3bo2bo3bo8b2o9bob14o3bo6bo$4bobo2bo7b3o2b4obob3o7bobo11b2o14bo3b
ob2obobo$5bo29b2o3bo5bo6bob4obo2b2obobob2obo2bobobo$5bo8b16o2bo7bo5bob
5o2bo10bobo3bo3b7o$14bo31b2o8bobobo5b3o11bo2bo$46bo21bo12b2o$47b8o4b9o
9bobo$7b3o36bo27bobobo4bo$7bo38b2o$46bob2o33b2o$46bo$51bo22bobobo4bo$
18b3o29bob3o4b9o9bobo$18bo31bo17bo12b2o$48bo7bobobo5b3o11bo2bo$42bo3bo
3b3o2bo10bobo3bo3b7o$42bo5bo4bob4obo2b2obobob2obo2bobobo$29b3o21b2o14b
o3bob2obobo$29bo11bobo9bob14o3bo6bo$53bo2$50bo$40b2o8bob14o3bo6bo$50b
2o14bo3bob2obobo$40bo5bo3bob4obo2b2obobob2obo2bobobo$40bo3b2ob3o2bo10b
obo3bo3b7o$53bobobo5b3o11bo2bo$47bo17bo12b2o$49b3o4b9o9bobo$71bobobo4b
o$43bo$43bob3o32b2o$43b2o$43bo27bobobo4bo$44b8o4b9o9bobo$43bo21bo12b2o
$43b2o8bobobo5b3o11bo2bo$43bob5o2bo10bobo3bo3b7o$43bo6bob4obo2b2obobob
2obo2bobobo$50b2o14bo3bob2obobo$50bob14o3bo6bo$50bo!


#N Forward Rake c/5 p60
#C This uses a period 60 backward rake and a reaction with a sparker ship.
#C David I. Bell, August 2000
# naturalXspeed: 0.20
# naturalYspeed: 0 
x = 85, y = 60, rule = JustFriends
$11bo$13b15o2b3o2b4o$31bob2obobo$4bo10b3o3b2obobob2obo$6b6o6b2o10b2o2b
o5b2o$13b3obo6bo16bo$13bob2o19b2ob3o$3bo2b7o4b10o6b3ob2o2bo$33b2ob2o$
33bobo4bo$6b2o33b2o$4bo3bo24bobo4bo$8b2o23b2ob2o$8bob3o4b10o6b3ob2o2bo
$8bo4bob2o19b2ob3o$13b3obo6bo16bo$2b3ob6o6b2o10b2o2bo5b2o10bo$5b2o8b3o
3b2obobob2obo20bob14o$4bo26bob2obobo14bo16bob3o2bobo$4bo8b15o2b3o2b4o
4bo11b5o2b2obobo4bo2bobobo$11bo31bob7o7bo5bobo2bo5bo3b2o$43b2o10bob3o
6bo$43bo11b2o23b2o$44b23o14bo$4bobo36bo29b3obob4o$4bo38b2o28bobo2bobo$
43bob2o25b2ob3obob3o$43bo29bobo2bobo$48bo24b3obob4o$47bob18o14bo$47bo
7b2o23b2o$43bo11bob3o6bo$43bobob5o7bo5bobo2bo5bo3b2o$55b5o2b2obobo4bo
2bobobo$26bobo14bobo7bo16bob3o2bobo$26bo8b3o14bob14o$52bo$49bo$49bob
14o$37bobo10bo16bob3o2bobo$37bo6bo7b5o2b2obobo4bo2bobobo$42b2ob4o7bo5b
obo2bo5bo3b2o$44bo7bob3o6bo$46bo5b2o23b2o$46bob16o14bo$70b3obob4o$42bo
27bobo2bobo$42bob2o23b2ob3obob3o$43bo26bobo2bobo$70b3obob4o$43b21o14bo
$52b2o23b2o$43bo8bob3o6bo$42bob5o7bo5bobo2bo5bo3b2o$42bo9b5o2b2obobo4b
o2bobobo$50bo16bob3o2bobo$49bob14o$49bo!


#N Wide Bullet c/3
#C Paul Tooke, July 2000
# naturalXspeed: 0.333333333333
# naturalYspeed: 0
x = 11, y = 18, rule = JustFriends
2$2bo$4bo$6b3o$5b2o2bo$5b4o$2bobo$5b2o$4bo2bo$5b2o$2bobo$5b4o$5b2o2bo$
6b3o$4bo$2bo!

#N Shuttle Bullet c/3
#C Paul Tooke, July 2000
# naturalXspeed: 0.333333333333
# naturalYspeed: 0
x = 18, y = 9, rule = JustFriends
$bo$3bo5b5o$5b4obo3b2o$4b2o7bo2bo$bo2b4obo4b2o$2bo8b3o$5b6o!

#N Pointy Ship1 c/3
#C Paul Tooke, July 2000
# naturalXspeed: 0.333333333333
# naturalYspeed: 0
x = 30, y = 13, rule = JustFriends
$2b7o$b2o7b7o$bo2bob3o12b2o$bo6b8obo$19bo3bob3o$8b10o3bo2b2o2bo$19bo3b
ob3o$bo6b8obo$bo2bob3o12b2o$b2o7b7o$2b7o!

#N Ship c/4
#C Paul Tooke
# naturalXspeed: 0.25
# naturalYspeed: 0
x = 33, y = 15, rule = JustFriends
$6bo9b2o3bo3b2o$8b2o3bobo3b2o5bo$6bo2bo4bo2bo12b2o$2bobo2b2o3bobo7bob
2o3bo$4bo3b3o17bo2bo$14b13obob2o2$13b13obob2o$3bo3b3o17bo2bo$bobo2b2o
3bobo7bob2o3bo$5bo2bo4bo2bo12b2o$7b2o3bobo3b2o5bo$5bo9b2o3bo3b2o!

#N Long Ship c/6
#C Paul Tooke
# naturalXspeed: 0.166666666667
# naturalYspeed: 0
x = 40, y = 13, rule = JustFriends
$3b9o4bo14bo$2bo9b2o3b5o11bo$bo8bo3b3o5b2o3bo6bo$bob2o5bo2bo6bo13bo$5b
o8bobo6bo4b2obo4b2o$3b2o4bobo19bob2o3bo$5bo8bobo6bo4b2obo4b2o$bob2o5bo
2bo6bo13bo$bo8bo3b3o5b2o3bo6bo$2bo9b2o3b5o11bo$3b9o4bo14bo!


#N Pointy Ship1 c/7
#C Paul Tooke, July 2000
# naturalXspeed: 0.142857142857143
# naturalYspeed: 0
x = 29, y = 15, rule = JustFriends
$5b4o$4b2o3b6o$5bo10b4o$4bo9bo5b2o$11bo3bo$bobo3b3o4bo6b5obo$2bobo2bo
2bo4bo4bo2b3o$bobo3b3o4bo6b5obo$11bo3bo$4bo9bo5b2o$5bo10b4o$4b2o3b6o$
5b4o!

#N Blunt Ship2 c/7
#C Paul Tooke, July 2000
#C A c/7 ship.
#C Paul Tooke, July 2000
# naturalXspeed: 0.142857142857143
# naturalYspeed: 0, 
x = 18, y = 18, rule = JustFriends
$3bo3b5o$bobo2b2o6bo$4bob5o$7b2o6b2o$9b2o$4bo9bo$4b8o3$4b8o$4bo9bo$9b
2o$7b2o6b2o$4bob5o$bobo2b2o6bo$3bo3b5o!

#N Pointy Ship3 c/7
#C Paul Tooke, July 2000
#naturalXspeed: 0.142857142857143
#naturalYspeed: 0, 
x = 39, y = 17, rule = JustFriends
3$bo3b14o$bo2bo14b5o$b2o2bobobo3b2o3bo5b5o$2b2obobob2o3bo3bob3o6b2o$2b
o3bobo9bo16bo$b2obo12bo3b5o3b2o$bo3bo10bo2bo3bo5bo6b2o$b2obo12bo3b5o3b
2o$2bo3bobo9bo16bo$2b2obobob2o3bo3bob3o6b2o$b2o2bobobo3b2o3bo5b5o$bo2b
o14b5o$bo3b14o!

#N Slow-Growship2 c/3+4c/14
#C A growing spaceship. c/3+4c/14
#C The front moves at c/3, the back at 4c/14.
#C Dean Hickerson, July 2000
#naturalXspeed: 0.333333333333333
#naturalYspeed: 0, 
x = 18, y = 7, rule = JustFriends
10bo$bo10b3o$3b3o4bo4b2o$o6bob3o2bo2bo$4b2o4bo4b2o$2bo9b3o$10bo!

# The Three speed crawler is a candidate for deletion from the built-in library

#N Three Speed Crawler
#C A three-speed spaceship which uses a line-crawling component.
#C David I. Bell, July 2005
x = 152, y = 122, rule = JustFriends
116bo$116b16o2bo7bo$137b2o3bo$109bo9b3o2b4obob3o7bobo$109b8o6b2o3bo2bo
3bo8b2o$117bo3bo17bo2bo$143bo$110b9o2b10o14bo$143b3o$137bobo4bo$109b4o
23b2ob2o2bo2bo$109bo27bobo4bo$143b3o$114b5o2b10o14bo$112bo30bo$109bo7b
o3bo17bo2bo$111bob4o6b2o3bo2bo3bo8b2o$106bobo2bo7b3o2b4obob3o7bobo$
107bo29b2o3bo$107bo8b16o2bo7bo$105b3o8bo$95bo9b2o12bo$95b3o6bobo12b16o
2bo7bo$105bo4b3o27b2o3bo$104bobo2b2obo9b3o2b4obob3o7bobo$109bo3b7o6b2o
3bo2bo3bo8b2o$109b3o8bo3bo17bo2bo$112bobo31bo$114b8o2b10o14bo$146b3o$
110bo29bobo4bo$73bo36bob2o25b2ob2o2bo2bo$73b3o64bobo4bo$146b3o$111b11o
2b10o14bo$22bo11bo11bo11bo87bo$22bo11bo11bo11bo61bo3bo17bo2bo$22bo11bo
11bo11bo51bob8o6b2o3bo2bo3bo8b2o$79bo30bo11b3o2b4obob3o7bobo$28b2o49bo
b14o10bo34b2o3bo$27bo45bo23bo2b2o17b16o2bo7bo$15bo56bobo7b4o3b2obobob
2obo4bobo12bo$13b3o56bobob6o4bo4b2obo2bo5b2o2b2o$17bo54bo7bo4bo19bo$
15b2o59bo6bo21b3o$76b6o2b10o11bo2bo$101bo4bo$72bo27bobo2bo3bo$72bob2o
30bo$50b2o48bobo2bo3bo$49bo51bo4bo$13bo59b9o2b10o11bo2bo$11b3o69bo21b
3o13bo$15bo64bo4bo19bo15bob14o10bo$13b2o57bob8o4bo4b2obo2bo5b2o2b2o30b
o2b2o$72bo9b4o3b2obobob2obo4bobo5bo11b4o3b2obobob2obo4bobo$97bo2b2o10b
ob10o4bo4b2obo2bo5b2o2b2o$79bob14o10bo7bo8bo4bo19bo$79bo45bo21b3o$72b
2o39b11o2b10o11bo2bo$71bo71bo4bo$11bo101bo28bobo2bo3bo$9b3o100bob2o32b
o$13bo98bo29bobo2bo3bo$11b2o130bo4bo$116bob6o2b10o11bo2bo$116bo8bo21b
3o$112b3o7bo4bo19bo$110b2obob9o4bo4b2obo2bo5b2o2b2o$94b2o28b4o3b2obobo
b2obo4bobo$93bo17bobo25bo2b2o$9bo93b3o15bob14o10bo$7b3o111bo$11bo54bo
51bo$9b2o55b16o2bo7bo12b2o11bob14o10bo$87b2o3bo11bo6b3o22bo2b2o$59bo9b
3o2b4obob3o7bobo16b2obo7b4o3b2obobob2obo4bobo$59b8o6b2o3bo2bo3bo8b2o
14bo3b7o4bo4b2obo2bo5b2o2b2o$67bo3bo17bo2bo17b3o6bo4bo19bo$93bo19bobo
6bo21b3o$60b9o2b10o14bo19b6o2b10o11bo2bo$7bo85b3o44bo4bo$5b3o79bobo4bo
16bo27bobo2bo3bo$9bo49b4o23b2ob2o2bo2bo14bob2o30bo$7b2o50bo27bobo4bo
44bobo2bo3bo$93b3o44bo4bo$64b5o2b10o14bo16b9o2b10o11bo2bo$62bo30bo28bo
21b3o$67bo3bo17bo2bo26bo4bo19bo$59b2ob5o6b2o3bo2bo3bo8b2o15bob8o4bo4b
2obo2bo5b2o2b2o$54bo6bo7b3o2b4obob3o7bobo17bo9b4o3b2obobob2obo4bobo$5b
o49b2o30b2o3bo43bo2b2o$3b3o60b16o2bo7bo25bob14o10bo$7bo58bo51bo$5b2o
62bo$43bo8b3o14b16o2bo7bo$44b2o15bo28b2o3bo$60bobo9b3o2b4obob3o7bobo$
60bobob6o6b2o3bo2bo3bo8b2o$60bo9bo3bo17bo2bo$64bo31bo$3bo60b8o2b10o14b
o$b3o92b3o$5bo54bo29bobo4bo$3b2o55bob2o25b2ob2o2bo2bo$21bo68bobo4bo$
22b2o72b3o$61b11o2b10o14bo$96bo$70bo3bo17bo2bo$60bob8o6b2o3bo2bo3bo8b
2o$2o58bo11b3o2b4obob3o7bobo5b3o$2bo87b2o3bo5b2o2bo$o2bo65b16o2bo7bo5b
o2bo$2obo65bo31bob2o2$101obob2o$102bo2bo$97b3o2b2o2bo$97bo2bo2b3o$100b
o$99b2o!



#N Glider Gun p236
#C Kellie Evans, July 2000
x = 55, y = 59, rule = JustFriends
4$17bo2$15bo3bo$22b2o$16bobo$17bo10$28bo$24bo$24bobobo$24b2o2$47bo$46b
3o$25bo18bo$25bo20b3o$21bo31bo$20b2o$15bobo$46bobo$17bo$9b5obo$11bobob
2o2$12b3o$11bo$10bo$10bo6$26b2o$25bo$26bob3o$30bo$31bo$30bo2$28bo4b2o$
28bo2$52bo$50bobo!

#N Big Glider Gun p236
#C A period 236 big glider gun using two period 236 glider guns.
#C Dean Hickerson, July 2000
x = 102, y = 85, rule = JustFriends
8$92b2o$98b2o$65bo27bo$65bo27bo$91b2o3$62bobo2$60bo2bo21bo$60b4o21bo$
86b2o$83bobo$78bo3bobobo$82bob2o$80bo$80b4o$56bo6bo15b2o$64b2o13bo$79b
o$50b2o$54bo$56bo$58bo$56bobo4$72bo2$70bo3bo$77b2o$71bobo$72bo2$30bobo
2$25b2o2bo3bo2$31bo$31bo3$45b2o$45bo$45bo2bo$45b2o21bo$48bo$52b2o13b2o
bo$70bo$38bobo28b2o$40bo$20b3o$18b2o3b2o$17bo3bob2o$17bobo$16b2o2b2o$
17bobo$18bo21bo2bo$18bo24bo$39bo2b2o2$40bo2$10bobo$38bo$10bo27bo$4b2o
3bo$9b3o!



#N "Spinning" p236 Oscillator
#C A period 236 "spinning" oscillator.
#C This rotates 90 degrees every 59 generations.
#C The oscillator has sparks which allow it to perturb many things.
#C In particular, it is the basis for many glider guns.  This oscillator
#C occurs spontaneously and is also very easy to construct.
#C David I. Bell, July 2002
x = 7, y = 8, rule = JustFriends
oobbo$6bo$4bo4$4bo$4bo!

#N A period 378 glider loop
#C This is based on glider turning reactions using four base period 26
#C oscillators whose phases are changed to period 37 due to the impacts.
#C If M is the number of contiguous period 37 gliders in the loop and N
#C is the number of contiguous period 26 gaps in the loop, then similar
#C oscillators can be built for any period of the form 37M + 26N, where
#C M > 0 and N > 0.  (Here M=6 and N=6).
#C David I. Bell, August 2004
x = 144, y = 144, rule = JustFriends
66b7o$$68bobo$68bobo$68bobo7$67b3o$69bo5$61boo$63bo5$55boo$$56bo4$49b
oo$50bo$50bo4$43bo$44bo56bo$44bo$100boo4$36bobo$38bo69bo$106boo5$114bo
$112b3o5$120bo$118bobo5$126bo$126bo$125bo3$143bo$132bo10bo$132bo6b3obo
$131boo10bo$139b3obo$o142bo$o142bo$ob3o$o10boo$ob3o6bo$o10bo$o3$18bo$
17bo$17bo5$23bobo$23bo5$29b3o$29bo5$36boo$35bo69bo$105bobo4$42boo$99bo
$42bo56bo$100bo4$93bo$93bo$93boo4$87bo$$87boo5$80bo$81boo5$74bo$74b3o
7$73bobo$73bobo$73bobo$$71b7o!

#N JF breeder.
#C This uses a c/5 period 30 backward big glider rake and a period 30
#C c/5 sparking ship to create a row of c/3 wickstretchers.
#C David I. Bell, August 2000
# naturalXspeed: 0.20
# naturalYspeed: 0 
x = 119, y = 58, rule = JustFriends
48bo$48bob14o$49bo16bob3o2bobo$41bo9b5o2b2obobo4bo2bobobo$41bob5o7bo5b
obo2bo5bo3b2o$42bo8bob3o6bo$51b2o23b2o$42b21o14bo$69b3obob4o$42bo26bob
o2bobo$41bob2o23b2ob3obob3o$41bo27bobo2bobo$69b3obob4o$45bob16o14bo$
45bo5b2o23b2o$41bo9bob3o6bo25bo$41bobob3o7bo5bobo2bo5bo3b2o10b16o2bo7b
o$41bobo7b5o2b2obobo4bo2bobobo33b2o3bo$41b3o5bo16bob3o2bobo5bo9b3o2b4o
bob3o7bobo$37bo10bob14o17b8o6b2o3bo2bo3bo8b2o$37bo10bo40bo3bo17bo2bo$
35bob2o76bo$35bo46b9o2b10o14bo$36bo78b3o$26bo82bobo4bo$26bo20b2o32b4o
23b2ob2o2bo2bo$24bob2o18bo34bo27bobo4bo$24bo90b3o$25bo60b5o2b10o14bo$
15bo68bo30bo$15bo42b2o21bo7bo3bo17bo2bo$13bob2o40bo20b3o3b5o6b2o3bo2bo
3bo8b2o$13bo77b3o2b4obob3o7bobo$14bo65bo28b2o3bo$27bo52bo7b16o2bo7bo$
17b2o10b15o2b3o2b4o14b2o17bo$17bo29bob2obobo13bo$2o4bo4b2o4bo5bo7b3o3b
2obobob2obo37bo$5bobo9bo3b2ob4o6b2o10b2o2bo5b2o27b16o2bo7bo$5bobo21b3o
bo6bo16bo19bobo26b2o3bo$24bo4bob2o19b2ob3o30b3o2b4obob3o7bobo$24bob3o
4b10o6b3ob2o2bo18b2obob5o6b2o3bo2bo3bo8b2o$24b2o23b2ob2o24b3o5bo3bo17b
o2bo$20bo3bo24bobo4bo25bo29bo$22b2o33b2o23bob4o2b10o14bo$49bobo4bo55b
3o$49b2ob2o24bo27bobo4bo$19bo2b7o4b10o6b3ob2o2bo20b4o23b2ob2o2bo2bo$
29bob2o19b2ob3o48bobo4bo$29b3obo6bo16bo54b3o$22b6o6b2o10b2o2bo5b2o21b
9o2b10o14bo$20bo10b3o3b2obobob2obo64bo$47bob2obobo31bo3bo17bo2bo$29b
15o2b3o2b4o23b8o6b2o3bo2bo3bo8b2o$27bo50bo9b3o2b4obob3o7bobo$106b2o3bo
$85b16o2bo7bo$85bo!


#N Invincible Box
x = 121, y = 121, rule = 345/2/4
3.A113.A$2.117A$.2A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A
.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.2A$
2A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.
A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.2A$.2A.113A.2A$.A.
2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.
2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$
.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A
$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.
2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.
2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A
111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.
2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.
2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$
.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A
$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.
2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.
2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A
111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.
2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.
2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$
.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A
$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.
2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.
2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A
111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.
2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.
2A.A111.A.2A$.A.2A111.2A.A$.2A.A111.A.2A$.A.2A111.2A.A$.2A.113A.2A$2A
.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.
A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.2A$.2A.A.A.A.A.A.A.A.
A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A
.A.A.A.A.A.A.A.A.A.A.A.A.A.A.A.2A$2.117A$3.A113.A!

#N  Double Wall Ship
#C Adapted from Knightlife's moving wall rake: http://www.conwaylife.com/forums/viewtopic.php?f=11&t=507&start=100#p5557
x = 65, y = 69, rule = 345/2/4
2$60.CBA$6.CBA51.CBA$6.C.A$6.C.AB54A$6.C.AB54A$4.C.C.A$3.C2.CBA.BC13.
AB2C31.CBA$9.ABC13.AC2.BA29.CBA$24.2B.A.CB$24.CAC2B.C.2A$27.A3.BA.B6.
CBA$21.A3.B2AC.ABCBC8.CBA$20.BCB.A.A5.C2.2A3.2C2A.A$18.B.A.A.B2C3.AB
3.AB2AB.AB.AB2A$18.C3ABC.BA.C.A.ABA.AC.BC.A.AB2A$19.C7.A.A.A.C.A.A.A.
A.A.A$15.C.CB27A$11.C2.B2.2A.A.A.A.A3.A.A.A.A.A.A.A.A$4.AB4.C3.CA.A.A
.2A.BACA3.A.A.A.2A2.BA$4.B2C.CB5.B.ABC.A2.A.B4.C2.C2.A.BA$3.AC2.B.BA
3.C2.AB.B.B10.BC2A.CA$4.B3A.C8.C2.A11.AB.2AB$6.A.C11.2A14.2A$4.3A13.A
CB13.2A$5.AC12.3A$4.ABCB12.3A11.CBA$6.A13.2A14.CBA$36.CBA4$8.C$9.B$8.
C4$36.CBA$6.A13.2A14.CBA$4.ABCB12.3A11.CBA$5.AC12.3A$4.3A13.ACB13.2A$
6.A.C11.2A14.2A$4.B3A.C8.C2.A11.AB.2AB$3.AC2.B.BA3.C2.AB.B.B10.BC2A.C
A$4.B2C.CB5.B.ABC.A2.A.B4.C2.C2.A.BA$4.AB4.C3.CA.A.A.2A.BACA3.A.A.A.
2A2.BA$11.C2.B2.2A.A.A.A.A3.A.A.A.A.A.A.A.A$15.C.CB27A$19.C7.A.A.A.C.
A.A.A.A.A.A$18.C3ABC.BA.C.A.ABA.AC.BC.A.AB2A$18.B.A.A.B2C3.AB3.AB2AB.
AB.AB2A$20.BCB.A.A5.C2.2A3.2C2A.A$21.A3.B2AC.ABCBC8.CBA$27.A3.BA.B6.C
BA$24.CAC2B.C.2A$24.2B.A.CB$9.ABC13.AC2.BA29.CBA$3.C2.CBA.BC13.AB2C
31.CBA$4.C.C.A$6.C.AB54A$6.C.AB54A$6.C.A$6.CBA51.CBA$60.CBA!

#C test comment

#N c/5 spaceship #19275
naturalXspeed: .20,
naturalYspeed: 0,
x = 34, y = 16, rule = B368/S12578
$21bo$2bo14b2o2bobo$2bo2b2o7b2ob2o2bob2obo2bo$bob2obo2b2o2bob4o2bo3b6o
$3bo5b2o2b2ob2o4b2o2b3o2bo$5bo3bo3b3obo4bo2bo2bobo$7b2o4b3o2bo5b2o2b5o
$7b2o4b3o2bo5b2o2b5o$5bo3bo3b3obo4bo2bo2bobo$3bo5b2o2b2ob2o4b2o2b3o2bo
$bob2obo2b2o2bob4o2bo3b6o$2bo2b2o7b2ob2o2bob2obo2bo$2bo14b2o2bobo$21bo

#N 2x2 and HotRep c/4 diag
#naturalXspeed = 0.25
#naturalYspeed = 0.25
x = 16, y = 16, rule = B368/S12578, B36/S125
$8bobo2$7bob2o$11bo$8bo$11bo$3bo10bo$bo3bo5b2obo$3bo6bob2o$bobo5bo$4bo
bobo3bo$8b2obo$9bo$7b2o!

#N c/3 diagonal ship #19502 
#naturalXspeed: 0.333333333,
#naturalYspeed: 0.333333333,
x = 35, y = 35, rule = B368/S12578
$7b2o$6bob2o$5bo3bo$5b5o$3b2o3b3o$2bobo5b2o3bo$bo2bo5bo6b2o$b2ob2o5b2o
2b2o$2b4o9b2o$5b3o2bo7b2o$6bobo2b3ob2obo$8bo2b2o3bobobo$11bobo3bo2bo$
19b2o$6bob2obo8b4o$8b2ob2o7b2o$7bo5bo8b2obo$7bo2b3o10bobo$10bo3bo4bo3b
5o$12b5o7b2obo$15b2o4b2o4bo$15bobo3bo4bo$15bob3o4bo2bo$19b2o2bobob3o$
17b4o3bob2ob2o$19bo2bo2b2o3bo$19b3ob3o3b2o$24bo3b6o$24b2ob3ob3o$25b4o
2b3o$28b5o$28b4o$28b3o!
</div>

<script type="text/javascript">

/*  An ill-placed   Parse userRLEstring  section.  This does not work with the patternstring itself - it just turns RLE examples into lifepatterns.
*/




function parseMultipleRLEentries (RLEinput) {
     RLEinput = RLEinput.replace(/(\r\n|\n|\r)/gm,"-----newline-----");
     RLEinput = RLEinput.split("-----newline-----");
     RLEinput[RLEinput.length] = "";
     var newname = "";
     var newinfo = "";
     var xyandruleline = "";
     var newx = 0;
     var newy = 0;
     var newXspeed = 0;
     var newYspeed = 0;
     var newrule = "all";
     var newpatternstring = "";
     var firstname = "";
     for (var i=0; i<RLEinput.length; i++) {
       if (RLEinput[i].match("#N ")) {
         newname = RLEinput[i].replace("#N ", "");
         continue;
       }
       
       if (RLEinput[i].match("naturalXspeed") || RLEinput[i].match("NaturalXspeed")) {
         newXspeed = RLEinput[i].replace(" = ", "");
         newXspeed = newXspeed.replace(":", "");
         newXspeed = newXspeed.replace("#", "");
         newXspeed = newXspeed.toUpperCase();
         newXspeed = parseFloat(newXspeed.replace("NATURALXSPEED", ""));
         continue;
       }
       if (RLEinput[i].match("naturalYspeed") || RLEinput[i].match("NaturalYspeed")) {
         newYspeed = RLEinput[i].replace(" = ", "");
         newYspeed = newYspeed.replace(":", "");
         newYspeed = newYspeed.replace("#", "");
         newYspeed = newYspeed.toUpperCase();
         newYspeed = parseFloat(newYspeed.replace("NATURALYSPEED", ""));
         continue;
       }
       
      
      else if (RLEinput[i].match("#")) { 
         //continue;  // for now, jump to the next line.  Later, this can be replaced with code to build up the .info section of the pattern entry.
         newinfo = newinfo.concat(RLEinput[i]); 
         continue;
       };

     

      if (RLEinput[i].match("x = ")) {
         xyandruleline = RLEinput[i].split(",");
         newx = parseInt(xyandruleline[0].replace("x = ", ""));
         newy = parseInt(xyandruleline[1].replace("y = ", ""));
         newrule = xyandruleline[2].replace("rule = ", "");
         if (newrule.match("/")) {newrule = newrule.toUpperCase();}   // the idea here is to capitalize the rule only if it has a slash in it like B3/S23 or B2/S345/4
         newrule = newrule.replace(/\s+/g,"");  // this removes all the spaces from the rule.   *******************************
         // now account for any extra rules added such as "x = 16, y = 16, rule = B368/S12578, B36/S125" ==> rule: ["B368/S12578", "B36/S125"]
         if (xyandruleline.length > 3) {
            newrule = [newrule];
            for (var r = 3; r < xyandruleline.length; r++) {
               newrule[r-2] = xyandruleline[r];
               if (newrule[r-2].match("/")) {newrule[r-2] = newrule[r-2].toUpperCase();}  
               newrule[r-2] = newrule[r-2].replace(/\s+/g,"");
            }
          };
           continue;
      };

      // We can also test for lines which start with "rule ="
      // The following code assumes that normal rule lines which start with "x =" have already been dispatched with.
     //  The following code depends on the "continue" statement in the above section.
     //  The followiong code is pretty redundant, sharing a lot of code with the above section - could be generalized.

         if (RLEinput[i].match("rule = ")) {
         xyandruleline = RLEinput[i].split(",");
                  newrule = xyandruleline[0].replace("rule = ", "");
         if (newrule.match("/")) {newrule = newrule.toUpperCase();}   // the idea here is to capitalize the rule only if it has a slash in it like B3/S23 or B2/S345/4
         newrule = newrule.replace(/\s+/g,"");  // this removes all the spaces from the rule.   *******************************
         // now account for any extra rules added such as "x = 16, y = 16, rule = B368/S12578, B36/S125" ==> rule: ["B368/S12578", "B36/S125"]
         if (xyandruleline.length > 1) {
            newrule = [newrule];
            for (var r = 1; r < xyandruleline.length; r++) {
               newrule[r] = xyandruleline[r];
               if (newrule[r].match("/")) {newrule[r] = newrule[r].toUpperCase();}  
               newrule[r] = newrule[r].replace(/\s+/g,"");
            }
          };
           continue;
      };


    

      if (RLEinput[i] != "") {
        newpatternstring = newpatternstring.concat(RLEinput[i]);
        continue;
      }
      else {
      // code to add to lifepatterns
       if (newpatternstring != "") {
            if (newname == "") {
              var dzzz=new Date();
              dzzz = dzzz.getTime();
              newname = "user added" + dzzz;
            };
         lifepatterns[newname] = {naturalXspeed: newXspeed, naturalYspeed: newYspeed, patternstring: newpatternstring};
         if (newx > 0) {lifepatterns[newname].xsize = newx; lifepatterns[newname].ysize = newy;}
         if (newrule != "") {lifepatterns[newname].rule = newrule};
         if (newinfo != "") {lifepatterns[newname].info = newinfo};
         if (firstname == "") {firstname = newname};

        };

       


      // now get ready for next pattern if there is one
       var newname = "";
       var newinfo = "";
       var xyandruleline = "";
       var newx = 0;
       var newy = 0;
       var newrule = "B3/S23";
       var newpatternstring = "";
       }

     } // end for loop

    // if (newpatternstring != "") {
          // code to to add last (or only) pattern to lifepatterns
    //     if (newname == "") {
    //          var dzzz=new Date();
    //          dzzz = dzzz.getTime();
    //          newname = "user added" + dzzz;
     //    };
      // if ( newx == 0 && newpatternstring != "") { lifepatterns[newname] = {rule: newrule, patternstring: newpatternstring} };
      // if ( newx > 0  && newpatternstring != "")  { lifepatterns[newname] = {xsize: newx, ysize: newy, rule: newrule, patternstring: newpatternstring}};            //  }
   return firstname;
}
      
         
parseMultipleRLEentries (document.getElementById("RLEdata").innerHTML)

// **************  Section for removing the RLE Data once it has been processed. ********************

// This is the usual way to remove a div

function removeElementByName(parent,div){ 
   var d1=document.getElementById(parent); 
   var d2=document.getElementById(div); 
   d1.removeChild(d2); 
} 

 removeElementByName ("MainBody", "RLEdata")


/*
//if we don't have the name of the parent, this will workt:

function removeElementWithNoNameParent (div) {
   var d1=document.getElementById(div).parentNode
   var d2=document.getElementById(div); 
   d1.removeChild(d2); 
} 


// removeElementWithNoNameParent("RLEdata"); // equivalent to document.getElementById("RLEdata").parentNode.removeChild(document.getElementById("RLEdata"))
*/
//*************End Section*****************
      

//This javascript replaces all 3 types of line breaks with a comma
//someText = someText.replace(/(\r\n|\n|\r)/gm,",");
// from http://www.textfixer.com/tutorials/javascript-line-breaks.php

//  someText.replace(/\s/g,"");    // this removes all the spaces from one line --  /\s/gm would remove spaces from multiple lines.


/* 
In addition to the commas in the RLE bug,  I think there will be a bug if an unknown rule is entered, particularly a generations rule. See how RLEs and Generations rules are handled.
*/

//  THis function -- parseUserAddedRLE --  can be deleted.  It is now replaced by parseMultipleRLEentries
function parseUserAddedRLE() { 
  var newrle = prompt("Please enter an RLE pattern here:");
  var newx = 0;
  var newy = 0;
  var newrule = "all";
  var newpatternstring = "3o!";  // RLE patternstring for the three cell Blinker as a default.  
  var dzzz=new Date();
  dzzz = dzzz.getTime();
  var newname = "user added" + dzzz;   // could look for a #N line for an embedded name, or could prompt the user for a name.

  newrle = newrle.replace(/(\r\n|\n|\r)/gm,","); // note that this will replace ALL line breaks with commas, including linebreaks in the rle code. note the use of "g" for global and "m" for multiline
  newrle = newrle.split(",")
  if (newrle.length >= 4 && newrle[0].match("x =") ) {
     newx = parseInt(newrle[0].replace("x = ", ""));  // only replaces the first instance, which is fine here, but suggests a good trick for the line "x = 5, y =6, rule = b3/s23"
     newy = parseInt(newrle[1].replace("y = ", ""));
     newrule = newrle[2].replace("rule = ", "");
     newrule = newrule.toUpperCase()
     newrule = newrule.replace(/\s+/g,"");  // this removes all the spaces from the rule.
    
     newpatternstring = newrle[3]
     for (var i=4; i<newrle.length; i++) {
          newpatternstring = newpatternstring.concat(newrle[i]);  
     }
    lifepatterns[newname] = {xsize: newx, ysize: newy, rule: newrule, patternstring: newpatternstring};
    return newname;
  }
  else {
   newpatternstring = newrle[0];
    for (var i=1; i<newrle.length; i++) {
          newpatternstring = newpatternstring.concat(newrle[i]);  
    }

   lifepatterns[newname] = {rule: newrule, patternstring: newpatternstring};
   return newname;

   };

}

// function parseMultipleRLEentries (RLEinputstring)

/*
x = 27, y = 15, rule = B3/S23
10b4o13b$10bo3bo12b$10bo16b$b2o8bo2bo12b$2ob2o22b$b4o3bo18b$2b2o3bob2o
8bo4b3o$6bo3bo8bo4bobo$2b2o3bob2o8bo4b3o$b4o3bo18b$2ob2o22b$b2o8bo2bo
12b$10bo16b$10bo3bo12b$10b4o!
*/

/*
#N Blinker ship 1
#O Paul Schick
#C A blinker ship created by Paul Schick based on his Schick engine.
#C www.conwaylife.com/wiki/index.php?title=Blinker_ship_1
x = 27, y = 15, rule = B3/S23
10b4o13b$10bo3bo12b$10bo16b$b2o8bo2bo12b$2ob2o22b$b4o3bo18b$2b2o3bob2o
8bo4b3o$6bo3bo8bo4bobo$2b2o3bob2o8bo4b3o$b4o3bo18b$2ob2o22b$b2o8bo2bo
12b$10bo16b$10bo3bo12b$10b4o!


*/



// **********************************************************************
 
//if arr[x][y] == background and pcolor != background, then increase alivecount.
//if arr[x][y] != background and pcolor == bacground, then decrease alivecount.   


// pdecayval is an optional parameter for setCell.

function setCell(x, y, pcolor, pXspeed, pYspeed, pdecayval, pextra) {
  x = getborderXcoord(x);
  y = getborderYcoord(y);
  if ((arr[x][y].color == background || arr[x][y].color == decaygray) && (pcolor != background && pcolor != decaygray)) {                   
        arr[x][y].neighbors[0].alivecount += 1;
	arr[x][y].neighbors[1].alivecount += 1;
	arr[x][y].neighbors[2].alivecount += 1;
	arr[x][y].neighbors[3].alivecount += 1;
	arr[x][y].neighbors[4].alivecount += 1;
	arr[x][y].neighbors[5].alivecount += 1;
	arr[x][y].neighbors[6].alivecount += 1;
	arr[x][y].neighbors[7].alivecount += 1;
        if (range != 8) {
	arr[x][y].neighbors[8].alivecount += 1;
	arr[x][y].neighbors[9].alivecount += 1;
	arr[x][y].neighbors[10].alivecount += 1;
	arr[x][y].neighbors[11].alivecount += 1;
	arr[x][y].neighbors[12].alivecount += 1;
	arr[x][y].neighbors[13].alivecount += 1;
	arr[x][y].neighbors[14].alivecount += 1;
	arr[x][y].neighbors[15].alivecount += 1;
	arr[x][y].neighbors[16].alivecount += 1;
	arr[x][y].neighbors[17].alivecount += 1;
	arr[x][y].neighbors[18].alivecount += 1;
	arr[x][y].neighbors[19].alivecount += 1;
	arr[x][y].neighbors[20].alivecount += 1;
	arr[x][y].neighbors[21].alivecount += 1;
	arr[x][y].neighbors[22].alivecount += 1;
	arr[x][y].neighbors[23].alivecount += 1;

        }
      } 
      else  if ((arr[x][y].color != background && arr[x][y].color != decaygray) && (pcolor == background || pcolor == decaygray)) {      
        arr[x][y].neighbors[0].alivecount -= 1;
	arr[x][y].neighbors[1].alivecount -= 1;
	arr[x][y].neighbors[2].alivecount -= 1;
	arr[x][y].neighbors[3].alivecount -= 1;
	arr[x][y].neighbors[4].alivecount -= 1;
	arr[x][y].neighbors[5].alivecount -= 1;
	arr[x][y].neighbors[6].alivecount -= 1;
	arr[x][y].neighbors[7].alivecount -= 1;
        if (range != 8) {
	arr[x][y].neighbors[8].alivecount -= 1;
	arr[x][y].neighbors[9].alivecount -= 1;
	arr[x][y].neighbors[10].alivecount -= 1;
	arr[x][y].neighbors[11].alivecount -= 1;
	arr[x][y].neighbors[12].alivecount -= 1;
	arr[x][y].neighbors[13].alivecount -= 1;
	arr[x][y].neighbors[14].alivecount -= 1;
	arr[x][y].neighbors[15].alivecount -= 1;
	arr[x][y].neighbors[16].alivecount -= 1;
	arr[x][y].neighbors[17].alivecount -= 1;
	arr[x][y].neighbors[18].alivecount -= 1;
	arr[x][y].neighbors[19].alivecount -= 1;
	arr[x][y].neighbors[20].alivecount -= 1;
	arr[x][y].neighbors[21].alivecount -= 1;
	arr[x][y].neighbors[22].alivecount -= 1;
	arr[x][y].neighbors[23].alivecount -= 1;

        }

       };
 
   

     if (pdecayval == undefined || pdecayval == 0) {   // pdecayval is an optional parameter.
           arr[x][y].color = pcolor;
           arr[x][y].decayval = 0;  
        } 
     else  {
           arr[x][y].color = decaygray;
           arr[x][y].decayval = pdecayval;
       }

    if (pextra == undefined || pcolor == background) {
           arr[x][y].extra = 0
           arr[x][y].placeholder_extra = 0  // this turns out to be necessary
       }
     else {
             arr[x][y].extra = pextra
             arr[x][y].placeholder_extra = pextra  // this turns out to be necessary
            
       }

  /* Commenting out this whole kludge block but such code will have to exist elsewhere

   // A Bx2 rule kludge.   Might want to have an optional parameter to send setcell information about .extra
  // if ((rulecode[pcolor] == 13) && pcolor != background)  {arr[x][y].extra = 2};

     // A Trilife and  Qbert and pentalife  and deltoid trihexagonal kites rule kludge -- will need an optional parameter to send setcell information about .extra
  if ((rulecode[pcolor] == 14 || rulecode[pcolor] == 15 || rulecode[pcolor] == 30 || rulecode[pcolor] == 17  || rulecode[pcolor] == 20  || rulecode[pcolor] == 21 || rulecode[pcolor] == 51) && pcolor != background){arr[x][y].extra = 31} 
  else if (rulecode[pcolor] == 18  && pcolor != background) {
            if (( arr[x][y].xpos % 2 == 0 &&  arr[x][y].ypos % 2 == 0) || ( arr[x][y].xpos % 2 == 1 &&  arr[x][y].ypos % 2 == 1)) {
                arr[x][y].extra = 2
             }
             else {arr[x][y].extra = 5}
   }
   

*/
 
  changedcells[changecount] = arr[x][y];
  changecount +=1;

  arr[x][y].message = "just changed";
 // if (pcolor != erase) {  // Hey!  Is this the right way?  should cells be removed from cellsinmotion?
     arr[x][y].Xspeed = pXspeed; 
     arr[x][y].Yspeed = pYspeed;

      arr[x][y].Xtally = 0;
      arr[x][y].Ytally = 0;
     if ((pXspeed != 0 || pYspeed != 0) && arr[x][y].physicsmessage != "listed") //contains(cellsinmotion, arr[x][y]) == false)
          {cellsinmotion.push(arr[x][y]);
           arr[x][y].physicsmessage = "listed";
          }; 
  // };
};

//var nlist = arr[x][y].neighbors
//for (var i=8; i--;) {nlist[i].alivecount = 



 
function IsNumeric(input) // this one is ok
{
   return (input - 0) == input && input.length > 0;
};



//-------------------------------------------------------------------

function drawPattern_decayRLE(pstring,x,y,xmirror,ymirror,zflip,pcolor, pXspeed, pYspeed){
 pstring = pstring.replace(/\$/g, "#$#");

 pstring = pstring.replace(/b/g, "#b#");
 pstring = pstring.replace(/o/g, "#o#");

// no doubt there is a better way to do this!
 pstring = pstring.replace(/A/g, "#A#");
 pstring = pstring.replace(/B/g, "#B#");
 pstring = pstring.replace(/C/g, "#C#");
 pstring = pstring.replace(/D/g, "#D#");
 pstring = pstring.replace(/E/g, "#E#");
 pstring = pstring.replace(/F/g, "#F#");
 pstring = pstring.replace(/G/g, "#G#");
 pstring = pstring.replace(/H/g, "#H#");
 pstring = pstring.replace(/I/g, "#I#");
 pstring = pstring.replace(/J/g, "#J#");
 pstring = pstring.replace(/K/g, "#K#");
 pstring = pstring.replace(/L/g, "#L#");
 pstring = pstring.replace(/M/g, "#M#");
 pstring = pstring.replace(/N/g, "#N#");
 pstring = pstring.replace(/O/g, "#O#");
 pstring = pstring.replace(/P/g, "#P#");
 pstring = pstring.replace(/Q/g, "#Q#");
 pstring = pstring.replace(/R/g, "#R#");
 pstring = pstring.replace(/S/g, "#S#");
 pstring = pstring.replace(/T/g, "#T#");
 pstring = pstring.replace(/U/g, "#U#");
 pstring = pstring.replace(/V/g, "#V#");
 pstring = pstring.replace(/W/g, "#W#");
 pstring = pstring.replace(/X/g, "#X#");
 pstring = pstring.replace(/Y/g, "#Y#");
 pstring = pstring.replace(/Z/g, "#Z#");



 pstring = pstring.replace(/\./g, "#.#");
 pstring = pstring.replace(/\*/g, "#*#");
 pstring = pstring.replace(/##/g, "#");
 pstring = pstring.split("#");
 var len = pstring.length;
//if (len == 1) // then this isn't an rle, just a modified life 1.05 format all contained in the first element.

 var i   = 0;
 var j   = 0;
 var r   = 0;
 for (var p=0;p<len;p++) {
   r = 1;

   if (IsNumeric(pstring[p]) == true)
     {  
       r = pstring[p]*1
       p++
      }; 

   if (pstring[p] == "." || pstring[p] == "b" ) 
     {for (var temp=0;temp<r;temp++)
        {
          if (pcolor == background) {  // the idea here is "or" with existing patterns instead of wiping them out, unless pcolor == erase
            if (zflip == true)  {setCell(x+(i*xmirror),y+(j*ymirror),background, pXspeed, pYspeed)}
            else   {setCell(x+(j*xmirror),y+(i*ymirror),background, pXspeed, pYspeed)};
          }
         i++;
        }; 
     }
   else if (pstring[p] == "*" || pstring[p] == "o" || pstring[p] == "A")
    if (uses_dot_extra[pcolor])  {
       for (var temp=0;temp<r;temp++)
        {
       
          if (zflip == true) {setCell(x+(i*xmirror),y+(j*ymirror),pcolor, pXspeed, pYspeed, 0,1)}
          else   {setCell(x+(j*xmirror),y+(i*ymirror),pcolor, pXspeed, pYspeed,0,  1)};

          i++;
       };
      }  
     else {
       for (var temp=0;temp<r;temp++)
        {
        
          if (zflip == true) {setCell(x+(i*xmirror),y+(j*ymirror),pcolor, pXspeed, pYspeed)}
          else   {setCell(x+(j*xmirror),y+(i*ymirror),pcolor, pXspeed, pYspeed)};

          i++;
       };
      }  
   else if (pstring[p].charCodeAt(0) > 65 && pstring[p].charCodeAt(0) < 91)      
      if (uses_dot_extra[pcolor])  {
       for (var temp=0;temp<r;temp++)
        {
       
          if (zflip == true) {setCell(x+(i*xmirror),y+(j*ymirror),pcolor, pXspeed, pYspeed, 0,pstring[p].charCodeAt(0) - 64)}
          else   {setCell(x+(j*xmirror),y+(i*ymirror),pcolor, pXspeed, pYspeed,0,  pstring[p].charCodeAt(0) - 64)};

          i++;
       };
      }  

      else {
       for (var temp=0;temp<r;temp++)
        {
       
          if (zflip == true) {setCell(x+(i*xmirror),y+(j*ymirror),decaygray, pXspeed, pYspeed, decayrule[pcolor] - (pstring[p].charCodeAt(0) - 66))}
          else   {setCell(x+(j*xmirror),y+(i*ymirror),decaygray, pXspeed, pYspeed,  decayrule[pcolor] - (pstring[p].charCodeAt(0) - 66))};

          i++;
       };
      }  
     
   else if (pstring[p] == "$")
      {for (var temp=0;temp<r;temp++)
        {

         i = 0;
         j++;
       };
      };
   };

 draw_only_changed_from_list ()
};


function drawPattern_normalRLE(pstring,x,y,xmirror,ymirror,zflip,pcolor, pXspeed, pYspeed){
 pstring = pstring.replace(/\$/g, "#$#");

 pstring = pstring.replace(/b/g, "#b#");
 pstring = pstring.replace(/o/g, "#o#");
 pstring = pstring.replace(/\./g, "#.#");
 pstring = pstring.replace(/\*/g, "#*#");
 pstring = pstring.replace(/##/g, "#");
 pstring = pstring.split("#");
 var len = pstring.length;
//if (len == 1) // then this isn't an rle, just a modified life 1.05 format all contained in the first element.

 var i   = 0;
 var j   = 0;
 var r   = 0;
 for (var p=0;p<len;p++) {
   r = 1;

   if (IsNumeric(pstring[p]) == true)
     {  
       r = pstring[p]*1
       p++
      }; 

   if (pstring[p] == "." || pstring[p] == "b" ) 
     {for (var temp=0;temp<r;temp++)
        {
         if (pcolor == background) {  // the idea here is "or" with existing patterns instead of wiping them out, unless pcolor == erase
            if (zflip == true) 
                   {setCell(x+(i*xmirror),y+(j*ymirror),background, pXspeed, pYspeed)}
            else   {setCell(x+(j*xmirror),y+(i*ymirror),background, pXspeed, pYspeed)};
         }
         i++;
        }; 
     }
   else if (pstring[p] == "*" || pstring[p] == "o")
     {for (var temp=0;temp<r;temp++)
        {

          if (zflip == true) 
                 {setCell(x+(i*xmirror),y+(j*ymirror),pcolor, pXspeed, pYspeed)}
          else   {setCell(x+(j*xmirror),y+(i*ymirror),pcolor, pXspeed, pYspeed)};

          i++;
       };
      }  
   else if (pstring[p] == "$")
      {for (var temp=0;temp<r;temp++)
        {

         i = 0;
         j++;
       };
      };
   };

 draw_only_changed_from_list ()
};



/*
1, 1, true = East down
1, -1, true = East up
-1, 1, true = West down
-1, -1, true = West up
1,1, false = South right
1, -1, false = North right  
-1, 1, false = South  left
-1, -1, false = North left
*/

function drawPattern_aux (pstring,x,y,xmirror,ymirror,zflip,pcolor, pXspeed, pYspeed){
   if (generations_rule[pcolor] == 1 || uses_dot_extra[pcolor] == 1) {
          drawPattern_decayRLE (pstring,x,y,xmirror,ymirror,zflip,pcolor, pXspeed, pYspeed)
   }
   else {
         drawPattern_normalRLE(pstring,x,y,xmirror,ymirror,zflip,pcolor, pXspeed, pYspeed)
   }
};
   

function drawPattern (pstring,x,y,orientation,pcolor, pXspeed, pYspeed){

  switch (orientation)
   {
    case "East down":
      drawPattern_aux(pstring, x,y,1,1,true,pcolor,pXspeed,pYspeed);
      break;
    case "East up":
      drawPattern_aux(pstring, x,y,1,-1,true,pcolor,pXspeed,pYspeed);
      break; 
    case "West down":
      drawPattern_aux(pstring, x,y,-1,1,true,pcolor,pXspeed,pYspeed);
      break; 
    case "West up":
      drawPattern_aux(pstring, x,y,-1,-1,true,pcolor,pXspeed,pYspeed);
      break; 
    case "South right":
      drawPattern_aux(pstring, x,y,1,1,false,pcolor,pXspeed,pYspeed);
      break; 
    case "North right":
      drawPattern_aux(pstring, x,y,1,-1,false,pcolor,pXspeed,pYspeed);
      break; 
    case "South left":
      drawPattern_aux(pstring, x,y,-1,1,false,pcolor,pXspeed,pYspeed);
      break; 
    case "North left":
      drawPattern_aux(pstring, x,y,-1,-1,false,pcolor,pXspeed,pYspeed);
      break; 
    default:
      drawPattern_aux(pstring, x,y,1,1,true,pcolor,pXspeed,pYspeed);
   };
};

function drawPatternInCenterByName (name, x,y,orientation,pcolor, pXspeed, pYspeed){
  var pstring = lifepatterns[name].patternstring;
  var xoffset = 0;
  var yoffset = 0;
  var xsize = lifepatterns[name].xsize;
  var ysize = lifepatterns[name].ysize 
  
     
  if (xsize != undefined) {xoffset = Math.floor(xsize /2)};
  if (ysize != undefined) {yoffset = Math.floor(ysize /2 )};
  

  switch (orientation)
   {
    case "East down":
      drawPattern_aux(pstring, x-xoffset,y-yoffset,1,1,true,pcolor,pXspeed,pYspeed);
      break;
    case "East up":
      drawPattern_aux(pstring, x-xoffset,y+yoffset,1,-1,true,pcolor,pXspeed,pYspeed);
      break; 
    case "West down":
      drawPattern_aux(pstring, x+xoffset,y-yoffset,-1,1,true,pcolor,pXspeed,pYspeed);
      break; 
    case "West up":
      drawPattern_aux(pstring, x+xoffset,y+yoffset,-1,-1,true,pcolor,pXspeed,pYspeed);
      break; 
    case "South right":
      drawPattern_aux(pstring, x-yoffset,y-xoffset,1,1,false,pcolor,pXspeed,pYspeed);
      break; 
    case "North right":
      drawPattern_aux(pstring,x-yoffset, y+xoffset,1,-1,false,pcolor,pXspeed,pYspeed);
      break; 
    case "South left":
      drawPattern_aux(pstring, x+yoffset,y-xoffset,-1,1,false,pcolor,pXspeed,pYspeed);  
      break; 
    case "North left":
      drawPattern_aux(pstring, x+yoffset,y+xoffset,-1,-1,false,pcolor,pXspeed,pYspeed);
      break; 
    default:
      alert("Hey!  Fell through to the default in drawPatternInCenterByName");
      drawPattern_aux(pstring, x,y,1,1,true,pcolor,pXspeed,pYspeed);
   };
};





 function changeBlock_aux(pattern, x, y, xmirror, ymirror, zflip,pcolor, pXspeed, pYspeed) {
  var xlen = lifepatterns[pattern].xsize;
  var ylen = lifepatterns[pattern].ysize;
   if (zflip == true) {
      for (var j = 0; Math.abs(j)<= ylen; j=j+1*ymirror) {
       for (var i=0; Math.abs(i)<= xlen; i=i+1*xmirror)   {
         setCell(x+i, y+j,pcolor, pXspeed, pYspeed)
       };
     }
  }
  else {
    for (var j = 0; Math.abs(j)<= ylen; j=j+1*ymirror) {
       for (var i=0; Math.abs(i)<= xlen; i=i+1*xmirror)   {
         setCell(x+j, y+i,pcolor, pXspeed, pYspeed)
       };
     }
   }
};

 
function changePatternArea (name,x,y,orientation,pcolor, pXspeed, pYspeed){
  var xoffset = 0;
  var yoffset = 0;
  
  if (lifepatterns[name].xsize != undefined) {xoffset = Math.floor(lifepatterns[name].xsize /2)};
  if (lifepatterns[name].ysize != undefined) {yoffset = Math.floor(lifepatterns[name].ysize /2 )};
  
  switch (orientation)
   {
    case "East down":
      changeBlock_aux(name, x-xoffset,y-yoffset,1,1,true,pcolor,pXspeed,pYspeed);
      break;
    case "East up":
      changeBlock_aux(name, x-xoffset,y+yoffset,1,-1,true,pcolor,pXspeed,pYspeed);
      break; 
    case "West down":
      changeBlock_aux(name, x+xoffset,y-yoffset,-1,1,true,pcolor,pXspeed,pYspeed);
      break; 
    case "West up":
      changeBlock_aux(name, x+xoffset,y+yoffset,-1,-1,true,pcolor,pXspeed,pYspeed);
      break; 
    case "South right":
      changeBlock_aux(name, x-yoffset,y-xoffset,1,1,false,pcolor,pXspeed,pYspeed);
      break; 
    case "North right":
      changeBlock_aux(name,x+yoffset, y-xoffset,1,-1,false,pcolor,pXspeed,pYspeed);
      break; 
    case "South left":
       changeBlock_aux(name, x-yoffset,y+xoffset,-1,1,false,pcolor,pXspeed,pYspeed);  
       break; 
    case "North left":
      changeBlock_aux(name, x+yoffset,y+xoffset,-1,-1,false,pcolor,pXspeed,pYspeed);
      break; 
    default:
      changeBlock_aux(name, x,y,1,1,true,pcolor,pXspeed,pYspeed);
   };
};

function erasePatternArea  (name,x,y,orientation,pcolor, pXspeed, pYspeed){
  changePatternArea(name,x,y,orientation,pcolor, pXspeed, pYspeed) // syntactic sugar
};

function setVelocityofCell(x, y, pcolor, pXspeed, pYspeed) {
   x = getborderXcoord(x);
   y = getborderYcoord(y);

  //arr[x][y].color = pcolor;
 // changedcells.push(arr[x][y]);

 if (arr[x][y].color != background) {  // Hey!  Is this the right way?  should cells be removed from cellsinmotion?
      arr[x][y].Xspeed = gCell.Xspeed; 
      arr[x][y].Yspeed = drivingCell.Yspeed;
     
      //arr[x][y].placeholder_Xspeed = drivingCell.Xspeed; //pXspeed; 
      //arr[x][y].placeholder_Yspeed = drivingCell.Yspeed;// pYspeed;

           arr[x][y].Xtally = drivingCell.Xspeed; //drivingCell.Xtally;
          arr[x][y].Ytally = drivingCell.Yspeed; //drivingCell.Ytally;   

       // arr[x][y].placeholder_Xtally = drivingCell.Xtally;
       // arr[x][y].placeholder_Ytally = drivingCell.Ytally;
     if ((pXspeed !=0 || pYspeed != 0)  && arr[x][y] != "listed") // contains(cellsinmotion, arr[x][y])== false)
       
       {cellsinmotion.push(arr[x][y]);
       arr[x][y].physicsmessage = "listed";
       }; 
    };
};
 
 function changeVelocityofBlock_aux(pattern, x, y, xmirror, ymirror, zflip,pcolor, pXspeed, pYspeed) {
  var xlen = lifepatterns[pattern].xsize;
  var ylen = lifepatterns[pattern].ysize;
   if (zflip == true) {
      for (var j = 0; Math.abs(j)<= ylen; j=j+1*ymirror) {
       for (var i=0; Math.abs(i)<= xlen; i=i+1*xmirror)   {
         setVelocityofCell(x+i, y+j,pcolor, pXspeed, pYspeed)
       };
     }
  }
  else {
    for (var j = 0; Math.abs(j)<= ylen; j=j+1*ymirror) {
       for (var i=0; Math.abs(i)<= xlen; i=i+1*xmirror)   {
         setVelocityofCell(x+j, y+i,pcolor, pXspeed, pYspeed)
       };
     }
   }
};


function changeVelocityArea (pstring,x,y,orientation,pcolor, pXspeed, pYspeed){
  switch (orientation)
   {
    case "East down":
      changeVelocityofBlock_aux(pstring, x,y,1,1,true,pcolor, pXspeed, pYspeed);
      break;
    case "East up":
       changeVelocityofBlock_aux(pstring, x,y,1,-1,true,pcolor, pXspeed, pYspeed);
      break; 
    case "West down":
       changeVelocityofBlock_aux(pstring, x,y,-1,1,true,pcolor, pXspeed, pYspeed);
      break; 
    case "West up":
      changeVelocityofBlock_aux(pstring, x,y,-1,-1,true,pcolor, pXspeed, pYspeed);
      break; 
    case "South right":
       changeVelocityofBlock_aux(pstring, x,y,1,1,false,pcolor, pXspeed, pYspeed);
      break; 
    case "North right":
       changeVelocityofBlock_aux(pstring, x,y,-1,1,false,pcolor, pXspeed, pYspeed);  // hack! used to be 1, -1
      break;  
    case "South left":
       changeVelocityofBlock_aux(pstring, x,y,1,-1,false,pcolor, pXspeed, pYspeed); // hack! used to be -1, 1
      break; 
    case "North left":
       changeVelocityofBlock_aux(pstring, x,y,-1,-1,false,pcolor, pXspeed, pYspeed);
      break; 
    default:
       changeVelocityofBlock_aux(pstring, x,y,1,1,true,pcolor, pXspeed, pYspeed);
   };
};


// ************* Driving *****************


// function cell(xpos, ypos, color, placeholder_color, kilroy_color, Xspeed, placeholder_Xspeed, Xtally, placeholder_Xtally, Yspeed, placeholder_Yspeed, Ytally, placeholder_Ytally)

/*
var drivingXpos = 150;
var drivingYpos = 150;
var drivingColor = blue;
var drivingInitialXspeed = 0;
var drivingInitialYspeed = 0;
*/

var drivingPattern =    "1234+Hat-experiment"; //"gosperglidergun"; ////"dragon";  // "Hat" // "basic grey ship"//"Hat"; // "1234+Hat"; // "schickship"; //  "ship from backrake";//"schickship" //"small_orion";//"ship from backrake";// "Queen Bee shuttles";  //"small_orion"; //"Quarter c/4 diag";//"ship from backrake"; // // "lwss";// "gosperglidergun"; //"Queen Bee shuttles"; // "schickship";// "backrake-js-p8"; //"ship from backrake"; //  "Queen Bee shuttles"; // "ship from backrake" ; // "lwssgun" ; //  "schickship" // "gosperglidergun"; //  //"gosperglidergun";

var drivingNaturalXspeed = lifepatterns[drivingPattern].naturalXspeed;
var drivingNaturalYspeed = lifepatterns[drivingPattern].naturalYspeed;
if (drivingNaturalXspeed == undefined) {drivingNaturalXspeed = 0};
if (drivingNaturalYspeed == undefined) {drivingNaturalYspeed = 0};

var drivingOrthogonalP = true;
if (Math.abs(drivingNaturalXspeed) > 0 && Math.abs(drivingNaturalYspeed) > 0) {drivingOrthogonalP = false} else {drivingOrthogonalP = true};

var velocity_stabilizer = "off";

var orthogonalBullet  = "Lightweight Ship c/2";
var diagonalBullet    = "Glider c/4 diag" ;



//var keynotpressed = true; // not used for now -- using arrowsok instead.
var arrowsok = true;


var orientation_index = 0;
var orientation_flip_index = 0;   

//var orientation_stack = [["East up", "East down", 1, -1] ,["South right","South left", -1,1]  ,["West down", "West up", 1, -1],["North left", "North right" , -1, 1]];
//var orientation_stack = [["East up", "East down", 1, -1] ,["South right","South left", -1,1]  ,["West down", "West up", 1, -1],["North left", "North right" , -1, 1]];

var orientation_stack = [["East up", "East down"] ,["South right","South left"]  ,["West down", "West up"],["North left", "North right" ]];



var drivingCell = new cell(100, 100, blue, blue,blue, 0, 0, 0, 0, 0, 0,0,0, "hi", "unlisted", [],0,0,0,0,0,0); 


// ******** Insert the drivable pattern here (until it is selected some other way, like by menu and mouse)
//  drawPatternInCenterByName(drivingPattern,drivingCell.xpos, drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index], drivingCell.color, drivingCell.Xspeed,drivingCell.Yspeed);

function restartDriving(patternchoice, x,y,orientchoice, colorchoice, x_vel,y_vel) {
    drivingPattern = patternchoice;
    drivingNaturalXspeed = lifepatterns[drivingPattern].naturalXspeed;
    drivingNaturalYspeed = lifepatterns[drivingPattern].naturalYspeed;
    if (drivingNaturalXspeed == undefined) {drivingNaturalXspeed = 0};
    if (drivingNaturalYspeed == undefined) {drivingNaturalYspeed = 0};
    
    if (Math.abs(drivingNaturalXspeed) > 0 && Math.abs(drivingNaturalYspeed) > 0) {
           drivingOrthogonalP = false
     }
     else {drivingOrthogonalP = true};
     arrowsok = true;


 switch(orientchoice) {
        case "East up":      
           orientation_index = 0; orientation_flip_index = 0; 
           drivingNaturalXspeed =  drivingNaturalXspeed*1;
           drivingNaturalYspeed =  drivingNaturalYspeed*-1;
           break;
        case "East down":  
           orientation_index = 0; orientation_flip_index = 1;      
           drivingNaturalXspeed =  drivingNaturalXspeed*1;
           drivingNaturalYspeed =  drivingNaturalYspeed*1;
           break;
        case "South right":    
           orientation_index = 1; orientation_flip_index = 0;    
           drivingNaturalXspeed =  drivingNaturalYspeed*1;
           drivingNaturalYspeed =  drivingNaturalXspeed*1;
           break;
        case "South left":  
           orientation_index = 1; orientation_flip_index = 1;     
           drivingNaturalXspeed =  drivingNaturalYspeed*-1;
           drivingNaturalYspeed =  drivingNaturalXspeed*1;
           break;
        case "West down": 
           orientation_index = 2; orientation_flip_index = 0;      
           drivingNaturalXspeed =  drivingNaturalXspeed*-1;
           drivingNaturalYspeed =  drivingNaturalYspeed*1;
           break;
        case "West up":  
           orientation_index = 2; orientation_flip_index = 1;     
           drivingNaturalXspeed =  drivingNaturalXspeed*-1;
           drivingNaturalYspeed =  drivingNaturalYspeed*-1;
           break;
        case "North left": 
           orientation_index = 3; orientation_flip_index = 0;      
           drivingNaturalXspeed =  drivingNaturalYspeed*-1;
           drivingNaturalYspeed =  drivingNaturalXspeed*-1;
           break;
        case "North right": 
           orientation_index = 3; orientation_flip_index = 1;      
           drivingNaturalXspeed =  drivingNaturalYspeed*1;
           drivingNaturalYspeed =  drivingNaturalXspeed*-1;
           break;
        };




     cxt.fillStyle = brown; 
     cxt.fillRect(drivingCell.xpos*magnification, drivingCell.ypos*magnification, magnification, magnification)

     drivingCell.xpos = x;
     drivingCell.ypos = y;
     drivingCell.color = colorchoice;
     drivingCell.Xspeed = x_vel;
     drivingCell.Yspeed = y_vel;

     if (velocity_stabilizer == "on") {
          drivingCell.Yspeed = drivingCell.Yspeed - drivingNaturalYspeed;       
          drivingCell.Xspeed = drivingCell.Xspeed -  drivingNaturalXspeed;
          };


     if (Math.abs(drivingNaturalXspeed) > 0 && Math.abs(drivingNaturalYspeed) > 0) {drivingOrthogonalP = false} else {drivingOrthogonalP = true};

     drawPatternInCenterByName(drivingPattern, x, y,orientation_stack[orientation_index][orientation_flip_index], colorchoice, drivingCell.Xspeed, drivingCell.Yspeed);
     document.getElementById("info_message2").innerHTML="X vel: " + drivingCell.Xspeed.toFixed(2) + "  Y vel:  " + drivingCell.Yspeed.toFixed(2)+ "  Velocity Stabilization:  " + velocity_stabilizer;


};

     



function resetArrows(ev) {
  //arrowsok = true;
 //  var arrows=ev.keyCode;
// switch(arrows) {
//   case 37: 
  //   keynotpressed = true;
   //  break;
 //  }
}


function getArrows(ev) {
 ev.preventDefault();  //  <-- this disables the normal scrolling effect that the arrow keys usually have
 if ( arrowsok) {
  //arrows=((ev.which)||(ev.keyCode));
 var arrows=ev.keyCode;

  switch(arrows) {

   case 13: // Enter key
     doTimer();
     break;

   case 37: // Left Arrow
     // keynotpressed = false;
    // arrowsok = false;
  if (select_clicks == 2) {nudge_selection(-1,0)} else {
    erasePatternArea(drivingPattern,drivingCell.xpos, drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],erase, drivingCell.Xspeed,drivingCell.Yspeed);

  if (velocity_stabilizer == "on") {
          drivingCell.Yspeed = drivingCell.Yspeed + drivingNaturalYspeed;      
          drivingCell.Xspeed = drivingCell.Xspeed +  drivingNaturalXspeed;
          };



  if (lifepatterns[drivingPattern].diagonalcounterpart != undefined) {
         drivingPattern = lifepatterns[drivingPattern].diagonalcounterpart;
        if (orientation_flip_index == 0) {
          if (drivingOrthogonalP == false) {
            drivingOrthogonalP = true
            orientation_index = orientation_index - 1;
            if (orientation_index > 3) {orientation_index = 0}
              else if (orientation_index < 0) {orientation_index = 3}; 
          } 
          else {drivingOrthogonalP = false}
       }
       else if (orientation_flip_index == 1) {
            if (drivingOrthogonalP == true) {
            drivingOrthogonalP = false
            orientation_index = orientation_index - 1;
            if (orientation_index > 3) {orientation_index = 0}
              else if (orientation_index < 0) {orientation_index = 3}; 
          } 
          else {drivingOrthogonalP = true}
         }
     } 
    else {
        orientation_index = orientation_index - 1;
        if (orientation_index > 3) {orientation_index = 0}
           else if (orientation_index < 0) {orientation_index = 3}; 
    };






      switch(orientation_stack[orientation_index][orientation_flip_index]) {
        case "East up":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalXspeed*1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalYspeed*-1;
           break;
        case "East down":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalXspeed*1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalYspeed*1;
           break;
        case "South right":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalYspeed*1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalXspeed*1;
           break;
        case "South left":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalYspeed*-1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalXspeed*1;
           break;
        case "West down":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalXspeed*-1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalYspeed*1;
           break;
        case "West up":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalXspeed*-1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalYspeed*-1;
           break;
        case "North left":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalYspeed*-1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalXspeed*-1;
           break;
        case "North right":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalYspeed*1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalXspeed*-1;
           break;
        };

  if (velocity_stabilizer == "on") {
          drivingCell.Yspeed = drivingCell.Yspeed - drivingNaturalYspeed;       
          drivingCell.Xspeed = drivingCell.Xspeed -  drivingNaturalXspeed; 
          };

 


      drawPatternInCenterByName(drivingPattern,drivingCell.xpos, drivingCell.ypos,orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, drivingCell.Xspeed,drivingCell.Yspeed);

// TEMPORARY driving cell visible for debugging purposes....
      cxt.fillStyle = drivingCell.color; 
      cxt.fillRect(drivingCell.xpos*magnification, drivingCell.ypos*magnification, magnification, magnification)


document.getElementById("info_message2").innerHTML="X vel: " + drivingCell.Xspeed.toFixed(2) + "  Y vel:  " + drivingCell.Yspeed.toFixed(2)+ "  Velocity Stabilization:  " + velocity_stabilizer;


      } // end of else from the line regarding nudge_selection(x,y)
     break;
   
 case 39:  // Right Arrow key
 if (select_clicks == 2) {nudge_selection(1,0)} else {
     erasePatternArea(drivingPattern,drivingCell.xpos, drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],erase, drivingCell.Xspeed,drivingCell.Yspeed);

     if (velocity_stabilizer == "on") {
          drivingCell.Yspeed = drivingCell.Yspeed + drivingNaturalYspeed;      
          drivingCell.Xspeed = drivingCell.Xspeed +  drivingNaturalXspeed;
          };


  if (lifepatterns[drivingPattern].diagonalcounterpart != undefined) {
         drivingPattern = lifepatterns[drivingPattern].diagonalcounterpart;
        if (orientation_flip_index == 0) {
          if (drivingOrthogonalP == true) {
            drivingOrthogonalP = false
            orientation_index = orientation_index + 1;
            if (orientation_index > 3) {orientation_index = 0}
              else if (orientation_index < 0) {orientation_index = 3}; 
          } 
          else {drivingOrthogonalP = true}
       }
       else if (orientation_flip_index == 1) {
            if (drivingOrthogonalP == false) {
            drivingOrthogonalP = true
            orientation_index = orientation_index + 1;
            if (orientation_index > 3) {orientation_index = 0}
              else if (orientation_index < 0) {orientation_index = 3}; 
          } 
          else {drivingOrthogonalP = false}
         }
     } 
    else {
        orientation_index = orientation_index + 1;
        if (orientation_index > 3) {orientation_index = 0}
           else if (orientation_index < 0) {orientation_index = 3}; 
    };
   


 





      switch(orientation_stack[orientation_index][orientation_flip_index]) {
        case "East up":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalXspeed*1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalYspeed*-1;
           break;
        case "East down":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalXspeed*1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalYspeed*1;
           break;
        case "South right":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalYspeed*1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalXspeed*1;
           break;
        case "South left":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalYspeed*-1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalXspeed*1;
           break;
        case "West down":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalXspeed*-1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalYspeed*1;
           break;
        case "West up":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalXspeed*-1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalYspeed*-1;
           break;
        case "North left":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalYspeed*-1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalXspeed*-1;
           break;
        case "North right":       
           drivingNaturalXspeed =  lifepatterns[drivingPattern].naturalYspeed*1;
           drivingNaturalYspeed =  lifepatterns[drivingPattern].naturalXspeed*-1;
           break;
        };

      if (velocity_stabilizer == "on") {
          drivingCell.Yspeed = drivingCell.Yspeed - drivingNaturalYspeed;       
          drivingCell.Xspeed = drivingCell.Xspeed -  drivingNaturalXspeed; 
          };


      drawPatternInCenterByName(drivingPattern,drivingCell.xpos, drivingCell.ypos,orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, drivingCell.Xspeed,drivingCell.Yspeed);

// TEMPORARY driving cell visible for debugging purposes....
      cxt.fillStyle = drivingCell.color; 
      cxt.fillRect(drivingCell.xpos*magnification, drivingCell.ypos*magnification, magnification, magnification)


document.getElementById("info_message2").innerHTML="X vel: " + drivingCell.Xspeed.toFixed(2) + "  Y vel:  " + drivingCell.Yspeed.toFixed(2)+ "  Velocity Stabilization:  " + velocity_stabilizer;
 
   } // end of else from the line regarding nudge_selection(x,y)

     break;
    
     case 77:  // m key  -- m is for mirror
      if ( drivingOrthogonalP) {
       erasePatternArea(drivingPattern,drivingCell.xpos, drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],erase, drivingCell.Xspeed,drivingCell.Yspeed);


      if (orientation_flip_index == 0) {orientation_flip_index = 1} else {orientation_flip_index = 0};
 
        drawPatternInCenterByName(drivingPattern,drivingCell.xpos, drivingCell.ypos,orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, drivingCell.Xspeed,drivingCell.Yspeed);
      };
      break;

  // case 18: // option key -- identical to the m key, good for macs.
  //    copy code for m key here
  //    break;

     case 16: // shift key
       //  it would be good to have a message indicating velocity-stabiliztoin on or off 
     erasePatternArea(drivingPattern,drivingCell.xpos, drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],erase, drivingCell.Xspeed,drivingCell.Yspeed);

     if (velocity_stabilizer == "off") {
         velocity_stabilizer = "on";
         drivingCell.Yspeed = drivingCell.Yspeed - drivingNaturalYspeed;       
         drivingCell.Xspeed = drivingCell.Xspeed -  drivingNaturalXspeed; 
     }  else {
         velocity_stabilizer = "off";
         drivingCell.Yspeed = drivingCell.Yspeed + drivingNaturalYspeed;       
         drivingCell.Xspeed = drivingCell.Xspeed +  drivingNaturalXspeed; 

         };

     drawPatternInCenterByName(drivingPattern,drivingCell.xpos, drivingCell.ypos,orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, drivingCell.Xspeed,drivingCell.Yspeed);

     document.getElementById("info_message2").innerHTML="X vel: " + drivingCell.Xspeed.toFixed(2) + "  Y vel:  " + drivingCell.Yspeed.toFixed(2) + "  Velocity Stabilization:  " + velocity_stabilizer;

     break;

   case 38: // Up arrow
    if (select_clicks == 2) {nudge_selection(0,-1)} else {

     erasePatternArea(drivingPattern,drivingCell.xpos, drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],erase, drivingCell.Xspeed,drivingCell.Yspeed);



         var speed_offset = .1;
         var roundDecimalPlaces = 2;

      switch(orientation_stack[orientation_index][orientation_flip_index]) {
        case "East up": 
          drivingCell.Xspeed =  roundNumber(drivingCell.Xspeed + speed_offset, roundDecimalPlaces);
          if (!(drivingOrthogonalP)) {
            drivingCell.Yspeed =  roundNumber(drivingCell.Yspeed - speed_offset, roundDecimalPlaces);};

           break;
        case "East down":       
          drivingCell.Xspeed =  roundNumber(drivingCell.Xspeed + speed_offset, roundDecimalPlaces);
          if (!(drivingOrthogonalP)) {
            drivingCell.Yspeed =  roundNumber(drivingCell.Yspeed + speed_offset, roundDecimalPlaces);};


           break;
        case "South right":       
           drivingCell.Yspeed = roundNumber(drivingCell.Yspeed + speed_offset, roundDecimalPlaces);
           if (!(drivingOrthogonalP)) {
              drivingCell.Xspeed =  roundNumber(drivingCell.Xspeed + speed_offset, roundDecimalPlaces);};


           break;
        case "South left":       
           drivingCell.Yspeed = roundNumber(drivingCell.Yspeed + speed_offset, roundDecimalPlaces);
          if (!(drivingOrthogonalP)) {
            drivingCell.Xspeed =  roundNumber(drivingCell.Xspeed - speed_offset, roundDecimalPlaces);};


           break;
        case "West down":       
           drivingCell.Xspeed = roundNumber(drivingCell.Xspeed - speed_offset,roundDecimalPlaces);
          if (!(drivingOrthogonalP)) {
            drivingCell.Yspeed =  roundNumber(drivingCell.Yspeed + speed_offset, roundDecimalPlaces);};


           break;
        case "West up":       
           drivingCell.Xspeed = roundNumber(drivingCell.Xspeed - speed_offset, roundDecimalPlaces);
          if (!(drivingOrthogonalP)) {
            drivingCell.Yspeed =  roundNumber(drivingCell.Yspeed - speed_offset, roundDecimalPlaces);};


           break;
        case "North left":       
           drivingCell.Yspeed = roundNumber(drivingCell.Yspeed - speed_offset, roundDecimalPlaces);
          if (!(drivingOrthogonalP)) {
            drivingCell.Xspeed =  roundNumber(drivingCell.Xspeed - speed_offset, roundDecimalPlaces);};


           break;
        case "North right":       
           drivingCell.Yspeed = roundNumber(drivingCell.Yspeed - speed_offset, roundDecimalPlaces);
          if (!(drivingOrthogonalP)) {
            drivingCell.Xspeed =  roundNumber(drivingCell.Xspeed + speed_offset, roundDecimalPlaces);};


           break;        
       };
//erasePattern(drivingPattern,drivingCell.xpos,drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],drivingColor, drivingCell.Xspeed,drivingCell.Yspeed);
      

       drivingCell.Xtally = 0;
       drivingCell.Ytally = 0;


 drawPatternInCenterByName(drivingPattern,drivingCell.xpos, drivingCell.ypos,orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, drivingCell.Xspeed,drivingCell.Yspeed);


  //  changeVelocityArea (drivingPattern,drivingCell.xpos,drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],drivingColor, drivingCell.Xspeed,drivingCell.Yspeed);

     document.getElementById("info_message2").innerHTML="X vel: " + drivingCell.Xspeed.toFixed(2) + "  Y vel:  " + drivingCell.Yspeed.toFixed(2)+ "  Velocity Stabilization:  " + velocity_stabilizer;

   }  // end of else from the line regarding nudge_selection(x,y)
     break;
  
   case 40:  // Down Arrow  // one idea is to use a smaller increment for the down arrow.
       if (select_clicks == 2) {nudge_selection(0,1)} else {
         erasePatternArea(drivingPattern,drivingCell.xpos, drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],erase, drivingCell.Xspeed,drivingCell.Yspeed);
   
         var speed_offset = roundNumber(.01, 2)
         var roundDecimalPlaces = 2;


      switch(orientation_stack[orientation_index][orientation_flip_index]) {
        case "East up": 
          drivingCell.Xspeed =  roundNumber(drivingCell.Xspeed - speed_offset, roundDecimalPlaces);
          if (!(drivingOrthogonalP)) {
              drivingCell.Yspeed =  roundNumber(drivingCell.Yspeed + speed_offset, roundDecimalPlaces);};


                      break;
        case "East down":       
           drivingCell.Xspeed = roundNumber(drivingCell.Xspeed - speed_offset, roundDecimalPlaces); 
           if (!(drivingOrthogonalP)) {
                 drivingCell.Yspeed =  roundNumber(drivingCell.Yspeed - speed_offset, roundDecimalPlaces);};

           break;
        case "South right":       
           drivingCell.Yspeed = roundNumber(drivingCell.Yspeed - speed_offset, roundDecimalPlaces);
           if (!(drivingOrthogonalP)) {
              drivingCell.Xspeed =  roundNumber(drivingCell.Xspeed - speed_offset, roundDecimalPlaces);};


           break;
        case "South left":       
           drivingCell.Yspeed = roundNumber(drivingCell.Yspeed - speed_offset, roundDecimalPlaces);
           if (!(drivingOrthogonalP)) {
               drivingCell.Xspeed =  roundNumber(drivingCell.Xspeed + speed_offset, roundDecimalPlaces);};


           break;
        case "West down":       
           drivingCell.Xspeed = roundNumber(drivingCell.Xspeed + speed_offset, roundDecimalPlaces);
            if (!(drivingOrthogonalP)) {
               drivingCell.Yspeed =  roundNumber(drivingCell.Yspeed - speed_offset, roundDecimalPlaces);};
 

           break;
        case "West up":       
           drivingCell.Xspeed = roundNumber(drivingCell.Xspeed + speed_offset, roundDecimalPlaces);
           if (!(drivingOrthogonalP)) {
                drivingCell.Yspeed =  roundNumber(drivingCell.Yspeed + speed_offset, roundDecimalPlaces);};


           break;
        case "North left":       
           drivingCell.Yspeed = roundNumber(drivingCell.Yspeed + speed_offset, roundDecimalPlaces);
           if (!(drivingOrthogonalP)) {
               drivingCell.Xspeed =  roundNumber(drivingCell.Xspeed + speed_offset, roundDecimalPlaces);};


           break;
        case "North right":       
           drivingCell.Yspeed = roundNumber(drivingCell.Yspeed + speed_offset, roundDecimalPlaces);
           if (!(drivingOrthogonalP)) {
               drivingCell.Xspeed =  roundNumber(drivingCell.Xspeed - speed_offset, roundDecimalPlaces);};


           break;        
       };
//erasePattern(drivingPattern,drivingCell.xpos,drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],drivingColor, drivingCell.Xspeed,drivingCell.Yspeed);
      

       drivingCell.Xtally = 0;
       drivingCell.Ytally = 0;


 drawPatternInCenterByName(drivingPattern,drivingCell.xpos, drivingCell.ypos,orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, drivingCell.Xspeed,drivingCell.Yspeed);


  //  changeVelocityArea (drivingPattern,drivingCell.xpos,drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],drivingColor, drivingCell.Xspeed,drivingCell.Yspeed);

     document.getElementById("info_message2").innerHTML="X vel: " + drivingCell.Xspeed.toFixed(2) + "  Y vel:  " + drivingCell.Yspeed.toFixed(2)+ "  Velocity Stabilization:  " + velocity_stabilizer;

   }  // end of else from the line regarding nudge_selection(x,y)

     break;


   case 32: // Shooting with the space bar
     
    if (lifepatterns[drivingPattern].counterpart != undefined) {
      
       erasePatternArea(drivingPattern,drivingCell.xpos, drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],erase, 0,0);

        
       drivingPattern = lifepatterns[drivingPattern].counterpart;
        //drivingCell.Xtally = 0;
       // drivingCell.Ytally = 0;



    
       drawPatternInCenterByName(drivingPattern,drivingCell.xpos, drivingCell.ypos,orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, drivingCell.Xspeed,drivingCell.Yspeed);
     
    } 
     else if (lifepatterns[drivingPattern].momentary_counterpart != undefined) {
         erasePatternArea(drivingPattern,drivingCell.xpos, drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],erase, 0,0);
 
       var tempdrivingPattern = lifepatterns[drivingPattern].momentary_counterpart;
        drawPatternInCenterByName(tempdrivingPattern,drivingCell.xpos, drivingCell.ypos,orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, drivingCell.Xspeed,drivingCell.Yspeed);
      }
     else { // insert independent bullet
        var bulletXspeed = drivingCell.Xspeed;
        var bulletYspeed = drivingCell.Yspeed;
       if (velocity_stabilizer == "on") {  
            // then cancel the velocity-stabilization effect for the bullet, so that a c/2 bullet will travel away from a velocity cancelled c/2 spacecraft.

          //  NOTE:  it was interesting to see what happened when the if clause was removed, so that the following two lines executed regardless of whether velocity_stabilization was on.
          //  Another thing to try would be to add the bullet's natural speed to itself.  The bullet pattern would need to be known, so move the code down after orthogonalP is decided.
         

           bulletXspeed = bulletXspeed + drivingNaturalXspeed;
           bulletYspeed = bulletYspeed + drivingNaturalYspeed;
          };
      

// Note that it fundamentally makes no sense that the bullet speed would be tied to the natural speed of the ship, and not to the bullet itself.   
//  replace "4" with "bulletMultiplier" and when physicsOn == false, let bulletMultiplier = 1
          //var bulletMultiplier = 1;
       
           //bulletXspeed = bulletXspeed + bulletMultiplier*drivingNaturalXspeed;
          // bulletYspeed = bulletYspeed + bulletMultiplier*drivingNaturalYspeed;

        switch(orientation_stack[orientation_index][orientation_flip_index]) {
          case "East up": 
           if (drivingOrthogonalP) {
 // "Lightweight Ship c/2"
            drawPatternInCenterByName( orthogonalBullet, drivingCell.xpos + Math.floor(lifepatterns[drivingPattern].xsize/2) + 4, drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color,bulletXspeed,bulletYspeed);
            }
           else { // if diagonal then shoot a glider instead
             drawPatternInCenterByName(diagonalBullet, drivingCell.xpos + Math.floor(lifepatterns[drivingPattern].xsize/2) +2 , drivingCell.ypos - Math.ceil(lifepatterns[drivingPattern].ysize/2) -2, orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, bulletXspeed,bulletYspeed); 
              };
           break;
        case "East down":   
          if (drivingOrthogonalP) {
            drawPatternInCenterByName(orthogonalBullet, drivingCell.xpos + Math.floor(lifepatterns[drivingPattern].xsize/2) + 4, drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color,bulletXspeed,bulletYspeed);
            }
           else { // if diagonal then shoot a glider instead
             drawPatternInCenterByName(diagonalBullet, drivingCell.xpos + Math.floor(lifepatterns[drivingPattern].xsize/2) +2 , drivingCell.ypos + Math.floor(lifepatterns[drivingPattern].ysize/2) +2 , orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, bulletXspeed,bulletYspeed); 
                 };  
         break;  
        case "South right":       
            if (drivingOrthogonalP) {
            drawPatternInCenterByName(orthogonalBullet, drivingCell.xpos, drivingCell.ypos+ lifepatterns[drivingPattern].ysize +6  , orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color,bulletXspeed,bulletYspeed);
            }
           else { // if diagonal then shoot a glider instead
             drawPatternInCenterByName(diagonalBullet, drivingCell.xpos + Math.floor(lifepatterns[drivingPattern].xsize/2) +2 , drivingCell.ypos + Math.floor(lifepatterns[drivingPattern].ysize/2)+2, orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, bulletXspeed,bulletYspeed); 
                 };

           break;

        case "South left":       
          if (drivingOrthogonalP) {
            drawPatternInCenterByName("Lightweight Ship c/2", drivingCell.xpos, drivingCell.ypos+ lifepatterns[drivingPattern].ysize +6  , orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color,bulletXspeed,bulletYspeed);
            }
           else { // if diagonal then shoot a glider instead
             drawPatternInCenterByName(diagonalBullet, drivingCell.xpos -Math.floor(lifepatterns[drivingPattern].xsize/2) -2 , drivingCell.ypos + Math.floor(lifepatterns[drivingPattern].ysize/2) +2, orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, bulletXspeed,bulletYspeed); 
                 };

           break;

        case "West down":       
            if (drivingOrthogonalP) {
            drawPatternInCenterByName(orthogonalBullet, drivingCell.xpos - Math.floor(lifepatterns[drivingPattern].xsize/2) - 4, drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color,bulletXspeed,bulletYspeed);
            }
           else { // if diagonal then shoot a glider instead
             drawPatternInCenterByName(diagonalBullet, drivingCell.xpos - Math.floor(lifepatterns[drivingPattern].xsize/2) -2 , drivingCell.ypos + Math.floor(lifepatterns[drivingPattern].ysize/2) +3, orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, bulletXspeed,bulletYspeed); 
                 }; 
 

           break;
        case "West up":       
           if (drivingOrthogonalP) {
            drawPatternInCenterByName(orthogonalBullet, drivingCell.xpos - Math.floor(lifepatterns[drivingPattern].xsize/2) - 4, drivingCell.ypos, orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color,bulletXspeed,bulletYspeed);
            }
           else { // if diagonal then shoot a glider instead
             drawPatternInCenterByName(diagonalBullet, drivingCell.xpos - Math.floor(lifepatterns[drivingPattern].xsize/2) -2 , drivingCell.ypos - Math.ceil(lifepatterns[drivingPattern].ysize/2) -2, orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, bulletXspeed,bulletYspeed); 
              };

           break;
        case "North left":       
          if (drivingOrthogonalP) {
            drawPatternInCenterByName(orthogonalBullet, drivingCell.xpos, drivingCell.ypos- lifepatterns[drivingPattern].ysize - 4  , orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color,bulletXspeed,bulletYspeed);
            }
           else { // if diagonal then shoot a glider instead
             drawPatternInCenterByName(diagonalBullet, drivingCell.xpos -Math.floor(lifepatterns[drivingPattern].xsize/2) -2 , drivingCell.ypos - Math.ceil(lifepatterns[drivingPattern].ysize/2) - 2, orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, bulletXspeed,bulletYspeed); 
                 };

           break;
        case "North right":       
            if (drivingOrthogonalP) {
            drawPatternInCenterByName("Lightweight Ship c/2", drivingCell.xpos, drivingCell.ypos- lifepatterns[drivingPattern].ysize - 4  , orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color,bulletXspeed,bulletYspeed);
            }
           else { // if diagonal then shoot a glider instead
             drawPatternInCenterByName(diagonalBullet, drivingCell.xpos +Math.floor(lifepatterns[drivingPattern].xsize/2) +2 , drivingCell.ypos - Math.ceil(lifepatterns[drivingPattern].ysize/2) -2, orientation_stack[orientation_index][orientation_flip_index],  drivingCell.color, bulletXspeed,bulletYspeed); 
                 };
           break;  
    
     }   //end switch
       }; //end main if for shooting code

  };  //end outermost switch to determine which key was pressed
  }; // end if arrowsok
  return false;
};

function doDriving () {
   var xn = 0;
   var yn = 0;
   var xoffset = 0;
   var yoffset = 0;


// TEMPORARY driving cell visible for debugging purposes....
// To do: should also check to see if drivingCell.Xspeed and drivigCell.Yspeed are both not zero 
/*
 if (arr[drivingCell.xpos][drivingCell.ypos].color !=background) {
              cxt.fillStyle = arr[drivingCell.xpos][drivingCell.ypos].color; 

              cxt.fillRect(drivingCell.xpos*magnification, drivingCell.ypos*magnification, magnification, magnification);
          }
          else {
              cxt.clearRect(drivingCell.xpos*magnification, drivingCell.ypos*magnification, magnification, magnification);
          };
*/

  // these could be preceded by an if regarding drivingCell.Xspeed 

   drivingCell.Xtally += drivingCell.Xspeed +drivingNaturalXspeed;
   drivingCell.Ytally += drivingCell.Yspeed +drivingNaturalYspeed;

   drivingCell.Xtally = roundNumber(drivingCell.Xtally, 8); // ******** Round Off Error Problem *********
   drivingCell.Ytally = roundNumber(drivingCell.Ytally, 8); 

               if (drivingCell.Xtally >=0) 
                    {xoffset=Math.floor( drivingCell.Xtally)}
               else {xoffset=Math.ceil( drivingCell.Xtally)};


               if (drivingCell.Ytally >=0)                   
                    {yoffset=Math.floor( drivingCell.Ytally)}
               else {yoffset=Math.ceil( drivingCell.Ytally)};
 
               xn = drivingCell.xpos + xoffset;
               yn = drivingCell.ypos + yoffset;  
               
               if (xn < 0 || xn >memoryX-1) {xn =  getborderXcoord(xn)};
               if (yn < 0 || yn>memoryY-1) {yn = getborderYcoord(yn)};


               drivingCell.xpos = xn;
               drivingCell.ypos = yn;


// TEMPORARY driving cell visible for debugging purposes....

//  To do:  check to see if drivingCell.Xspeed and drivigCell.Yspeed are both not zero
/*
      cxt.fillStyle = drivingCell.color; 
      cxt.fillRect(drivingCell.xpos*magnification, drivingCell.ypos*magnification, magnification, magnification)

*/
               if (Math.abs(drivingCell.Xtally) >= 1) {
                     drivingCell.Xtally = drivingCell.Xtally - xoffset
                };

               if (Math.abs(drivingCell.Ytally) >= 1) {
                     drivingCell.Ytally = drivingCell.Ytally - yoffset                
                };
};


/* To do:  doDriving which updates drivingCell and other variables for each generation - reuse doPhysics code but simplify because no placeholders are necessary -- the cell only updates itself.  
           make a stack of orientations so that the stack can be shifted and popped, just like the colors in colored pencil 
           move the drawing code above the driving code if draw/insert with the mouse is used to get a driveable pattern started.
           reference natural speed + induced speed = actual speed.   But where?  at initialization only?  induced speed changes via upkey

*/

// ********* End of Driving section ***********



//drawPatternInCenterByName("Star Wars test", 100, 100,"East up", yellow, 0, 0);

// *****draw a horizontal line at the halfway mark in memory *****
 
/*
for (var i=memoryX/4, j=memoryY/2;i<memoryX*3/4; i++) 
   {arr[i][j].color = blue;
   changedcells.push(arr[i][j]);
   arr[i][j].message = "just changed";
   };
*/
/*
for (var i=0, j=memoryY/2;i<memoryX; i++) 
   {arr[i][j].color = yellow;
   changedcells.push(arr[i][j]);
      arr[i][j].message = "just changed";

   };
*/




 // GliderGunHorizontalDownLeft(50,200, red);

//draw();
  document.getElementById("info_message").innerHTML="changedcell list length: " + changedcells.length + " Generation: " + generation;




// Reusing Timer code to keep the game running

var t;
var timer_is_on=0; // this has nothing to do with actually timing anything - this is just "timer code" reuse.
var startdate = 0;  // this has nothing to do with "timer code" -- this is actually timing the program!
                    // we'll call it dating the program for clarity, (the non-romantic kind of dating).
var stopdate = 0;
var elapsed = 0;
//nested_refresh() or refresh()

var debug2 = 0;

var speedstep = 3;

function timedCount () // (rulefunction)
{ 


   arrowsok = false;

   // for (var ij=0; ij<speedstep; ij++)

for (var ij=speedstep; ij--;) {   

     doDriving();

     if (cellsinmotion.length ) {
             physicsOn = 1;
           // superluminal_reckless_doPhysics();  // ****** check to make sure all cells are delisted
       } 
      else {physicsOn = 0};   

// Thhe above line doesn't entirely make sense -- it mixes two ideas -- the idea of a user toggle for physicsOn and auto-detecting when there are no cells in motion so that VelocityBirth isn't triggered.  This will have to be sorted out later.  

 superluminal_reckless_doPhysics();    // ******* could be superceded by the above line on a trial basis
  
  // reckless_doPhysics();
  //doPhysics();
 draw_only_changed_from_list ();
  //drawfunction();
   
   //--commented for 33 --
 //draw_only_changed_from_list(cellsinmotion);

  


   

 

//debug2 = changedcells.length;

  //if (generation < 200 || generation >400) {document.getElementById("info_message").innerHTML="changed cell list length: " + debug2 + " Generation: " + generation;};

  if (generation == 0)   {startdate = new Date().getTime();}

  if (generation == 1000)  // 17331 for rabbits
      {
        stopdate = new Date().getTime();
        elapsed = stopdate - startdate;
        document.getElementById("info_message").innerHTML="changedcell list length: " + changedcells.length +"............"+ "Time at stop clock = " +  elapsed;
       };



    //geared_refresh(4500);  //use 700 // 600 best?
    //  commented out just for beezero 

     //  nested_refresh3(rulefunction);   
     //  beezero_refresh(rulefunction);
     //  refresh(rulefunction);


   // nested_refresh3();
   refresh(); 

    generation += 1; 
    oddgeneration_p = (generation % 2);


 } // this ends the for loop before the setTimeout
    
    //t=setTimeout(timedCount,0);

    arrowsok = true;

};

var theRuleInUse =  con1doLifeRuleToCell2;  //BeeZeroRule;  //con1doLifeRuleToCell2;                  // HighLifeRule;
//var theDrawFunction = draw_only_changed_from_list ();

function doTimer()
{
if (!timer_is_on)
  {
  document.getElementById("gobutton").value = "Stop";
  //document.controlform.value ="Stop";

 // startdate = new Date().getTime();
   // if (generation == 0)   {
     //                       document.getElementById("info_message").innerHTML="changedcell list length: " + changedcells.length + "Time  =  0";
     //                       startdate = new Date().getTime();
     //  }

  timer_is_on=1;
  //timedCount();  // Use this line with setTimeout
  //t=setInterval(function () {timedCount(theRuleInUse); },delay);
    t=setInterval(timedCount,delay);


  }
else
  {stopCount();
    } 

};

function stopCount()
{
 //clearTimeout(t);
  clearInterval(t);
timer_is_on=0;
document.getElementById("gobutton").value = "Go";
//document.controlform.gobutton.value ="Go";

};

function stepCount() {
  stopCount();
  
  draw_only_changed_from_list ();
   arrowsok = false;
    doDriving();
  superluminal_reckless_doPhysics();

   draw_only_changed_from_list ();
  

//debug2 = changedcells.length;

//  if (generation < 200 || generation >400) {document.getElementById("info_message").innerHTML="changed cell list length: " + debug2 + " Generation: " + generation;};

/*
  if (generation == 200) 
      {
        stopdate = new Date().getTime();
        elapsed = stopdate - startdate;
        document.getElementById("info_message").innerHTML="changedcell list length: " + debug2 + "Time at stop clock = " + elapsed;
       };
*/
   // geared_refresh(4500);  //use 700 // 600 best?
  //refresh();
  nested_refresh3();
  generation = generation +1;   // Possibly these two lines should be after refresh rather than before.
  oddgeneration_p = (generation % 2);

  draw_only_changed_from_list ();

    arrowsok = true;


};


// Drawing cells via the mouse
var pencil_insertmode = "insert";
var draw_status = "off";
var draw_choice = "freehand";
var colored_pencil = yellow;
var now_colored_pencil = yellow;

var orient_pencil = "East up";
//var color_stack = [red,yellow, green, blue, erase];
var x_vel_pencil = 0;
var y_vel_pencil = 0;

// Selecting cells via the mouse
var select_clicks = 0;
var select_1st_x = 0;
var select_1st_y = 0;
var select_2nd_x = 0;
var select_2nd_y = 0;


// original range1 offsets
var mouseXoffset = 15
var mouseYoffset = 120



function change_color_pencil(color) {
  colored_pencil = Number(color);
  putpatternsinmenu(); // this function may be defined after this function definition, which should be ok if javascript makes two passes.

};

function change_orient_pencil(x) {
  orient_pencil = x;
};

function change_x_vel_pencil(vel) {
   x_vel_pencil =  parseFloat(vel);
};

function change_y_vel_pencil(vel) {
   y_vel_pencil =  parseFloat(vel);
};

function change_draw_choice(choice) {

 if (choice == "user pattern") 
       {
           draw_choice = parseMultipleRLEentries(prompt("Please enter an RLE pattern here:")); // parseUserAddedRLE();
            putpatternsinmenu()
          

       }
 else  {
   draw_choice = choice
       };
};


//   Tried to use document.body.style.cursor = "hand"; in draw_at_mouse_here(x,y), below.
//   Didn't work.  Using "hand" is also the wrong stye, but it doesn't matter - it doesn't change on mousedown.
//   This is reportedly a bug in Chrome (and perhaps Safari).   
//   However, see http://stackoverflow.com/questions/2659999/html5-canvas-hand-cursor-problems


function convertcolor (c) {

  switch (c) {
    case 0x1000: return "#FF0000"; break;
    case 0x0100: return "#FFFF00"; break;
    case 0x0010: return "#00FF00"; break;
    case 0x0001: return "#00FFFF"; break;
    case 0x10000: return "#BDBDBD"; break;
    case 0:  return "rgba(0,0,0,0)"; break;   // this should be transparent color1 or something easier to maintain.  Also, clear doesn't erase.  Use something that erases.
   // there should be a default error-preventing case here.
   } 
}

function draw_at_mouse_here(x,y) {
  di = Math.round((x-mouseXoffset)/magnification);  // needs an offset, we're using zero for now.
  dj = Math.round((y-mouseYoffset)/magnification);
 // cxt.fillStyle= convertcolor(now_colored_pencil);
 // cxt.fillRect(di*magnification,dj*magnification, magnification, magnification);
   switch (now_colored_pencil) {
            case 0: 
                cxt.putImageData(clrpxid,di*magnification, dj*magnification);
                break;
            case 256:
                cxt.putImageData(ypxid, di*magnification, dj*magnification);
                break;
          
            case  16:
                cxt.putImageData(gpxid, di*magnification, dj*magnification);
                break;

            case  1:
                 cxt.putImageData(bpxid, di*magnification, dj*magnification);
                break;
          
            default:
                cxt.putImageData(rpxid, di*magnification, dj*magnification);
        };
   if ((arr[di][dj].color == background || arr[di][dj].color == decaygray) && now_colored_pencil != background) {      
      // if now_colored_pencil can equal decaygray, change the code to cover this possibility!               
        arr[di][dj].neighbors[0].alivecount += 1;
	arr[di][dj].neighbors[1].alivecount += 1;
	arr[di][dj].neighbors[2].alivecount += 1;
	arr[di][dj].neighbors[3].alivecount += 1;
	arr[di][dj].neighbors[4].alivecount += 1;
	arr[di][dj].neighbors[5].alivecount += 1;
	arr[di][dj].neighbors[6].alivecount += 1;
	arr[di][dj].neighbors[7].alivecount += 1;
        if (range != 8) {
	arr[di][dj].neighbors[8].alivecount += 1;
	arr[di][dj].neighbors[9].alivecount += 1;
	arr[di][dj].neighbors[10].alivecount += 1;
	arr[di][dj].neighbors[11].alivecount += 1;
	arr[di][dj].neighbors[12].alivecount += 1;
	arr[di][dj].neighbors[13].alivecount += 1;
	arr[di][dj].neighbors[14].alivecount += 1;
	arr[di][dj].neighbors[15].alivecount += 1;
	arr[di][dj].neighbors[16].alivecount += 1;
	arr[di][dj].neighbors[17].alivecount += 1;
	arr[di][dj].neighbors[18].alivecount += 1;
	arr[di][dj].neighbors[19].alivecount += 1;
	arr[di][dj].neighbors[20].alivecount += 1;
	arr[di][dj].neighbors[21].alivecount += 1;
	arr[di][dj].neighbors[22].alivecount += 1;
	arr[di][dj].neighbors[23].alivecount += 1;
        }
      } 
      else  if ((arr[di][dj].color != background && arr[di][dj].color != decaygray) && now_colored_pencil == background) {      
        arr[di][dj].neighbors[0].alivecount -= 1;
	arr[di][dj].neighbors[1].alivecount -= 1;
	arr[di][dj].neighbors[2].alivecount -= 1;
	arr[di][dj].neighbors[3].alivecount -= 1;
	arr[di][dj].neighbors[4].alivecount -= 1;
	arr[di][dj].neighbors[5].alivecount -= 1;
	arr[di][dj].neighbors[6].alivecount -= 1;
	arr[di][dj].neighbors[7].alivecount -= 1;
        if (range != 8) {
	arr[di][dj].neighbors[8].alivecount -= 1;
	arr[di][dj].neighbors[9].alivecount -= 1;
	arr[di][dj].neighbors[10].alivecount -= 1;
	arr[di][dj].neighbors[11].alivecount -= 1;
	arr[di][dj].neighbors[12].alivecount -= 1;
	arr[di][dj].neighbors[13].alivecount -= 1;
	arr[di][dj].neighbors[14].alivecount -= 1;
	arr[di][dj].neighbors[15].alivecount -= 1;
	arr[di][dj].neighbors[16].alivecount -= 1;
	arr[di][dj].neighbors[17].alivecount -= 1;
	arr[di][dj].neighbors[18].alivecount -= 1;
	arr[di][dj].neighbors[19].alivecount -= 1;
	arr[di][dj].neighbors[20].alivecount -= 1;
	arr[di][dj].neighbors[21].alivecount -= 1;
	arr[di][dj].neighbors[22].alivecount -= 1;
	arr[di][dj].neighbors[23].alivecount -= 1;
          }
       };
 
  arr[di][dj].decayval = 0;

  // Bx2 rule  
   if ((rulecode[now_colored_pencil] == 13 || rulecode[now_colored_pencil] == 23 || rulecode[now_colored_pencil] == 22) && now_colored_pencil != background)  {arr[di][dj].extra = 2}

   // Trilife rule or Qbert or penta  or kites rule or Kagome or truncated hex (and not enforcing case 52 - Penta-type9)
  else if ((rulecode[now_colored_pencil] == 14 || rulecode[now_colored_pencil] == 15   || rulecode[now_colored_pencil] == 51    || rulecode[now_colored_pencil] == 52 || rulecode[now_colored_pencil] == 30 || rulecode[now_colored_pencil] == 17 || rulecode[now_colored_pencil] == 40 ||  rulecode[now_colored_pencil] == 39  ) && now_colored_pencil != background)  { arr[di][dj].extra = 2 }

  else if (( rulecode[now_colored_pencil] == 20 || rulecode[now_colored_pencil] == 21 || rulecode[now_colored_pencil] == 54) && now_colored_pencil != background)  { arr[di][dj].extra = 7 }

        // Kishromb mouse
  else if ( rulecode[now_colored_pencil] == 56 && now_colored_pencil != background)  { arr[di][dj].extra = 7 }


   // Pentalife basketweave rule  -- enforce the checkerboard
  else if (rulecode[now_colored_pencil] == 18   && now_colored_pencil != background) {
            if (( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 2 == 0) || ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 2 == 1)) {
                arr[di][dj].extra = 1
             }
             else {arr[di][dj].extra = 4}
   }

   // Pentalife 668 alternaing peace signs  -- enforce the checkerboard
  else if (rulecode[now_colored_pencil] == 57   && now_colored_pencil != background) {
            if (( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 2 == 0) || ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 2 == 1)) {
                arr[di][dj].extra = 9
             }
             else {arr[di][dj].extra = 2}
   }


  // PentasSplitHex alternating 5-8 pentagons -- enforce the checkerboard  (Could be merged with  pentalife-basketweave but I'm keeping separete for debugging for now)
  else if (rulecode[now_colored_pencil] == 49  && now_colored_pencil != background) {
            if (( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 2 == 0) || ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 2 == 1)) {
                arr[di][dj].extra = 1
             }
             else {arr[di][dj].extra = 4}
   }


   // Elongtri tiling -- enforce the rows
   else if (rulecode[now_colored_pencil] == 44 && now_colored_pencil != background) {
           if ( arr[di][dj].ypos % 2 == 0) {arr[di][dj].extra = 2} else {arr[di][dj].extra = 4}
    }
    //   Snub Square tiling -- enforce snub square's set of conditions
   else if (rulecode[now_colored_pencil] == 46 && now_colored_pencil != background) {
         if ( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 2 == 0) 
                { arr[di][dj].extra = 2}
         else if ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 2 == 1) 
                 {arr[di][dj].extra = 5}
         else  {arr[di][dj].extra = 7}
     }
     // Tetrakis Square tiling
   else if (rulecode[now_colored_pencil] == 50 && now_colored_pencil != background) {
             if (( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 2 == 0) || ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 2 == 1)) {
                arr[di][dj].extra = 5
             }
             else {arr[di][dj].extra = 2}
   }
   // Rhombitrihexagonal and truncated trihexagonal mouse
   else if (((rulecode[now_colored_pencil] == 42) || (rulecode[now_colored_pencil] == 43)) && now_colored_pencil != background) {
             if (( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 4 == 0) || ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 4 == 2)) {
                arr[di][dj].extra = 8
             }
             else  if (( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 4 == 2) || ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 4 == 0)) {
                arr[di][dj].extra = 4
             }   
             else if (( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 4 == 1) || ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 4 == 3)) {
                arr[di][dj].extra = 1
             } 
             else  if (( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 4 == 3) || ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 4 == 1))
             {
                arr[di][dj].extra = 5
             } 
	    else { alert("imposed checkerboard error")}

      }

   // Snub Hexagonal mouse
   else if (((rulecode[now_colored_pencil] == 55) || (rulecode[now_colored_pencil] == 55)) && now_colored_pencil != background) {
                  // Squares
             if (( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 4 == 0) || ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 4 == 2)) {
                arr[di][dj].extra = 15
             }
                   // Hexagons
             else  if (( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 4 == 2) || ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 4 == 0)) {
                arr[di][dj].extra = 18
             }   
                    //  Downward Trio
             else if (( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 4 == 1) || ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 4 == 3)) {
                arr[di][dj].extra = 8
             } 
                      // Upward Trio
             else  if (( arr[di][dj].xpos % 2 == 0 &&  arr[di][dj].ypos % 4 == 3) || ( arr[di][dj].xpos % 2 == 1 &&  arr[di][dj].ypos % 4 == 1))
             {
                arr[di][dj].extra = 1
             } 
	    else { alert("imposed checkerboard error")}

      }


   else if (rulecode[now_colored_pencil] == 53 && now_colored_pencil != background) {

             if (( arr[di][dj].xpos % 3 == 0 &&  arr[di][dj].ypos % 3 == 0) || ( arr[di][dj].xpos % 3 == 1 &&  arr[di][dj].ypos % 3 == 2) || ( arr[di][dj].xpos % 3 == 2 &&  arr[di][dj].ypos % 3 == 1)) {
                arr[di][dj].extra = 1
             }
             else  if (( arr[di][dj].xpos % 3 == 0 &&  arr[di][dj].ypos % 3 == 1) || ( arr[di][dj].xpos % 3 == 1 &&  arr[di][dj].ypos % 3 == 0) || ( arr[di][dj].xpos % 3 == 2 &&  arr[di][dj].ypos % 3 == 2)) {
                arr[di][dj].extra = 4
             }   
             else if (( arr[di][dj].xpos % 3 == 0 &&  arr[di][dj].ypos % 3 == 2) || ( arr[di][dj].xpos % 3 == 1 &&  arr[di][dj].ypos % 3 == 1) || ( arr[di][dj].xpos % 3 == 2 &&  arr[di][dj].ypos % 3 == 0)) {
                arr[di][dj].extra = 7
             } 
         else { alert("imposed checkerboard error")}

      }



     // PentaSplitHex-six 
   else if (rulecode[now_colored_pencil] == 48 && now_colored_pencil != background) {
            if ( arr[di][dj].xpos % 2 == 0) {arr[di][dj].extra = 1} else {arr[di][dj].extra = 4}
    }


arr[di][dj].color = now_colored_pencil;
  arr[di][dj].Xspeed = x_vel_pencil;
  arr[di][dj].Yspeed = y_vel_pencil;
   //arr[di][dj].Xtally = 0;
  //arr[di][dj].Ytally = 0;

 
  changedcells[changecount] = arr[di][dj];
  changecount +=1;

  arr[di][dj].message = "just changed";
    


  if (x_vel_pencil != 0 || y_vel_pencil !=0)  {   // nested ifs to make the mouse more responsive since contains is slow
    if (now_colored_pencil != erase) {
      if (arr[di][dj].physicsmessage != "listed") // (contains(cellsinmotion, arr[di][dj]) == false)
        { 
         cellsinmotion.push(arr[di][dj])
         arr[di][dj].physicsmessage = "listed";
      };
    };
  };
}




//  Draw Line
// http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm#Simplification
 function drawline(x0, y0, x1, y1) {
   var dx = Math.abs(x1-x0);
   var dy = Math.abs(y1-y0);
   var sx;
   var sy;
   if (x0 < x1) { sx = 1} else { sx = -1};
   if (y0 < y1) { sy = 1} else {sy = -1};
   var err = dx-dy;
   var e2;

   while (true) {
     draw_at_mouse_here(x0,y0);
     if (x0 == x1 && y0 == y1) {break};
     e2 = 2*err;
     if (e2 > -dy) { 
       err = err - dy;
       x0 = x0 + sx;
     };
     if (e2 <  dx) { 
       err = err + dx;
       y0 = y0 + sy; 
     };
   } 
}


function cnvs_mousemove(e)
{
//stopCount()



   var x=e.clientX+window.pageXOffset; // CHANGED THIS TO LOCAL VARIABLE
   var y=e.clientY+window.pageYOffset;
   if (draw_status == "on" && draw_choice == "freehand") {
    //stopCount()
   // draw_at_mouse_here(x,y)
   drawline(x, y, oldMouseX, oldMouseY);
   oldMouseX = x;  // ********** Comment out this line and the next line to get a really cool radial drawing effect!!!!!! ****
   oldMouseY = y;
  //cxt.fillStyle= convertcolor(now_colored_pencil);
  //cxt.fillRect(x-mouseXoffset,y-mouseYoffset, magnification, magnification);



    }
   else if (pencil_insertmode == "select" && select_clicks == 1) {
          //ctx2.fillStyle = black;  
           ctx2.clearRect(Math.min(select_1st_x,select_2nd_x),Math.min(select_1st_y,select_2nd_y),
                       Math.abs( select_2nd_x - select_1st_x), Math.abs(select_2nd_y - select_1st_y));

          ctx2.fillStyle = greenish_select_color;  
          ctx2.fillRect(Math.min(select_1st_x,x-mouseXoffset),Math.min(select_1st_y,y-mouseYoffset),
                        Math.abs( x-mouseXoffset - select_1st_x), Math.abs(y-mouseYoffset - select_1st_y));
          select_2nd_x =  x-mouseXoffset;
          select_2nd_y = y-mouseYoffset;
         //  Since these select_2nd values are provisional (before the second select click),
         //   there must be a provision to ensure they don't become numbers that go outside the boundaries of the canvas
          select_2nd_x =  Math.min(Math.max(select_2nd_x,0),memoryX*magnification);
          select_2nd_y =  Math.min(Math.max(select_2nd_y,0),memoryY*magnification);

       
   }

  
};

function cnvs_clearCoordinates()
{
//document.getElementById("xycoordinates").innerHTML="";
};

function cnvs_mouseup(e)
{
     draw_status = "off"

     if (pencil_insertmode == "select" && select_clicks == 1) {
          var x=e.clientX + window.pageXOffset;    // CHANGED THIS TO LOCAL VARIABLE
          var y=e.clientY + window.pageYOffset;
          select_clicks = 2;
          select_2nd_x = x-mouseXoffset;
          select_2nd_y = y-mouseYoffset;
          ctx2.fillStyle=greenish_select_color;  
          ctx2.fillRect(Math.min(select_1st_x,select_2nd_x),Math.min(select_1st_y,select_2nd_y),Math.abs( select_2nd_x - select_1st_x), Math.abs(select_2nd_y - select_1st_y));       
      }
};

var oldMouseX;
var oldMouseY;



function cnvs_mousedown(e) {

    //colored_pencil = color_stack.shift();
  //color_stack.push(colored_pencil);
  var x=e.clientX + window.pageXOffset;    // CHANGED THIS TO LOCAL VARIABLE
  var y=e.clientY + window.pageYOffset;
  var tempx;
  var tempy;
    // Note that canvas offsets are 15 and 120 below, and used in draw_at_mouse_here
  if (pencil_insertmode == "insert") {
    if (draw_choice == "freehand") 
      {
         // if the user clicks on a cell that is, say, yellow,  when the colored pencil is already selected for yellow, the pencil becomes an eraser due to the next lines.
         tempx = Math.round((x-mouseXoffset)/magnification)  // unfortunately, this must be calculated now, I first thought it wouldn't have to be calculated until draw_at_mouse
         tempy = Math.round((y-mouseYoffset)/magnification)
         if ( colored_pencil == arr[tempx][tempy].color) 
               {now_colored_pencil = erase} 
         else {now_colored_pencil = colored_pencil}

        draw_status = "on";
       draw_at_mouse_here(x,y)
       oldMouseX = x;
       oldMouseY = y;
       //stopCount()
       }
   /*
     else if (draw_choice == "user pattern") 
       {
           draw_choice = parseMultipleRLEentries(prompt("Please enter an RLE pattern here:")); // parseUserAddedRLE();
           drawPatternInCenterByName(draw_choice,Math.round((x-mouseXoffset)/magnification),Math.round((y-mouseYoffset)/magnification),orient_pencil, colored_pencil, x_vel_pencil, y_vel_pencil);

       }
   */
     else 
      {
       drawPatternInCenterByName(draw_choice,Math.round((x-mouseXoffset)/magnification),Math.round((y-mouseYoffset)/magnification),orient_pencil, colored_pencil, x_vel_pencil, y_vel_pencil);
      }
   }
  else if (pencil_insertmode == "select") {
     if (select_clicks == 0) {
          select_clicks = 1;
          select_1st_x = x-mouseXoffset;
          select_1st_y = y-mouseYoffset;
      }
      else if (select_clicks == 1) {
          select_clicks = 2;
          select_2nd_x = x-mouseXoffset;
          select_2nd_y = y-mouseYoffset;
          ctx2.fillStyle=greenish_select_color;  
          ctx2.fillRect(Math.min(select_1st_x,select_2nd_x),Math.min(select_1st_y,select_2nd_y),Math.abs( select_2nd_x - select_1st_x), Math.abs(select_2nd_y - select_1st_y));

      }
      else {
          select_clicks = 0
          //ctx2.fillStyle=black;  
          ctx2.clearRect(Math.min(select_1st_x,select_2nd_x),Math.min(select_1st_y,select_2nd_y),Math.abs( select_2nd_x - select_1st_x), Math.abs(select_2nd_y - select_1st_y));
      }
   }
  
  else if (pencil_insertmode == "drive") {
   if (draw_choice != "freehand") {
    restartDriving(draw_choice, Math.round((x-mouseXoffset)/magnification),Math.round((y-mouseYoffset)/magnification),orient_pencil, colored_pencil, x_vel_pencil, y_vel_pencil);
    }
   }
  else  if (pencil_insertmode == "orthobullet") {
   if (draw_choice != "freehand") { orthogonalBullet = draw_choice}
    }
  else if (pencil_insertmode == "diagbullet") {
   if (draw_choice != "freehand") { diagonalBullet = draw_choice}
    }
};

// *******  Change Settings (change magnification) *********

var weird_effect = false;
var offerallpatterns = false;

function redraw_backdrop() {
    switch (magnification) {

        case .5:
                ctx3.fillStyle=black;  
                ctx3.fillRect(0,0, layer3.width, layer3.height);
                break;
        case 1: 
                ctx3.fillStyle=black;  
                ctx3.fillRect(0,0, layer3.width, layer3.height);
                break;
       case 2:
                ctx3.fillStyle=black;  
                ctx3.fillRect(0,0, layer3.width, layer3.height);
                break;
        case 3:
                ctx3.fillStyle=black;  
                ctx3.fillRect(0,0, layer3.width, layer3.height);
                break;
         case 4: 
                ctx3.clearRect(0,0, layer3.width, layer3.height);
                document.getElementById("layer3").style.backgroundImage = "url('./spritelife-aux/1over4-grid-4k.jpg')"
                break;
         case 8: 
                ctx3.clearRect(0,0, layer3.width, layer3.height);
                document.getElementById("layer3").style.backgroundImage = "url('./spritelife-aux/1over8-grid-8k.jpg')"
                break;
         case 16: 
                ctx3.clearRect(0,0, layer3.width, layer3.height);
                document.getElementById("layer3").style.backgroundImage = "url('./spritelife-aux/1over16-grid-12k.jpg')"
                break;
          default:
                // do nothing for now
                }
};

function redraw_canvas() {
       //cxt.fillStyle=non_game_canvas_color;  
       //cxt.fillRect(0,0, c.width, c.height);
      // cxt.fillStyle=background; 
       //cxt.fillRect(0,0,memoryX*magnification, memoryY*magnification);
       c.width =  memoryX*magnification     //c.width = 960;  
       if ((window.innerHeight - 119)>memoryY*magnification ){c.height = memoryY*magnification} else {c.height=window.innerHeight -70};  
      layer2.width = magnification*memoryX;
      if ((window.innerHeight - 119)>memoryY*magnification ){layer2.height = memoryY*magnification} else {layer2.height=window.innerHeight -70};  
      layer3.width = magnification*memoryX;
      if ((window.innerHeight - 119)>memoryY*magnification ){layer3.height = memoryY*magnification} else {layer3.height=window.innerHeight -70};  
      //ctx2.drawImage(backdrop, 0, 0, magnification*memoryX, magnification*memoryY);
     // draw_only_changed_from_list ();
      draw_withputimagedata ()

};

function change_settings_menu (val) {
  //stopCount();

  var fx=document.getElementById("mag");
  switch (val) {
   case "title":
     break;

 case "fill window":
        memoryX = Math.floor((window.innerWidth -30 )/magnification);    
        memoryY = Math.floor((window.innerHeight -119) / magnification);   

      arr = Create2DArray(memoryX);

       for (var i=0;i<memoryX;i++){
          for (var j=0; j<memoryY;j++) {
              arr[i][j] = new cell(i, j, background, background,background,0, 0,0,0,0,0,0,0, "hi", "unlisted",[],0,0,0,0,0,0);
           };
       };
      precalculateNeighbors();
       changedcells = [];
        changecount = 0;
        newchangedcells = [];   
        NewChangeCount = 0;  
       cellsinmotion = [];
       generation = 0;
       c.width =  window.innerWidth  -30 ;  
       c.height = window.innerHeight -119;  
      layer2.width =  window.innerWidth -30  ; 
      layer2.height = window.innerHeight - 119;
      layer3.width =  window.innerWidth -30  ; 
      layer3.height = window.innerHeight - 119;
       redraw_backdrop()
      //ctx2.drawImage(backdrop, 0, 0,window.innerWidth - 30  , window.innerHeight - 119);
      // draw_withputimagedata () 
     draw_only_changed_from_list ();      
      fx.selectedIndex = 0;  // Allows toggle despite "onchange" not changing!!!!

      break;
 

   
   case ".1 effect":
      if (weird_effect == false) {
        weird_effect = true; magnification = magnification+0.1; fx.options[fx.selectedIndex].text="Disable weird history effect";} 
      else {
        weird_effect = false; magnification = magnification-0.1; fx.options[fx.selectedIndex].text="Enable weird history effect"}; 
      fx.selectedIndex = 0;  // Allows toggle despite "onchange" not changing!!!!
  
     c.width = magnification*memoryX;
     c.height = magnification*memoryY;
     //cxt.fillStyle=non_game_canvas_color;  //  with cxt.fillStyle = get-current-color(arr[i][j])
     //cxt.fillRect(0,0, c.width, c.height);
       layer2.width = magnification*memoryX;
      layer2.height = magnification*memoryY;
       layer3.width = magnification*memoryX;
      layer3.height = magnification*memoryY;
     // ctx2.drawImage(backdrop, 0, 0, magnification*memoryX, magnification*memoryY);
    //draw();  
    break;

    case "960x640":
       memoryX = 960;
       memoryY = 640;
       arr = Create2DArray(memoryX);

       for (var i=0;i<memoryX;i++){
          for (var j=0; j<memoryY;j++) {
              arr[i][j] = new cell(i, j, background, background,background,0, 0,0,0,0,0,0,0, "hi", "unlisted", [],0,0,0,0,0,0);
           };
       };
       precalculateNeighbors();

       magnification = 1;

       // the following might be completely unnnecessary!   If not, replicate for changedcells and cellsinmotion for all sizes. 
      // for (var ii=0, lenlen = changedcells.length; ii< lenlen; ii++) {changedcells[ii].message = "hi"}; 
      
       changedcells = [];
        changecount = 0;
        newchangedcells = [];   
        NewChangeCount = 0;  
       cellsinmotion = [];
       generation = 0;
       redraw_canvas(); 
       change_mag_aux (magnification);         
       redraw_backdrop()
       break;
    case "480x320":
       memoryX = 480;
       memoryY = 320;
       arr = Create2DArray(memoryX);

       for (var i=0;i<memoryX;i++){
          for (var j=0; j<memoryY;j++) {
              arr[i][j] = new cell(i, j, background, background,background,0, 0,0,0,0,0,0,0, "hi", "unlisted", [],0,0,0,0,0,0);
           };
       };
      precalculateNeighbors();

       magnification = 2;
        changedcells = [];
       changecount = 0;
        newchangedcells = [];   
        NewChangeCount = 0;  
       cellsinmotion = [];
       generation = 0;
       redraw_canvas(); 
       change_mag_aux (magnification);         
       redraw_backdrop()
       break;
   case "320x213":
       memoryX = 320;
       memoryY = 213;
       arr = Create2DArray(memoryX);

       for (var i=0;i<memoryX;i++){
          for (var j=0; j<memoryY;j++) {
              arr[i][j] = new cell(i, j, background, background,background,0, 0,0,0,0,0,0,0, "hi", "unlisted",[],0,0,0,0,0,0);
           };
       };
      precalculateNeighbors();

       magnification = 3;
        changedcells = [];
        changecount = 0;
        newchangedcells = [];   
        NewChangeCount = 0;  
       cellsinmotion = [];
       generation = 0;
       redraw_canvas(); 
       change_mag_aux (magnification);
       redraw_backdrop()

       break;
  case "240x160":
       memoryX = 240;
       memoryY = 160;
       

       arr = Create2DArray(memoryX);

       for (var i=0;i<memoryX;i++){
          for (var j=0; j<memoryY;j++) {
              arr[i][j] = new cell(i, j, background, background,background,0, 0,0,0,0,0,0,0, "hi", "unlisted",[],0,0,0,0,0,0);
           };
       };
       precalculateNeighbors();

       magnification = 4;

        changedcells = [];
        changecount = 0;
        newchangedcells = [];   
        NewChangeCount = 0;  
       cellsinmotion = [];
       generation = 0;
       redraw_canvas(); 
       change_mag_aux (magnification);
       redraw_backdrop()

       break;
   case "no background":
      ctx3.fillStyle=black;  
      ctx3.fillRect(0,0, layer3.width, layer3.height);

     fx.selectedIndex = 0;
      break;
    case "not rule specific":   
       offerallpatterns = true;
       putpatternsinmenu ();
       fx.selectedIndex = 0;
       break; 
     case "rule specific":
         offerallpatterns = false;
       putpatternsinmenu ();
       fx.selectedIndex = 0;
       break; 

  case "toggleRange":



       // Temporary ugly solution --- should use clear memory
      


       arr = Create2DArray(memoryX);
       for (var i=0;i<memoryX;i++){
          for (var j=0; j<memoryY;j++) {
              arr[i][j] = new cell(i, j, background, background,background,0, 0,0,0,0,0,0,0, "hi", "unlisted",[],0,0,0,0,0,0);
           };
       };

         //   also, the available height for the canvas changes, so possibly resize the canvas -- see references to - 119


      if (range == 8) { 
         range = 24;
         r2_initialize();   // this function includes precalculateNeighbors()
         fx.options[fx.selectedIndex].text="Switch to radius 1";
         fx.selectedIndex = 0;  // Allows toggle despite "onchange" not changing!!!!
       }
       else {
         range = 8;
         original_initialize();   // this function includes precalculateNeighbors()
         fx.options[fx.selectedIndex].text="Switch to radius 2";
         fx.selectedIndex = 0;  // Allows toggle despite "onchange" not changing!!!!
       }



     break;

         
         

   case "toggleX":
      if (Xtopology == "wraparound")  {
        Xtopology =  "oasis";  fx.options[fx.selectedIndex].text="Enable East-West wraparound";} 
      else {
        Xtopology = "wraparound"; fx.options[fx.selectedIndex].text="Disable East-West wraparound"}; 
      precalculateNeighbors();
      fx.selectedIndex = 0;  // Allows toggle despite "onchange" not changing!!!!
      break;

   case "toggleY":
      if (Ytopology == "wraparound")  {
        Ytopology =  "oasis";  fx.options[fx.selectedIndex].text="Enable North-South wraparound";} 
      else {
        Ytopology = "wraparound"; fx.options[fx.selectedIndex].text="Disable North-South wraparound"}; 
      precalculateNeighbors();
      fx.selectedIndex = 0;  // Allows toggle despite "onchange" not changing!!!!
      break;
   case "twoNeigh":
      if (multi_color_mode == "two can be converted")  {
        multi_color_mode =  "2 does not convert";  fx.options[fx.selectedIndex].text="Enable two neighbor conversion";} 
      else {
        multi_color_mode = "two can be converted" ; fx.options[fx.selectedIndex].text="Disable two neighbor conversion"}; 
      fx.selectedIndex = 0;  // Allows toggle despite "onchange" not changing!!!!
      break;
  
/*   theRuleInUse =  con1doLifeRuleToCell2;  //  HighLifeRule //  MorleyRule   //DayandNightRule // BeeZeroRule 
   <option value="B3/S23B3/S23">Conway's Life (B3/S23)</option>
       <option value="HighLife">HighLife (B36/S23)</option>  
       <option value="Day&Night">Day & Night (B3678/S34678)</option>    
       <option value="Morley">Morley/Move ( B368/S245)</option> 
       <option value="Low Morley">Low Morley (B36/S245)</option> 
       <option value="2x2 Life">2x2 Life (B36/S125)</option> 
       <option value="Even&Odd">Even & Odd (B013468/S02)</option> 
*/
    case "B3/S23B3/S23":        theRuleInUse =      con1doLifeRuleToCell2; 
          break; 
    case "HighLife":      theRuleInUse =       HighLifeRule;
          break;
    case  "Day&Night":   theRuleInUse =        DayandNightRule;
          break;
    case  "Morley":       theRuleInUse =   MorleyRule;
          break;

    // The rules below are not  implemented yet so we'll just use the life rule.

    case  "Low Morley":   theRuleInUse =      con1doLifeRuleToCell2; 
          break; 

    case   "2x2 Life":    theRuleInUse =      con1doLifeRuleToCell2; 
          break; 

    case   "Even&Odd":    theRuleInUse =      BeeZeroRule;
          break; 
 

         

    default:
      if (weird_effect == true)
           {magnification = parseFloat(val); magnification=magnification+0.1} 
      else {magnification=parseFloat(val)};
      c.width = magnification*memoryX;
      c.height = magnification*memoryY;
      layer2.width = magnification*memoryX;
      layer2.height = magnification*memoryY;
      layer3.width = magnification*memoryX;
      layer3.height = magnification*memoryY;
      change_mag_aux (magnification);
      redraw_backdrop()
     // ctx2.drawImage(backdrop, 0, 0, magnification*memoryX, magnification*memoryY);
     // draw(); 
      //redraw_canvas(); // this is probably highly redundant.  fix.
      //      draw_only_changed_from_list ();
           draw_withputimagedata ()


  }
 
};



function change_mag_aux(magnification) {
    switch (magnification) {

        case .5:
 		ypxid = ypxid1;
 		rpxid = rpxid1;
		gpxid = gpxid1;
	 	bpxid = bpxid1;
		clrpxid = clrpxid1;
                graypxid = graypxid1;
               draw_only_changed_from_list = draw_normal_only_changed_from_list;
               draw_withputimagedata = draw_normal_withputimagedata

                break;
        case 1: 

 		ypxid = ypxid1;
 		rpxid = rpxid1;
		gpxid = gpxid1;
	 	bpxid = bpxid1;
		clrpxid = clrpxid1;
                graypxid = graypxid1;
               draw_only_changed_from_list = draw_normal_only_changed_from_list;
               draw_withputimagedata = draw_normal_withputimagedata

                break;
       case 2:

 		ypxid = ypxid2;
 		rpxid = rpxid2;
		gpxid = gpxid2;
	 	bpxid = bpxid2;
		clrpxid = clrpxid2;
                graypxid = graypxid2;
               draw_only_changed_from_list = draw_normal_only_changed_from_list;
               draw_withputimagedata = draw_normal_withputimagedata

                break;
        case 3:

 		ypxid = ypxid3;
 		rpxid = rpxid3;
		gpxid = gpxid3;
	 	bpxid = bpxid3;
		clrpxid = clrpxid3;
                graypxid = graypxid3;
               draw_only_changed_from_list = draw_normal_only_changed_from_list;
               draw_withputimagedata = draw_normal_withputimagedata

                break;
         case 4: 
               	ypxid = ypxid4;
 		rpxid = rpxid4;
		gpxid = gpxid4;
	 	bpxid = bpxid4;
		clrpxid = clrpxid4;
                graypxid = graypxid4;
               draw_only_changed_from_list = draw_normal_only_changed_from_list;
               draw_withputimagedata = draw_normal_withputimagedata

                break;
         case 8: 
               	ypxid = ypxid8;
 		rpxid = rpxid8;
		gpxid = gpxid8;
	 	bpxid = bpxid8;
		clrpxid = clrpxid8;
                graypxid = graypxid8;
              //  if (uses_dot_extra[red] || uses_dot_extra[yellow] || uses_dot_extra[green] || uses_dot_extra[blue]) {
            
              gpixel_array = gpxid8_array
              ypixel_array = ypxid8_array
              rpixel_array = rpxid8_array
              bpixel_array = bpxid8_array
              graypixel_array = graypxid8_array
           
                set_icons (red)
                set_icons (yellow)
                set_icons (green)
                set_icons (blue)
                set_icons (gray)



              draw_only_changed_from_list = draw_extra_only_changed_from_list;
              draw_withputimagedata = draw_extra_withputimagedata
              //  }
             //  else {
             // draw_only_changed_from_list = draw_normal_only_changed_from_list;
            //   draw_withputimagedata = draw_normal_withputimagedata
            //   }

                break;
         case 16: 
               	ypxid = ypxid16;
 		rpxid = rpxid16;
		gpxid = gpxid16;
	 	bpxid = bpxid16;
		clrpxid = clrpxid16;
                graypxid = graypxid16;
                //if (uses_dot_extra[red] || uses_dot_extra[yellow] || uses_dot_extra[green] || uses_dot_extra[blue]) {
               
              
              gpixel_array = gpxid16_array
              ypixel_array = ypxid16_array
              rpixel_array = rpxid16_array
              bpixel_array = bpxid16_array
              graypixel_array = graypxid16_array

                set_icons (red)
                set_icons (yellow)
                set_icons (green)
                set_icons (blue)
                set_icons (gray)

            

             // this was just for testing -- what to do if no .extra values being used -- gpixel_array =   gpxid16_array
              draw_only_changed_from_list = draw_extra_only_changed_from_list;
              draw_withputimagedata = draw_extra_withputimagedata
             //   }
             //  else {
              //draw_only_changed_from_list = draw_normal_only_changed_from_list;
            //   draw_withputimagedata = draw_normal_withputimagedata
             //  }


                break;
          default:
                // do nothing for now
                }
};

function change_magnification(val) {
     // if (weird_effect == true)
     //      {magnification = parseFloat(val); magnification=magnification+0.1} 
     // else {magnification=parseFloat(val)};
      c.width = magnification*memoryX;
      c.height = magnification*memoryY;
      layer2.width = magnification*memoryX;
      layer2.height = magnification*memoryY;
      layer3.width = magnification*memoryX;
      layer3.height = magnification*memoryY;
      change_mag_aux (magnification);
      redraw_backdrop()
     // ctx2.drawImage(backdrop, 0, 0, magnification*memoryX, magnification*memoryY);
     // draw(); 
      //redraw_canvas(); // this is probably highly redundant.  fix.
      //      draw_only_changed_from_list ();
           draw_withputimagedata ()
}

function increase_magnification () {
  if (mag_index < (mag_options.length - 1)) {
     mag_index += 1;
     magnification = mag_options[mag_index];
     change_magnification(magnification);
  }
}

// Could  enable/disable increase and decrese buttons to indicate whether limit has been reached.

function decrease_magnification () {
  if (mag_index > 0) {
       mag_index -= 1;
       magnification = mag_options[mag_index];
       change_magnification(magnification);
  }
}


    /*
1over16-grid-8k.jpg
1over8-grid-8k.jpg
1over4-grid-4k.jpg
//document.getElementById("layer2").style.backgroundImage = "url('http://./1over4-grid-best.jpg'); background-repeat: repeat;";

document.getElementById("layer3").style.backgroundImage = "url('./spritelife-aux/1over4-grid-4k.jpg')"
document.getElementById("layer3").style.backgroundRepeat = "repeat"

*/

// Code for the initial backdrop
if (magnification < 4) {
     ctx3.fillStyle=black;  
     ctx3.fillRect(0,0, layer3.width, layer3.height);
 } 
 else { change_mag_aux(magnification) };



//********************** Creating the lifepatterns menu********************

function addOption(selectbox,text,value ) {
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
};

/*

for (var p in lifepatterns) {
  if (lifepatterns[p].englishname != undefined)
   {
    //addOption(document.controlform.drawmode, lifepatterns[p].englishname, p)
     addOption(document.getElementById("drawmode"), lifepatterns[p].englishname, p)
   } 
   else 
    {
    // addOption(document.controlform.drawmode, p, p)
      addOption(document.getElementById("drawmode"), p, p)

    }
};

*/

function addpatternchoice (p) {
   if (lifepatterns[p].englishname != undefined) {addOption(document.getElementById("drawmode"), lifepatterns[p].englishname, p)} 
 	 else { addOption(document.getElementById("drawmode"), p, p)}
}


function putpatternsinmenu () {
 document.getElementById("drawmode").options.length = 2

 var r = rulename[colored_pencil]
 for (var p in lifepatterns) {
  if (offerallpatterns)  {addpatternchoice(p)}
  else {




   	 if (lifepatterns[p].rule != undefined) { 
       		if ( contains_or_is(lifepatterns[p].rule, r) ||  contains_or_is(lifepatterns[p].rule, "all")) {
         		addpatternchoice(p)       
       		}
     	}
     	else {
        	if (r == "B3/S23") {
            		addpatternchoice(p)
        	}
    	}
    }
  }
 draw_choice = document.getElementById("drawmode").options[0].value;  
};
         



function putrulesinmenus () { 
        
    document.getElementById("redrule1").options.length = 0
    document.getElementById("yellowrule1").options.length = 0
    document.getElementById("greenrule1").options.length = 0
    document.getElementById("bluerule1").options.length = 0


   for (var i = 0; i<rulesmenu.length; i++) {
      if (rulesmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("redrule1"),rulesmenu[i][1],rulesmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("redrule1"),rulesmenu[i][0],rulesmenu[i][0] )
       }
   }   for (var i = 0; i<rulesmenu.length; i++) {
      if (rulesmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("yellowrule1"),rulesmenu[i][1],rulesmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("yellowrule1"),rulesmenu[i][0],rulesmenu[i][0] )
       }
   }   for (var i = 0; i<rulesmenu.length; i++) {
      if (rulesmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("greenrule1"),rulesmenu[i][1],rulesmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("greenrule1"),rulesmenu[i][0],rulesmenu[i][0] )
       }
   }
   for (var i = 0; i<rulesmenu.length; i++) {
      if (rulesmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("bluerule1"),rulesmenu[i][1],rulesmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("bluerule1"),rulesmenu[i][0],rulesmenu[i][0] )
       }
   }
}



function r2_putrulesinmenus () { 
    document.getElementById("r2_redrule1").options.length = 0
    document.getElementById("r2_yellowrule1").options.length = 0
    document.getElementById("r2_greenrule1").options.length = 0
    document.getElementById("r2_bluerule1").options.length = 0


   for (var i = 0; i<r2_rulesmenu.length; i++) {
      if (r2_rulesmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("r2_redrule1"),r2_rulesmenu[i][1],r2_rulesmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("r2_redrule1"),r2_rulesmenu[i][0],r2_rulesmenu[i][0] )
       }
   }   for (var i = 0; i<r2_rulesmenu.length; i++) {
      if (r2_rulesmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("r2_yellowrule1"),r2_rulesmenu[i][1],r2_rulesmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("r2_yellowrule1"),r2_rulesmenu[i][0],r2_rulesmenu[i][0] )
       }
   }   for (var i = 0; i<r2_rulesmenu.length; i++) {
      if (r2_rulesmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("r2_greenrule1"),r2_rulesmenu[i][1],r2_rulesmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("r2_greenrule1"),r2_rulesmenu[i][0],r2_rulesmenu[i][0] )
       }
   }
   for (var i = 0; i<r2_rulesmenu.length; i++) {
      if (r2_rulesmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("r2_bluerule1"),r2_rulesmenu[i][1],r2_rulesmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("r2_bluerule1"),r2_rulesmenu[i][0],r2_rulesmenu[i][0] )
       }
   }
}
        

// Range2 version
function r2_putweightsinmenus () { 
        
    document.getElementById("redweight1").options.length = 0
    document.getElementById("yellowweight1").options.length = 0
    document.getElementById("greenweight1").options.length = 0
    document.getElementById("blueweight1").options.length = 0


   for (var i = 0; i<weightsmenu.length; i++) {
      if (weightsmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("redweight1"),weightsmenu[i][1],weightsmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("redweight1"),weightsmenu[i][0],weightsmenu[i][0] )
       }
   }   for (var i = 0; i<weightsmenu.length; i++) {
      if (weightsmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("yellowweight1"),weightsmenu[i][1],weightsmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("yellowweight1"),weightsmenu[i][0],weightsmenu[i][0] )
       }
   }   for (var i = 0; i<weightsmenu.length; i++) {
      if (weightsmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("greenweight1"),weightsmenu[i][1],weightsmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("greenweight1"),weightsmenu[i][0],weightsmenu[i][0] )
       }
   }
   for (var i = 0; i<weightsmenu.length; i++) {
      if (weightsmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("blueweight1"),weightsmenu[i][1],weightsmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("blueweight1"),weightsmenu[i][0],weightsmenu[i][0] )
       }
   }
}

function r1_puthoodsinmenus () { 
        
    document.getElementById("redhood1").options.length = 0
    document.getElementById("yellowhood1").options.length = 0
    document.getElementById("greenhood1").options.length = 0
    document.getElementById("bluehood1").options.length = 0


   for (var i = 0; i<hoodsmenu.length; i++) {
      if (hoodsmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("redhood1"),hoodsmenu[i][1],hoodsmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("redhood1"),hoodsmenu[i][0],hoodsmenu[i][0] )
       }
   }   for (var i = 0; i<hoodsmenu.length; i++) {
      if (hoodsmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("yellowhood1"),hoodsmenu[i][1],hoodsmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("yellowhood1"),hoodsmenu[i][0],hoodsmenu[i][0] )
       }
   }   for (var i = 0; i<hoodsmenu.length; i++) {
      if (hoodsmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("greenhood1"),hoodsmenu[i][1],hoodsmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("greenhood1"),hoodsmenu[i][0],hoodsmenu[i][0] )
       }
   }
   for (var i = 0; i<hoodsmenu.length; i++) {
      if (hoodsmenu[i][1] != undefined) {
          // if there is an englishname option, use it
          addOption(document.getElementById("bluehood1"),hoodsmenu[i][1],hoodsmenu[i][0] )
       }
      else { // there is no englishname option
           addOption(document.getElementById("bluehood1"),hoodsmenu[i][0],hoodsmenu[i][0] )
       }
   }
}


function original_initialize () {
   putpatternsinmenu();
   putrulesinmenus ();

   // This code hides the R2 weight menus:
   document.getElementById("Range2_weights_div").style.display = "none";
   // This code shows the original Range 1 rules menus:
   document.getElementById("original_rules_div").style.display = "";

   // mouseXoffset = 15;  There is no need to change the Xoffset, for now.
   mouseYoffset = 120;
   precalculateNeighbors();
   change_rule (blue, rulesmenu[0][0])
   change_rule (green, rulesmenu[0][0])
   change_rule (yellow, rulesmenu[0][0])
   change_rule (red, rulesmenu[0][0])
}


function r1_initialize () {
  putpatternsinmenu();

   r1_putrulesinmenus ();
   r1_puthoodsinmenus (); 

  // This code shows the weight menus:
  document.getElementById("Range2_weights_div").style.display = "";
  // This code hides the original Range1 rules menus:
  document.getElementById("original_rules_div").style.display = "none";

   // mouseXoffset = 15;  There is no need to change the Xoffset, for now.
   mouseYoffset = 150;
   precalculateNeighbors();
   rulecode[blue] = 1
   rulecode[yellow] = 1
   rulecode[green] = 1
   rulecode[red] = 1
   r1_change_rule (blue, r1_rulesmenu[0][0])
   r1_change_rule (green, r1_rulesmenu[0][0])
   r1_change_rule (yellow, r1_rulesmenu[0][0])
   r1_change_rule (red, r1_rulesmenu[0][0])

}




function r2_initialize () {
   r2_putrulesinmenus ();
   r2_putweightsinmenus (); 

  // This code shows the weight menus:
  document.getElementById("Range2_weights_div").style.display = "";
  // This code hides the original Range1 rules menus:
  document.getElementById("original_rules_div").style.display = "none";

   // mouseXoffset = 15;  There is no need to change the Xoffset, for now.
   mouseYoffset = 150;
   precalculateNeighbors();
   rulecode[blue] = 1
   rulecode[yellow] = 1
   rulecode[green] = 1
   rulecode[red] = 1
   r2_change_rule (blue, r2_rulesmenu[0][0])
   r2_change_rule (green, r2_rulesmenu[0][0])
   r2_change_rule (yellow, r2_rulesmenu[0][0])
   r2_change_rule (red, r2_rulesmenu[0][0])

}








// ********************************************************************
//        Code - not a function                                 *************
//
//        Initialize the drawing menu with lifepatterns         *************
//
// ********************************************************************


if (range == 8) {original_initialize()} else {r2_initialize()}
generation = 0

//putpatternsinmenu();
//putrulesinmenus ();

//r2_putrulesinmenus ();
//r2_putweightsinmenus ()

// This code hides the weight menus:
//document.getElementById("Range2_weights_div").style.display = "none";

// This code shows the weight menus:
//document.getElementById("Range2_weights_div").style.display = "";

// This code hides the original Range1 rules menus:
//document.getElementById("original_rules_div").style.display = "none";

// This code shows the original Range 1 rules menus:
//document.getElementById("original_rules_div").style.display = "";

/*

<select id="insertmode" onchange="change_insertmode(this.value)">
   <option value="insert" selected="selected">Insert</option>
   <option value="select">Select</option>
   <option value="select_all">Select All</option>
   <option value="save">Get RLE</option>
   <option value="save">Get Multirule RLE</option>

   <option value="insert">==========</option>
   <option value="cut">Cut</option>
   <option value="copy">Copy</option>
   <option value="paste">Paste</option>
   <option value="insert">==========</option>
   <option value="clear">Clear Selection</option>
   <option value="clear_outside">Clear Outside</option>
   <option value="clear_outside">Clear All</option>
   <option value="insert">==========</option>

   <option value="fill">Fill</option>
   <option value="random_fill">Random Fill</option>
   <option value="insert">==========</option>
   <option value="rotate_cw">Rotate CW</option>
   <option value="rotate_ccw">Rotate CCW</option>
   <option value="flip_N-S">Flip N-S</option>
   <option value="flip_E-W">Flip E-W</option>
   <option value="insert">==========</option>
   <option value="drive">Insert drivable</option>
   <option value="orthobullet">Set ortho bullet</option>
   <option value="diagbullet">Set diag bullet</option>
</select>



function setCell(x, y, pcolor, pXspeed, pYspeed, pdecayval) {


*/

function nudge_selection(x_nudge,y_nudge){
      var c_select_1st_x = Math.min(select_1st_x, select_2nd_x)
      var c_select_2nd_x = Math.max(select_1st_x, select_2nd_x)
      var c_select_1st_y = Math.min(select_1st_y, select_2nd_y)
      var c_select_2nd_y = Math.max(select_1st_y, select_2nd_y)

      c_select_1st_x = Math.round(c_select_1st_x/magnification)
      c_select_1st_y = Math.round(c_select_1st_y/magnification)
      c_select_2nd_x = Math.round(c_select_2nd_x/magnification)
      c_select_2nd_y = Math.round(c_select_2nd_y/magnification)

     var c_single_color = detect_single_color (c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);
     var selected_pattern = save_RLE_patternstring(c_single_color,c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);
     drawPattern_aux(selected_pattern, c_select_1st_x,c_select_1st_y,  1, 1,true,background,0,0);  // erase at old place
     drawPattern_aux(selected_pattern, c_select_1st_x + x_nudge,c_select_1st_y+y_nudge,  1, 1,true,c_single_color,0,0);  // draw at new place
       

      ctx2.clearRect(Math.min(select_1st_x,select_2nd_x),Math.min(select_1st_y,select_2nd_y),Math.abs( select_2nd_x - select_1st_x), Math.abs(select_2nd_y - select_1st_y));
          select_1st_x = select_1st_x + x_nudge*magnification;
          select_2nd_x = select_2nd_x + x_nudge*magnification;
          select_1st_y = select_1st_y + y_nudge*magnification;
          select_2nd_y = select_2nd_y + y_nudge*magnification;
      ctx2.fillStyle=greenish_select_color;  
      ctx2.fillRect(Math.min(select_1st_x,select_2nd_x),Math.min(select_1st_y,select_2nd_y),Math.abs( select_2nd_x - select_1st_x), Math.abs(select_2nd_y - select_1st_y));
 }




function change_insertmode(choice) {

      var c_select_1st_x = Math.min(select_1st_x, select_2nd_x)
      var c_select_2nd_x = Math.max(select_1st_x, select_2nd_x)
      var c_select_1st_y = Math.min(select_1st_y, select_2nd_y)
      var c_select_2nd_y = Math.max(select_1st_y, select_2nd_y)

      c_select_1st_x = Math.round(c_select_1st_x/magnification)
      c_select_1st_y = Math.round(c_select_1st_y/magnification)
      c_select_2nd_x = Math.round(c_select_2nd_x/magnification)
      c_select_2nd_y = Math.round(c_select_2nd_y/magnification)

      var x_offset = Math.round((c_select_2nd_x - c_select_1st_x)/2)
      var y_offset = Math.round((c_select_2nd_y - c_select_1st_y)/2)
      var x_center = Math.round((c_select_2nd_x + c_select_1st_x)/2)
      var y_center = Math.round((c_select_2nd_y + c_select_1st_y)/2)



   if (choice == "save") {
 
      var c_single_color = detect_single_color (c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);
      var selected_pattern = screensave_single_color_with_decay(c_single_color,c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);
      // add dimensions and rule name to make it a proper RLE
    
     show_info_window ("You can copy and paste this RLE to another document:\n" + selected_pattern )
     
   }    
   else if (choice == "clear") {
   /*
     for (var j = c_select_1st_y; j<c_select_2nd_y; j++) {
       for (var i = c_select_1st_x; i<c_select_2nd_x; i++) {
           setCell(i,j,background, 0,0,0)
          }
       }
      draw_only_changed_from_list ()

    */
     // the above works, but what if things change?  The following solution is compatible with rotate, flip, etc. Fix them, and this is fixed too.
      var c_single_color = detect_single_color (c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);
      var selected_pattern = save_RLE_patternstring(c_single_color,c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);
      drawPattern_aux(selected_pattern, c_select_1st_x,c_select_1st_y,  1, 1,true,background,0,0);  // erase at old place

    }
   else if (choice == "clear_outside") {
  
    for (var j = 0; j<memoryY; j++) {
       for (var i = 0; i<memoryX; i++) {
         if (i < c_select_1st_x || i >= c_select_2nd_x || j < c_select_1st_y || j >= c_select_2nd_y) {
           setCell(i,j,background, 0,0,0,0)
          // redundant arr[i][j].extra = 0  // temporary - this should be incorporated into setCell
          // redundant arr[i][j].placeholder_extra = 0  // temporary - this should be incorporated into setCell

         }
       }
     }

      draw_only_changed_from_list ()

   
    }

   
   else if (choice == "clear_all") {
     for (var j = 0; j<memoryY; j++) {
       for (var i = 0; i<memoryX; i++) {
           setCell(i,j,background, 0,0,0,0)
           // redundant arr[i][j].extra = 0  // temporary - this should be incorporated into setCell
           arr[i][j].placeholder_extra = 0  // temporary - this should be incorporated into setCell

          }
       }
      draw_only_changed_from_list ()
    }
   else if (choice == "fill") {
     for (var j = c_select_1st_y; j<c_select_2nd_y; j++) {
       for (var i = c_select_1st_x; i<c_select_2nd_x; i++) {
          setCell(i,j,colored_pencil,0,0,0)
       }
     }
      draw_only_changed_from_list ()
    }
   else if (choice == "random_fill") {
     random_fill_percentage = prompt("Random fill percentage:",random_fill_percentage)
     for (var j = c_select_1st_y; j<c_select_2nd_y; j++) {
       for (var i = c_select_1st_x; i<c_select_2nd_x; i++) {
           if (Math.random() < random_fill_percentage/100) {
                 setCell(i,j,colored_pencil,0,0,0)
           }
           else {setCell(i,j,background, 0,0,0)}
          }
       }
      draw_only_changed_from_list ()
    }

   
   else if  (choice == "rotate_cw") {

      var c_single_color = detect_single_color (c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);
      var selected_pattern = save_RLE_patternstring(c_single_color,c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);

      drawPattern_aux(selected_pattern, c_select_1st_x,c_select_1st_y,  1, 1,true,background,0,0);  // erase at old place
      drawPattern_aux(selected_pattern, x_center+y_offset, y_center - x_offset,-1, 1,false,c_single_color,0,0);  // draw at new place
          //ctx2.fillStyle = black;  
          ctx2.clearRect(Math.min(select_1st_x,select_2nd_x),Math.min(select_1st_y,select_2nd_y),Math.abs( select_2nd_x - select_1st_x), Math.abs(select_2nd_y - select_1st_y));
          select_1st_x = x_center*magnification - y_offset*magnification;
          select_1st_y = y_center*magnification - x_offset*magnification;
          select_2nd_x = select_1st_x + y_offset*magnification*2;
          select_2nd_y = select_1st_y + x_offset*magnification*2;
          ctx2.fillStyle=greenish_select_color;  
          ctx2.fillRect(Math.min(select_1st_x,select_2nd_x),Math.min(select_1st_y,select_2nd_y),Math.abs( select_2nd_x - select_1st_x), Math.abs(select_2nd_y - select_1st_y));
 
    }

   else if  (choice == "rotate_ccw") {
      var c_single_color = detect_single_color (c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);
      var selected_pattern = save_RLE_patternstring(c_single_color,c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);

      drawPattern_aux(selected_pattern, c_select_1st_x,c_select_1st_y,  1, 1,true,background,0,0);  // erase at old place
      //       //  x-yoffset, y+xoffset

      drawPattern_aux(selected_pattern, x_center-y_offset, y_center + x_offset,1, -1,false,c_single_color,0,0);  // draw at new place
          //ctx2.fillStyle = black;  
          ctx2.clearRect(Math.min(select_1st_x,select_2nd_x),Math.min(select_1st_y,select_2nd_y),Math.abs( select_2nd_x - select_1st_x), Math.abs(select_2nd_y - select_1st_y));
          select_1st_x = x_center*magnification - y_offset*magnification;
          select_1st_y = y_center*magnification - x_offset*magnification;
          select_2nd_x = select_1st_x + y_offset*magnification*2;
          select_2nd_y = select_1st_y + x_offset*magnification*2;
          ctx2.fillStyle=greenish_select_color;  

          ctx2.fillRect(Math.min(select_1st_x,select_2nd_x),Math.min(select_1st_y,select_2nd_y),Math.abs( select_2nd_x - select_1st_x), Math.abs(select_2nd_y - select_1st_y));
 
    }


   else if (choice == "flip_E-W") {

      var c_single_color = detect_single_color (c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);
      var selected_pattern = save_RLE_patternstring(c_single_color,c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);

      drawPattern_aux(selected_pattern, c_select_1st_x,c_select_1st_y,  1, 1,true,background,0,0);  // erase at old place
      drawPattern_aux(selected_pattern,x_center + x_offset,y_center - y_offset,  -1, 1,true,c_single_color,0,0);  // draw at same place but fipped

    }
   else if (choice == "flip_N-S") {

      var c_single_color = detect_single_color (c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);
      var selected_pattern = save_RLE_patternstring(c_single_color,c_select_1st_x, c_select_1st_y,  c_select_2nd_x, c_select_2nd_y);

      drawPattern_aux(selected_pattern, c_select_1st_x,c_select_1st_y,  1, 1,true,background,0,0);  // erase at old place
      drawPattern_aux(selected_pattern, c_select_1st_x ,y_center + y_offset,  1, -1,true,c_single_color,0,0);  // draw at same place but fipped

    }



   if  (choice == "insert" || choice == "drive" || choice == "orthobullet" || choice == "diagbullet")
       {   pencil_insertmode = choice}
   else if (choice == "clear_all")
       { document.getElementById("insertmode").selectedIndex = 0;
         pencil_insertmode = "insert"
       }
   else {
            document.getElementById("insertmode").selectedIndex = 1;  //   sets the menu to "select" to indicate that the selection is what is being referenced for save, etc.
            pencil_insertmode = "select";  // and then let the program know that the menu now shows select!
         }

};


function change_speed_step(choice) {
   speedstep = choice
};
    


</script>



</body>
</html>



Anon7 - 2021