Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import sys
- import math
- WIDTH = 30
- HEIGHT = 20
- dirs = {'UP': (0, -1), 'RIGHT': (1, 0), 'DOWN': (0, 1), 'LEFT': (-1, 0)}
- def idebug(*args):
- # return
- print(*args, file=sys.stderr)
- def debug(*args):
- # return
- print(*args, file=sys.stderr)
- def get_moves(x, y):
- moves = []
- for move, (dx, dy) in dirs.items():
- if (x + dx, y + dy) not in lights and 0 <= x + dx < WIDTH and 0 <= y + dy < HEIGHT:
- moves.append(move)
- debug(f'moves: {moves}')
- return moves
- cars = {}
- lights = []
- # game loop
- while True:
- # n: total number of players (2 to 4).
- # p: your player number (0 to 3).
- n, p = [int(i) for i in input().split()]
- idebug(n, p)
- for i in range(n):
- # x0: starting X coordinate of lightcycle (or -1)
- # y0: starting Y coordinate of lightcycle (or -1)
- # x1: starting X coordinate of lightcycle (can be the same as X0 if you play before this player)
- # y1: starting Y coordinate of lightcycle (can be the same as Y0 if you play before this player)
- x0, y0, x1, y1 = [int(j) for j in input().split()]
- idebug(x0, y0, x1, y1)
- if cars.get(i):
- cars.get(i).append((x1, y1))
- else:
- cars[i] = [(x1, y1)]
- debug(f'cars: {cars}')
- lights = []
- for c in cars.values():
- lights += c
- lights = set(lights)
- debug(f'lights: {lights}')
- debug(f'cars: {cars}')
- my_car = cars[0]
- debug(f'my car: {my_car}')
- my_pos = my_car.pop()
- debug(f'my_pos: {my_pos}')
- move = random.choice(get_moves(*my_pos))
- # A single line with UP, DOWN, LEFT or RIGHT
- print(move)
Add Comment
Please, Sign In to add comment