bzr branch
/chaos
| Line | Revision | Contents |
| 1 | 1 | <?php $fb_user = $facebook->require_add(); ?> |
| 2 | <div> |
|
| 3 | <script language="javascript"> |
|
| 4 | var sq = 7 |
|
| 5 | var sq2 = sq |
|
| 6 | var max_x = 84 |
|
| 7 | var max_y = 56 |
|
| 8 | var x = 36 |
|
| 9 | var y = max_y / 2 |
|
| 10 | var grid = new Array(max_y) |
|
| 11 | var counter = 0 |
|
| 12 | var movx = 0 |
|
| 13 | var movy = 0 |
|
| 14 | var html = "" |
|
| 15 | for (i=0; i<=max_y; i++) { grid[i] = new Array(max_x)
|
|
| 16 | } |
|
| 17 | for (cy=0; cy<=max_y; cy++) { for (cx=0; cx<=max_x; cx++) { grid[cy][cx] = 0
|
|
| 18 | html = html+"<div id='x"+cx+"y"+cy+"' style='position:absolute; top:"+cy*sq+"px; left:"+cx*sq+"px; width:"+sq2+"px; height:"+sq2+"px; z-index:1; background-color:#FFFFFF'></div>" |
|
| 19 | } |
|
| 20 | } |
|
| 21 | function MoveSnake() { document.getElementById("grid").style.top = y*sq
|
|
| 22 | document.getElementById("grid").style.left = x*sq
|
|
| 23 | } |
|
| 24 | function odd(value) { var binary = value.toString(2); if (binary.charAt(binary.length - 1) == "1") { return false;}
|
|
| 25 | else { return true;}
|
|
| 26 | } |
|
| 27 | function Logic() { if (grid[y][x] == 0) { grid[y][x] = 1
|
|
| 28 | id = "x"+x+"y"+y |
|
| 29 | document.getElementById(id).style.backgroundColor = "#000000" |
|
| 30 | if (counter == 0) {movy = -1; movx = 0}
|
|
| 31 | if (movy == -1) { movy = 0; movx = -1
|
|
| 32 | } else { if (movx == -1) { movx = 0; movy = 1
|
|
| 33 | } else { if (movy == 1) { movx = 1; movy = 0
|
|
| 34 | } else { if (movx == 1) { movx = 0; movy = -1
|
|
| 35 | } |
|
| 36 | } |
|
| 37 | } |
|
| 38 | } |
|
| 39 | x = x + movx |
|
| 40 | y = y + movy |
|
| 41 | } else { grid[y][x] = 0
|
|
| 42 | id = "x"+x+"y"+y |
|
| 43 | document.getElementById(id).style.backgroundColor = "#3B5998" |
|
| 44 | if (movy == -1) { movy = 0; movx = 1
|
|
| 45 | } else { if (movx == -1) { movx = 0; movy = -1
|
|
| 46 | } else { if (movy == 1) { movx = -1; movy = 0
|
|
| 47 | } else { if (movx == 1) { movx = 0; movy = 1
|
|
| 48 | } |
|
| 49 | } |
|
| 50 | } |
|
| 51 | } |
|
| 52 | x = x + movx |
|
| 53 | y = y + movy |
|
| 54 | } |
|
| 55 | MoveSnake() |
|
| 56 | counter = counter + 1 |
|
| 57 | document.form1.counter.value = counter |
|
| 58 | } |
|
| 59 | html = html+"<div id='grid' style='position:absolute; background-color:#000FFF; z-index:2; width:"+sq+"px; height:"+sq+"px;'></div>" |
|
| 60 | html = html+"<div style='position:absolute; top:"+sq2+"px; left:"+sq2+"px; z-index:2;'><form name='form1'><input id='counter' name='counter' type='text' value='0' style='font:Arial; font-size:12px; font-weight: bold; color:#000000; background-color:#0000000;'/></form></div>" |
|
| 61 | document.write(html) |
|
| 62 | setInterval("Logic()",1)
|
|
| 63 | </script> |
|
| 64 | ||
| 65 | </div> |
|
| 66 | <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> |
|
| 67 | </script> |
|
| 68 | <script type="text/javascript"> |
|
| 69 | _uacct = "UA-2645625-6"; |
|
| 70 | urchinTracker(); |
|
| 71 | </script> |
|
| 72 | <br/><br/> |
|
| 73 | <br/> |
|
| 74 | <br/> |
|
| 75 | <br/> |
|
| 76 | <br/> |
|
| 77 | <br/> |
|
| 78 | <br/> |
|
| 79 | <br/> |
|
| 80 | <br/> |
|
| 81 | <br/> |
|
| 82 | <br/> |
|
| 83 | <br/> |
|
| 84 | <br/> |
|
| 85 | <br/> |
|
| 86 | <br/> |
|
| 87 | <br/> |
|
| 88 | <br/> |
|
| 89 | <br/> |
|
| 90 | <br/> |
|
| 91 | <br/> |
|
| 92 | <br/> |
|
| 93 | <br/> |
|
| 94 | <br/> |
|
| 95 | <br/> |
|
| 96 | <br/> |
|
| 97 | <p>The experiment above consists of the following rules:</p> |
|
| 98 | <li> If the square is white/blue - move forward 1 space & rotate 90 degrees left. Reset. |
|
| 99 | <li> If the square is black - move forward 1 space & rotate 90 degrees right. Reset. |
|
| 100 | ||
| 101 | <p> It's amazing to that with just these simple rules such chaos can emerge. |
|
| 102 | <p> Watch carefully around the 10,000 mark.. something quite strange happens. |
Loggerhead 1.17 is a web-based interface for Bazaar branches