-
Notifications
You must be signed in to change notification settings - Fork 5
/
stream-code.py
86 lines (71 loc) · 2.8 KB
/
stream-code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import sys
import math
# Code created during the live on twitch around 19pm on June
# it was top wood 2 before nerfs, and now top wood 1
# thank you jmpeg for this print err function <3
def log(*args): print(*args, file=sys.stderr, flush=True)
# UP RIGHT DOWN LEFT
directions = [[0, -1], [1,0], [0,1], [-1,0]]
class Grid():
def __init__(self):
self.g = []
self.width = 0
self.height = 0
def read(self):
self.width = int(input())
self.height = int(input())
for i in range(self.height):
self.g.append( input() )
def __str__(self):
return "\n".join(self.g)
grid = Grid()
grid.read()
log(grid)
# sanity_loss_lonely: how much sanity you lose every turn when alone, always 3 until wood 1
# sanity_loss_group: how much sanity you lose every turn when near another player, always 1 until wood 1
# wanderer_spawn_time: how many turns the wanderer take to spawn, always 3 until wood 1
# wanderer_life_time: how many turns the wanderer is on map after spawning, always 40 until wood 1
sanity_loss_lonely, sanity_loss_group, wanderer_spawn_time, wanderer_life_time = [int(i) for i in input().split()]
class Unit:
def __init__(self,x ,y, id):
self.x = x
self.y = y
self.id = id
def distance(self, other):
return abs(self.x - other.x) + abs(self.y - other.y)
def __str__(self):
return "{0} [{1}:{2}]".format(self.id,self.x, self.y)
class Explorer(Unit):
def __init__(self, x, y, id, lights):
Unit.__init__(self, x, y, id)
self.lights = lights
def __str__(self):
return "Ex {0} [{1}:{2}] {3}".format(self.id,self.x, self.y, self.lights)
# game loop
while True:
entity_count = int(input()) # the first given entity corresponds to your explorer
explorers = []
minions = []
iHaveALight = False
for i in range(entity_count):
entity_type, id, x, y, param_0, param_1, param_2 = input().split()
id = int(id)
x = int(x)
y = int(y)
param_0 = int(param_0)
param_1 = int(param_1)
param_2 = int(param_2)
if entity_type == "EXPLORER":
explorer = Explorer(x, y, id, param_2)
explorers.append( explorer )
elif entity_type == "WANDERER":
minion = Unit(x, y, id)
minions.append( minion )
elif entity_type == "EFFECT_LIGHT":
iHaveALight = (id == 0) or iHaveALight
# if no minion on the map, just move to the nearest player
# if there is a minion next to you, move aside
# if you have lights, you aren't using one, minions are not too close and explorer aren't too far
# -> light up
# if a minion is close move away
# otherwise go to the nearest player