Advertisement
philRG

Ocean of code - reloaded from scratch

Apr 16th, 2021
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.87 KB | None | 0 0
  1. import random
  2. import sys
  3. import math
  4.  
  5.  
  6. def idebug(*args):
  7.     # return
  8.     print(*args, file=sys.stderr, flush=True)
  9.  
  10.  
  11. def debug(*args):
  12.     # return
  13.     print(*args, file=sys.stderr, flush=True)
  14.  
  15.  
  16. def init_game_tester():
  17.     global width, height, my_id, map
  18.     width, height, my_id = 15, 15, 0
  19.     map = [['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
  20.            ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
  21.            ['.', '.', '.', '.', '.', '.', 'x', 'x', '.', '.', '.', '.', '.', 'x', 'x'],
  22.            ['.', '.', '.', '.', '.', '.', 'x', 'x', '.', '.', '.', '.', '.', 'x', 'x'],
  23.            ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
  24.            ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
  25.            ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
  26.            ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
  27.            ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
  28.            ['.', '.', '.', '.', '.', '.', '.', 'x', 'x', 'x', 'x', '.', '.', '.', '.'],
  29.            ['.', '.', '.', '.', '.', '.', '.', 'x', 'x', 'x', 'x', 'x', '.', 'x', 'x'],
  30.            ['.', '.', '.', '.', '.', '.', '.', 'x', 'x', 'x', 'x', 'x', '.', 'x', 'x'],
  31.            ['.', '.', '.', '.', '.', '.', '.', '.', '.', 'x', 'x', 'x', '.', '.', '.'],
  32.            ['x', 'x', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
  33.            ['x', 'x', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.']]
  34.  
  35.  
  36. def init_game():
  37.     global width, height, my_id, map, history, sea
  38.     width, height, my_id = [int(i) for i in input().split()]
  39.     idebug(width, height, my_id)
  40.     map = []
  41.     for i in range(height):
  42.         line = input()
  43.         idebug(line)
  44.         map.append(list(line))
  45.     idebug(map)
  46.  
  47.     sea = [(x, y) for x in range(width) for y in range(height) if map[x][y] == '.']
  48.  
  49.     x, y = random.choice(sea)
  50.     history = [(x, y)]
  51.  
  52.     print(f'{x} {y}')
  53.  
  54.  
  55. def do_turn():
  56.     line = input()
  57.     idebug(line)
  58.     x, y, my_life, opp_life, torpedo_cooldown, sonar_cooldown, silence_cooldown, mine_cooldown = [int(i) for i in line.split()]
  59.     sonar_result = input()
  60.     idebug(sonar_result)
  61.     opponent_orders = input()
  62.     idebug(opponent_orders)
  63.  
  64.     '''
  65.        1 - Read opponent orders:
  66.            MOVE N
  67.            MOVE N | TORPEDO x y
  68.            SURFACE n
  69.    '''
  70.     # opponent_orders = 'MOVE N'
  71.     # opponent_orders = 'MOVE N | TORPEDO 3 5'
  72.     op_orders = [order.strip() for order in opponent_orders.split('|')]
  73.     debug(f'op_orders: {op_orders}')
  74.  
  75.     print("MOVE N TORPEDO")
  76.  
  77.  
  78. if __name__ == '__main__':
  79.     init_game()
  80.     # init_game_tester()
  81.  
  82.     # game loop
  83.     while True:
  84.         do_turn()
  85.         # debug('Tester')
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement