Created
June 8, 2011 22:33
-
-
Save buzzedword/1015612 to your computer and use it in GitHub Desktop.
Console tic tac toe.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var grid; | |
| function Grid() { | |
| var grid, quadrant, dash, stilt, breaks; | |
| dash = '-------------------------'; | |
| stilt = '| | | |'; | |
| breaks = '\n\r'; | |
| quadrant = { | |
| x0y0 : ' ', | |
| x1y0 : ' ', | |
| x2y0 : ' ', | |
| x0y1 : ' ', | |
| x1y1 : ' ', | |
| x2y1 : ' ', | |
| x0y2 : ' ', | |
| x1y2 : ' ', | |
| x2y2 : ' ' | |
| }; | |
| function addBreaks( line ) { | |
| var appended = ''; | |
| appended = line + breaks; | |
| return appended; | |
| } | |
| function modifier( param ){ | |
| var X = param.quadrant.x, Y = param.quadrant.y, bit = param.value, bitswitch; | |
| bitswitch = quadrant['x'+X+'y'+Y]; | |
| } | |
| grid = addBreaks(''); | |
| grid += addBreaks(dash); | |
| grid += addBreaks(stilt) + addBreaks(stilt) + addBreaks(stilt); | |
| grid += addBreaks(dash); | |
| grid += addBreaks(stilt) + addBreaks(stilt) + addBreaks(stilt); | |
| grid += addBreaks(dash); | |
| grid += addBreaks(stilt) + addBreaks(stilt) + addBreaks(stilt); | |
| grid += addBreaks(dash); | |
| return { | |
| draw : grid, | |
| quadrant : quadrant, | |
| components : { | |
| breaks : breaks, | |
| stilt : stilt, | |
| dash : dash | |
| } | |
| }; | |
| } | |
| grid = new Grid(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment