-
Notifications
You must be signed in to change notification settings - Fork 18
/
scriptblue.py
88 lines (72 loc) · 2.3 KB
/
scriptblue.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
87
88
import random
import math
name = "scriptblue"
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 random.randint(1, 2) == 1:
return (position[0] > x) * 2 + 2
else:
return (position[1] < y) * 2 + 1
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()
pirate.setSignal("")
s = pirate.trackPlayers()
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() != "":
s = pirate.getTeamSignal()
l = s.split(",")
x = int(l[0][1:])
y = int(l[1])
return moveTo(x, y, pirate)
else:
return random.randint(1, 4)
def ActTeam(team):
l = team.trackPlayers()
s = team.getTeamSignal()
team.buildWalls(1)
team.buildWalls(2)
team.buildWalls(3)
# print(team.getTeamSignal())
# print(team.trackPlayers())
if s:
island_no = int(s[0])
signal = l[island_no - 1]
if signal == "myCaptured":
team.setTeamSignal("")