def spawn_wall_container(self, grid): self.wall_container = WallContainer( len(grid[0]) * self.scale, len(grid) * self.scale) for row_i in range(0, len(grid)): for cell_i in range(0, len(grid[row_i])): cell = grid[row_i][cell_i] if cell == 1: y_1 = row_i * self.scale y_2 = y_1 + self.scale x_1 = cell_i * self.scale x_2 = x_1 + self.scale self.wall_container.add(Wall(x_1, y_1, x_2, y_2))
window = turtle.Screen() window.title('Robomaster') window.bgcolor('white') turtle.register_shape('game_over.gif') def Fire(): tank.gun.fire(tank.getPosition(), tank) # Wall(x, y, width, height) width = global_vals.WIDTH height = global_vals.HEIGHT Wall(0, height / 2 + 5, width + 20, 10) Wall(0, -height / 2 - 5, width + 20, 10) # top and bottom Wall(width / 2 + 5, 0, 10, height) Wall(-width / 2 - 5, 0, 10, height) # sides Wall(0, height / 2 - 25, 100, 50) Wall(0, -height / 2 + 25, 100, 50) # D Wall(0, 0, 100, 25) #center Wall(width / 2 - 140 - 12.5, 50, 25, 100) Wall(-width / 2 + 140 + 12.5, -50, 25, 100) tank = Tank(100, 100)
from mahjong.agari import Agari from mahjong.meld import Meld import numpy as np c = HandCalculator() st = Shanten() ag = Agari() ops = 1e7 # Control Code k = 0 cstart = time.time_ns() while k < ops: k += 1 w = Wall() hand = Hand(w) hand.draw(w) cend = time.time_ns() # Test Code k = 0 start = time.time_ns() while k < ops: k += 1 w = Wall() hand = Hand(w) hand.draw(w) win = ag.is_agari(hand.tiles34)
# pygame pygame.display.update() fps_clock.tick(60) # setup obstacles obstacles_present = False if obstacles_map != None: obstacles_present = True width = map_builder.x_increment for c, _ in enumerate(obstacles_map): height = 0 x = map_builder.x + (c * map_builder.x_increment) y = map_builder.y current_wall = Wall(width, height, x, y) for r, box in enumerate(obstacles_map[c]): y += map_builder.y_increment if box: height += map_builder.y_increment current_wall.height = height if not box or r == len(obstacles_map[0]) - 1: if current_wall.height != 0: obstacles.append(current_wall) current_wall = Wall(width, 0, x, y) height = 0 # gene pool gene_pool = GenePool()