Guessing Game Algorithm
Data
- ROWS int constant # of rows
- COLS int constant 3 of columns
- cell custom object with ON and OFF states
- tileset ROWS by COLS 2D array of cells
Cell custom object
- inherited from simpleGame.Sprite object
- state int or enumeration ON or OFF
- getState() and setState()
Initialize grid
- Create tileset as 2d array of cells ROWS by COLS
- Set initial state of each tile to off
- Display the tiles on the screen (inherited from sprite)
Randomize grid
- For each row in ROWS -1
- set an int rowCounter to 0
- for each col in COLS -1
- Roll a random float 0 to 1
- if that value is larger than .5:
- set the current cell's state to ON
- add one to the rowCounter
- if rowCounter is odd
- set state of last cell in this row to ON
- Set parity of final row
- for each col in COLS - 1
- set int colCounter to zero
- for each row in ROWS
- if current cell's state is ON
- if colCounter is odd
- set state of last cell in this coloumn to ON