-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclanBattle.py
223 lines (161 loc) · 3.13 KB
/
clanBattle.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
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
DEF = 100
BD = 0
prevAttack4 = False
prevAttack5 = False
attack4Effect = False
BD_B4_set = False
BD_B4 = 0
attack5Effect = 0
BD_B5_set = False
BD_B5 = 0
attack6Effect = False
def attack1():
ATK = 900
a1d = damage(ATK)
# print("a1: " + str(a1d))
return a1d
def attack2():
global DEF
global BD
ATK = 600
BD += BD * 0.5
if BD > DEF:
BD = DEF
a2d = damage(ATK)
# print("a2: " + str(a2d))
return a2d
def attack3():
global prevAttack4
global prevAttack5
ATK = 700
if prevAttack4 and prevAttack5:
ATK = 1200
return damage(ATK)
def attack4():
global DEF
global BD
global attack4Effect
global BD_B4_set
global BD_B4
global prevAttack4
ATK = 400
prevAttack4 = True
result = damage(ATK)
BD += 50
if BD > DEF:
BD_B4_set = True
BD_B4 = BD
BD = DEF
attack4Effect = True
return result
def attack5():
global DEF
global BD
global attack5Effect
global BD_B5_set
global BD_B5
global prevAttack5
ATK = 400
prevAttack5 = True
BD += 30
if BD > DEF:
BD_B5_set = True
BD_B5 = BD
BD = DEF
attack5Effect = 2
a5d = damage(ATK)
return a5d
def attack6():
global DEF
global BD
global attack6Effect
ATK = 1200
a6d = damage(ATK)
# print("a6: " + str(a6d))
attack6Effect = True
return a6d
def damage(ATK):
global DEF
global BD
global attack4Effect
global BD_B4_set
global BD_B4
global attack5Effect
global BD_B5_set
global BD_B5
global attack6Effect
if attack6Effect:
DEF = 150
BD = 0
result = ATK * (100 / ((DEF - BD) + 100))
if attack4Effect:
attack4Effect = False
if BD_B4_set:
BD = BD_B4
else:
BD = 0 # -= 50
if attack5Effect > 0:
attack5Effect -= 1
if attack5Effect == 0:
if BD_B5_set:
BD = BD_B5
else:
# BD -= 30
BD = 0
return result
def reset():
global DEF
global BD
global attack4Effect
global BD_B4_set
global BD_B4
global prevAttack4
global attack5Effect
global BD_B5_set
global BD_B5
global prevAttack5
global attack6Effect
DEF = 100
BD = 0
prevAttack4 = False
prevAttack5 = False
attack4Effect = False
BD_B4_set = False
BD_B4 = 0
attack5Effect = 0
BD_B5_set = False
BD_B5 = 0
attack6Effect = False
"""
total1 = attack1() + attack5() + attack2() + attack6()
fitness1 = round(total1, 2)
print("1,5,2,6: " + str(fitness1))
reset()
total2 = attack1() + attack2() + attack4() + attack3()
fitness2 = round(total2, 2)
print("1,2,4,3: " + str(fitness2))
reset()
total3 = attack4() + attack3() + attack6() + attack3()
fitness3 = round(total3, 2)
print("4,3,6,3: " + str(fitness3))
reset()
total4 = attack2() + attack4() + attack2() + attack4()
fitness4 = round(total4, 2)
print("2,4,2,4: " + str(fitness4))
"""
# Crossovers
total12 = attack1() + attack2() + attack2() + attack6()
fitness12 = round(total12, 2)
print("1,2,2,6: " + str(fitness12))
reset()
total21 = attack1() + attack5() + attack4() + attack3()
fitness21 = round(total21, 2)
print("1,5,4,3: " + str(fitness21))
reset()
total34 = attack2() + attack4() + attack6() + attack3()
fitness34 = round(total34, 2)
print("2,4,6,3: " + str(fitness34))
reset()
total43 = attack4() + attack3() + attack2() + attack4()
fitness43 = round(total43, 2)
print("4,3,2,4: " + str(fitness43))