def test_list(struclist, gridsize, rounds, failisblank=True, failnochange=False): ''' Takes a list of structures, places each of them on the gameboard in the lower right quadrent, and tests it for x number of rounds. Returns a list of strucures that have passed ''' results = [] for structure in struclist: game = GOL(gridsize, gridsize) game.add_structure(structure, xoffset=int(gridsize / 2), yoffset=int(gridsize / 2)) result = game.test(rounds, failisblank=failisblank, failnochange=failnochange) if result == True: results.append(structure) return results
def test_iterations(structuresize, gridsize, rounds, failisblank=True, failnochange=False): ''' Generates a list of all possible structures based on structuresize (a sqare grid) tests them for rounds, and returns the ones that pass ''' teststructures = generate_binary_grid(structuresize) results = [] for structure in teststructures: game = GOL(gridsize, gridsize) game.add_structure(structure, xoffset=int(gridsize / 2), yoffset=int(gridsize / 2)) result = game.test(rounds, failisblank=failisblank, failnochange=failnochange) if result == True: results.append(structure) return results