-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscriptred.py
More file actions
212 lines (181 loc) · 5.72 KB
/
Copy pathscriptred.py
File metadata and controls
212 lines (181 loc) · 5.72 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
from random import randint
name = 'blitzkreig'
def moveTo(x , y , Pirate):
position = Pirate.getPosition()
if position[0] == x and position[1] == y:
return 0
if position[0] == x:
return (position[1] < y) * 2 + 1
if position[1] == y:
return (position[0] > x) * 2 + 2
if randint(1, 2) == 1:
return (position[0] > x) * 2 + 2
else:
return (position[1] < y) * 2 + 1
def checkfriends(pirate , quad ):
sum = 0
up = pirate.investigate_up()[1]
print(up)
down = pirate.investigate_down()[1]
left = pirate.investigate_left()[1]
right = pirate.investigate_right()[1]
ne = pirate.investigate_ne()[1]
nw = pirate.investigate_nw()[1]
se = pirate.investigate_se()[1]
sw = pirate.investigate_sw()[1]
if(quad=='ne'):
if(up == 'friend'):
sum +=1
if(ne== 'friend'):
sum +=1
if(right == 'friend'):
sum +=1
if(quad=='se'):
if(down == 'friend'):
sum +=1
if(right== 'friend'):
sum +=1
if(se == 'friend'):
sum +=1
if(quad=='sw'):
if(down == 'friend'):
sum +=1
if(sw== 'friend'):
sum +=1
if(left == 'friend'):
sum +=1
if(quad=='nw'):
if(up == 'friend'):
sum +=1
if(nw == 'friend'):
sum +=1
if(left == 'friend'):
sum +=1
return sum
def spread(pirate):
sw = checkfriends(pirate ,'sw' )
se = checkfriends(pirate ,'se' )
ne = checkfriends(pirate ,'ne' )
nw = checkfriends(pirate ,'nw' )
my_dict = {'sw': sw, 'se': se, 'ne': ne, 'nw': nw}
sorted_dict = dict(sorted(my_dict.items(), key=lambda item: item[1]))
x, y = pirate.getPosition()
if( x == 0 , y == 0):
return randint(1,4)
if(sorted_dict[list(sorted_dict())[3]] == 0 ):
return randint(1,4)
if(list(sorted_dict())[0] == 'sw'):
return moveTo(x-1 , y+1 , pirate)
elif(list(sorted_dict())[0] == 'se'):
return moveTo(x+1 , y+1 , pirate)
elif(list(sorted_dict())[0] == 'ne'):
return moveTo(x+1 , y-1 , pirate)
elif(list(sorted_dict())[0] == 'nw'):
return moveTo(x-1 , y-1 , pirate)
def ActPirate(pirate):
up = pirate.investigate_up()[0]
down = pirate.investigate_down()[0]
left = pirate.investigate_left()[0]
right = pirate.investigate_right()[0]
x, y = pirate.getPosition()
s = pirate.trackPlayers()
if(pirate.getTeamSignal() != '42069'):
if (
(up == "island1" and s[0] != "myCaptured")
or (up == "island2" and s[1] != "myCaptured")
or (up == "island3" and s[2] != "myCaptured")
):
s = up[-1] + str(x) + "," + str(y - 1)
pirate.setTeamSignal(s)
if (
(down == "island1" and s[0] != "myCaptured")
or (down == "island2" and s[1] != "myCaptured")
or (down == "island3" and s[2] != "myCaptured")
):
s = down[-1] + str(x) + "," + str(y + 1)
pirate.setTeamSignal(s)
if (
(left == "island1" and s[0] != "myCaptured")
or (left == "island2" and s[1] != "myCaptured")
or (left == "island3" and s[2] != "myCaptured")
):
s = left[-1] + str(x - 1) + "," + str(y)
pirate.setTeamSignal(s)
if (
(right == "island1" and s[0] != "myCaptured")
or (right == "island2" and s[1] != "myCaptured")
or (right == "island3" and s[2] != "myCaptured")
):
s = right[-1] + str(x + 1) + "," + str(y)
pirate.setTeamSignal(s)
if pirate.getTeamSignal() == '42069':
x,y = pirate.getPosition()
strp = pirate.getSignal()
print(strp)
if(strp != ''):
try:
xchange =int(strp[0])-2
ychange = int(strp[1])-2
except:
xchange=1
ychange=1
else:
xchange=1
ychange=1
if x==pirate.getDimensionX()-1:
xchange = -1
strp = str(xchange+2)+str(ychange+2)
pirate.setSignal(strp)
print(strp)
print("rchd end")
elif x==0:
xchange = 1
strp = str(xchange+2)+str(ychange+2)
pirate.setSignal(strp)
if y== 0:
ychange = 1
strp = str(xchange+2)+str(ychange+2)
pirate.setSignal(strp)
elif y == pirate.getDimensionY()-1:
ychange = -1
strp = str(xchange+2)+str(ychange+2)
pirate.setSignal(strp)
print(f"{xchange},{ychange}")
return moveTo(x+xchange,y+ychange,pirate)
if pirate.getTeamSignal() != "":
s = pirate.getTeamSignal()
l = s.split(",")
x = int(l[0][1:])
y = int(l[1])
return moveTo(x, y, pirate)
else:
return spread(pirate)
def ActTeam(team):
l = team.trackPlayers()
s = team.getTeamSignal()
team.buildWalls(1)
team.buildWalls(2)
team.buildWalls(3)
if team.getCurrentFrame() < 800:
team.setTeamSignal("42069")
print(team.getCurrentFrame())
else:
if s:
island_no = int(s[0])
signal = l[island_no - 1]
if signal == "myCaptured":
team.setTeamSignal("")
'''
first element of team signal:
0: top left
1: top right
2: bottom right
3: bottom left
second element of team signal:
0: blitzkrieg active
1: blitzkriet inactive
third element of team signal:
island number currently bieng attacked
after third element
coordinates of the island bieng attacked
'''