STARTING = [[10,10],[9,10],[11,10],[11,9],[10,8]] XSIZE = 20 YSIZE = 20 def init_board (): """ This function creates an instance of the board with XSIZE by YSIZE cells. All cells are set to False initially. """ board = [] for y in range(0,YSIZE): board = board + [[False] * XSIZE] return board def set_starting_conf(board): """ This function sets those cells specified in the variable STARTING to True. """ for pos in STARTING: board[pos[1]][pos[0]] = True def printcell(board,x,y): """ This function prints an 'o' if the cell at position x, y is True and '-' if that cell is False. """ if board[y][x]: print 'o', else: print '-', def display_board (board): """ This function prints out a representation of the board. """ print for y in range(0,YSIZE): for x in range(0,XSIZE): printcell(board,x,y) print print def life_neighbors(board,x,y): """ This function takes the representation of the board and two integers, x and y, indicating a position on the board. Complete this function so that it counts how many life neighbors the cell at position x,y has and returns that number. Assume that the board wraps around. That is, if the cell is at the edge of the board, some of its neighbors will be at the opposite edge of the board. The cell at position x,y should not be counted as its own neighbor. """ n = 0 ### ADD YOUR CODE HERE return n def update_board(board): """ This function takes the board representation as parameter. Complete this function such that it calculates what the board in the next generation should look like. """ new_board = init_board() ### ADD YOUR CODE HERE return new_board def main (): board = init_board() set_starting_conf(board) display_board(board) more = raw_input("Press return for the next step; 'q' and return to stop\n") while more != 'q': board = update_board(board) display_board(board) more = raw_input("Press return for the next step; 'q' and return to stop\n") main()