def main(): try: key = sys.argv[1].split("-", 1)[1] except: key = "c" path = os.getcwd() + "/model/grid.txt" Game(Grid(path), App(key)).play()
def test_propagate(self): grid = Grid(8, 8) grid.add_source(Source(2, 1)) grid.propagate() print (grid) self.assertEqual(grid[0], [2, 2, 2, 2]) self.assertEqual(grid[1], [1, 1, 1, 2]) self.assertEqual(grid[2], [1, 0, 1, 2]) self.assertEqual(grid[3], [1, 1, 1, 2])
def test_propagate_short(self): grid = Grid(8, 8) grid.add_source(Source(2, 1)) grid.propagate(9) self.assertEqual(grid[0], [999.0, 999.0, 999.0, 999.0]) self.assertEqual(grid[1], [1, 1, 1, 999.0]) self.assertEqual(grid[2], [1, 0, 1, 999.0]) self.assertEqual(grid[3], [1, 1, 1, 999.0])
def main(width, height, cells): live_cells = [[ random.randint(0, width - 1), random.randint(0, height - 1) ] for _ in range(cells)] grid = Grid(width, height) grid.set_alive(live_cells) while not grid.stale: tmp = os.system('clear') grid.play() time.sleep(0.5)
def create_objects(params, locIncome, PrintGrids): income = Income.Income(params, locIncome, False) params.addIncomeParameters(income) grids = Grid.Grid(params, income) if PrintGrids: print('Cash grid:') functions.printVector(grids.x_flat) print('Consumption grid:') functions.printVector(grids.c_flat) quit() return (grids, income)
def __init__(self, v): # Pass the view into the grid to allow the model to update self.g = Grid.Grid(v) self.g.add_neighbours()
# No need for this line below # ! C:\Users\USER\AppData\Local\Programs\Python\Python37-32\python.exe # Please follow Pep reccomendations, I # f using Pycharm, you should have the warnings and you can fix them just by clicking on code -> reformat code import webview from model import Grid if __name__ == "__main__": grid = Grid() w = webview.create_window("hello world", url="vue.html", js_api=grid) w.expose(grid.get_cell) webview.start()
def test_grid_creation(self): grid = Grid(100, 100) self.assertEqual(len(grid), 50, "Correct row size") self.assertEqual(len(grid[0]), 50, "Correct column size")
def test_grid_update(self): grid = Grid(4, 4) grid[1][1] = 10.0 self.assertEqual (grid[0], [999.0] * 2) self.assertEqual (grid[1], [999.0, 10.0])
def test_grid_printing(self): grid = Grid(4, 4) self.assertEqual (grid[0], [999.0] * 2) self.assertEqual (grid[1], [999.0] * 2)
from model import Grid from view import View from uav import Uav pygame.init() # Loop until the user clicks the close button. done = False # Used to manage how fast the screen updates clock = pygame.time.Clock() # initialize the map (size, num_targets) size = 40 targets = 5 data = Grid(size, targets) # define drones num_drones = 10 drones = [Uav(1, 1, data)] for m in range(num_drones - 1): drones.append(Uav(m + 1, 1, data)) # init the view of the map view = View(600, data, drones) # max fps at which to run fps = 10 counter = 0 raw_input('Press <ENTER> to begin')
def build(self): game = PongGame() game.serve_ball() grid = Grid(*game.size) Clock.schedule_interval(game.update, 1.0 / 60.0) return game
def build_fixture(name): """build game from fixture name""" return Game(Grid(fixture_name(name)), None)