예제 #1
0
파일: main.py 프로젝트: fran757/tdlog
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()
예제 #2
0
 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])
예제 #3
0
    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])
예제 #4
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)
예제 #5
0
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)
예제 #6
0
 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()
예제 #7
0
# 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()
예제 #8
0
 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")
예제 #9
0
 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])
예제 #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)
예제 #11
0
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')
예제 #12
0
 def build(self):
     game = PongGame()
     game.serve_ball()
     grid = Grid(*game.size)
     Clock.schedule_interval(game.update, 1.0 / 60.0)
     return game
예제 #13
0
def build_fixture(name):
    """build game from fixture name"""
    return Game(Grid(fixture_name(name)), None)