Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import math
- import numpy
- PAC_TYPE = ['ROCK', 'PAPER', 'SCISSORS'] # [0, 1, 2]
- WIN_TABLE = {0: 2, 2: 1, 1: 0} # {"ROCK": "SCISSORS", "SCISSORS": "PAPER", "PAPER": "ROCK"}
- def debug(*args):
- print(*args, file=sys.stderr)
- class Game:
- def __init__(self):
- self.walls_array = numpy.zeros(shape=(WIDTH, HEIGHT), dtype=numpy.int)
- self.pacs = numpy.zeros(shape=(2, 5, 7), dtype=numpy.int) # [team_id, [pac_id, [x, y, type_id, speed_turns_left, ability_cooldown, visible, is_dead]]]
- self.pellets = numpy.zeros(shape=(WIDTH, HEIGHT), dtype=numpy.int) # value
- self.pacs_per_player = 0
- def __repr__(self):
- # return f'GRID ({WIDTH},{HEIGHT}):\n{self.walls_array.T}\nPACS:\n{self.pacs}\nPELLETS:\n{self.pellets.T}\nPACS_COUNT: {self.pacs_per_player}'
- return f'PELLETS:\n{self.pellets.T}'
- def update(self):
- if self.pacs_per_player:
- self.pacs[0, :, 5] = 0 # set not visible for enemy pacs (team_id = 0)
- my_score, opponent_score = [int(i) for i in input().split()]
- debug(my_score, opponent_score)
- visible_pac_count = int(input()) # all your pacs and enemy pacs in sight
- debug(visible_pac_count)
- for i in range(visible_pac_count):
- inputs = input().split()
- debug(*inputs)
- pac_id = int(inputs[0]) # pac number (unique within a team)
- team_id = int(inputs[1]) # 1 if this pac is yours
- x = int(inputs[2]) # position in the grid
- y = int(inputs[3]) # position in the grid
- type_id = PAC_TYPE.index(inputs[4]) # unused in wood leagues
- speed_turns_left = int(inputs[5]) # unused in wood leagues
- ability_cooldown = int(inputs[6]) # unused in wood leagues
- self.pacs[team_id, pac_id] = numpy.array([x, y, type_id, speed_turns_left, ability_cooldown, 1, 1]) # visible, alive
- # Initialisation du nombre de pacs
- if not self.pacs_per_player:
- self.pacs_per_player = len(game.pacs[1])
- self.pacs.resize((2, self.pacs_per_player, 7))
- visible_pellet_count = int(input()) # all pellets in sight
- debug(visible_pellet_count)
- for i in range(visible_pellet_count):
- # value: amount of points this pellet is worth
- x, y, value = [int(j) for j in input().split()]
- self.pellets[x, y] = value
- debug(x, y, value)
- def is_wall(self, x, y):
- return self.walls_array[x, y] != 0
- def set_wall(self, x, y):
- self.walls_array[x, y] = 1
- # Grab the pellets as fast as you can!
- # width: size of the grid
- # height: top left corner is (x=0, y=0)
- WIDTH, HEIGHT = [int(i) for i in input().split()]
- debug(WIDTH, HEIGHT)
- game = Game()
- for i in range(HEIGHT):
- row = input() # one line of the grid: space " " is floor, pound "#" is wall
- debug(row)
- for j, c in enumerate(row):
- if c == "#":
- game.set_wall(j, i)
- # game loop
- while True:
- game.update()
- debug(game)
- # MOVE <pacId> <x> <y>
- print("MOVE 0 15 10")
Add Comment
Please, Sign In to add comment