-
Notifications
You must be signed in to change notification settings - Fork 2
/
battle_simulator_multiple_pokemon.pcsp
177 lines (162 loc) · 9.34 KB
/
battle_simulator_multiple_pokemon.pcsp
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
#define active 1; //trainer active
#define inactive 0; //trainer inactive
#define win 2; // trainer wins
#define lose -1; //trainer loses
var trainer[2] = [active, inactive]; //initial trainer states
var currentPokemon[2] = [0, 0]; // index of trainers current pokemon
var trainer0AttackStats[6] = [1, 1, 1, 1, 1, 1];
var trainer0DefenceStats[6] = [1, 1, 1, 1, 1, 1];
var trainer0HealthStats[6] = [10, 10, 10, 10, 10, 10];
var trainer0Levels[6] = [1, 1, 1, 1, 1, 1];
var trainer0pokemon0moves = [90, 90, 100, 80];
var trainer0pokemon1moves = [90, 90, 100, 80];
var trainer0pokemon2moves = [90, 90, 100, 80];
var trainer0pokemon3moves = [90, 90, 100, 80];
var trainer0pokemon4moves = [90, 90, 100, 80];
var trainer0pokemon5moves = [90, 90, 100, 80];
var trainer1AttackStats[6] = [1, 1, 1, 1, 1, 1];
var trainer1DefenceStats[6] = [1, 1, 1, 1, 1, 1];
var trainer1HealthStats[6] = [10, 10, 10, 10, 10, 10];
var trainer1Levels[6] = [1, 1, 1, 1, 1, 1];
var trainer1pokemon0moves = [90, 90, 100, 80];
var trainer1pokemon1moves = [90, 90, 100, 80];
var trainer1pokemon2moves = [90, 90, 100, 80];
var trainer1pokemon3moves = [90, 90, 100, 80];
var trainer1pokemon4moves = [90, 90, 100, 80];
var trainer1pokemon5moves = [90, 90, 100, 80];
rotate() =
[trainer[0] == active && trainer[1] == inactive]switchTrainer{trainer[0] = inactive; trainer[1] = active} -> move(1)
[]
[trainer[1] == active && trainer[0] == inactive]switchTrainer{trainer[1] = inactive; trainer[0] = active} -> move(0);
move(i) =
[i == 0 && currentPokemon[1] == 0]attackFoe.i -> attack(i, 0)
[]
[i == 0 && currentPokemon[1] == 1]attackFoe.i -> attack(i, 1)
[]
[i == 0 && currentPokemon[1] == 2]attackFoe.i -> attack(i, 2)
[]
[i == 0 && currentPokemon[1] == 3]attackFoe.i -> attack(i, 3)
[]
[i == 0 && currentPokemon[1] == 4]attackFoe.i -> attack(i, 4)
[]
[i == 0 && currentPokemon[1] == 5]attackFoe.i -> attack(i, 5)
[]
[i == 1 && currentPokemon[0] == 0]attackFoe.i -> attack(i, 0)
[]
[i == 1 && currentPokemon[0] == 1]attackFoe.i -> attack(i, 1)
[]
[i == 1 && currentPokemon[0] == 2]attackFoe.i -> attack(i, 2)
[]
[i == 1 && currentPokemon[0] == 3]attackFoe.i -> attack(i, 3)
[]
[i == 1 && currentPokemon[0] == 4]attackFoe.i -> attack(i, 4)
[]
[i == 1 && currentPokemon[0] == 5]attackFoe.i -> attack(i, 5);
attack(i, m) = [i == 0 && currentPokemon[i] == 0]pokemon0attack -> pcase {
[0.25]: damage(0, trainer0pokemon0moves[0], m)
[0.25]: damage(0, trainer0pokemon0moves[1], m)
[0.25]: damage(0, trainer0pokemon0moves[2], m)
[0.25]: damage(0, trainer0pokemon0moves[3], m)
} [] [i == 0 && currentPokemon[i] == 1]pokemon0attack -> pcase {
[0.25]: damage(0, trainer0pokemon1moves[0], m)
[0.25]: damage(0, trainer0pokemon1moves[1], m)
[0.25]: damage(0, trainer0pokemon1moves[2], m)
[0.25]: damage(0, trainer0pokemon1moves[3], m)
} [] [i == 0 && currentPokemon[i] == 2]pokemon0attack -> pcase {
[0.25]: damage(0, trainer0pokemon2moves[0], m)
[0.25]: damage(0, trainer0pokemon2moves[1], m)
[0.25]: damage(0, trainer0pokemon2moves[2], m)
[0.25]: damage(0, trainer0pokemon2moves[3], m)
} [] [i == 0 && currentPokemon[i] == 3]pokemon0attack -> pcase {
[0.25]: damage(0, trainer0pokemon3moves[0], m)
[0.25]: damage(0, trainer0pokemon3moves[1], m)
[0.25]: damage(0, trainer0pokemon3moves[2], m)
[0.25]: damage(0, trainer0pokemon3moves[3], m)
} [] [i == 0 && currentPokemon[i] == 4]pokemon0attack -> pcase {
[0.25]: damage(0, trainer0pokemon4moves[0], m)
[0.25]: damage(0, trainer0pokemon4moves[1], m)
[0.25]: damage(0, trainer0pokemon4moves[2], m)
[0.25]: damage(0, trainer0pokemon4moves[3], m)
} [] [i == 0 && currentPokemon[i] == 5]pokemon0attack -> pcase {
[0.25]: damage(0, trainer0pokemon5moves[0], m)
[0.25]: damage(0, trainer0pokemon5moves[1], m)
[0.25]: damage(0, trainer0pokemon5moves[2], m)
[0.25]: damage(0, trainer0pokemon5moves[3], m)
} [] [i == 1 && currentPokemon[i] == 0]pokemon1attack -> pcase {
[0.25]: damage(1, trainer1pokemon0moves[0], m)
[0.25]: damage(1, trainer1pokemon0moves[1], m)
[0.25]: damage(1, trainer1pokemon0moves[2], m)
[0.25]: damage(1, trainer1pokemon0moves[3], m)
} [] [i == 1 && currentPokemon[i] == 1]pokemon1attack -> pcase {
[0.25]: damage(1, trainer1pokemon1moves[0], m)
[0.25]: damage(1, trainer1pokemon1moves[1], m)
[0.25]: damage(1, trainer1pokemon1moves[2], m)
[0.25]: damage(1, trainer1pokemon1moves[3], m)
} [] [i == 1 && currentPokemon[i] == 2]pokemon0attack -> pcase {
[0.25]: damage(1, trainer1pokemon2moves[0], m)
[0.25]: damage(1, trainer1pokemon2moves[1], m)
[0.25]: damage(1, trainer1pokemon2moves[2], m)
[0.25]: damage(1, trainer1pokemon2moves[3], m)
} [] [i == 1 && currentPokemon[i] == 3]pokemon1attack -> pcase {
[0.25]: damage(1, trainer1pokemon3moves[0], m)
[0.25]: damage(1, trainer1pokemon3moves[1], m)
[0.25]: damage(1, trainer1pokemon3moves[2], m)
[0.25]: damage(1, trainer1pokemon3moves[3], m)
} [] [i == 1 && currentPokemon[i] == 4]pokemon1attack -> pcase {
[0.25]: damage(1, trainer1pokemon4moves[0], m)
[0.25]: damage(1, trainer1pokemon4moves[1], m)
[0.25]: damage(1, trainer1pokemon4moves[2], m)
[0.25]: damage(1, trainer1pokemon4moves[3], m)
} [] [i == 1 && currentPokemon[i] == 5]pokemon1attack -> pcase {
[0.25]: damage(1, trainer1pokemon5moves[0], m)
[0.25]: damage(1, trainer1pokemon5moves[1], m)
[0.25]: damage(1, trainer1pokemon5moves[2], m)
[0.25]: damage(1, trainer1pokemon5moves[3], m)
};
damage(i, p, m) =
[i == 0 && m == 0]damageFoe.i{trainer1HealthStats[m] = trainer1HealthStats[m] - (((((2*trainer1Levels[m])/5) + 2)*p*(trainer1AttackStats[m]/trainer1DefenceStats[m])/50) + 2)} -> switch(1, m)
[]
[i == 0 && m == 1]damageFoe.i{trainer1HealthStats[m] = trainer1HealthStats[m] - (((((2*trainer1Levels[m])/5) + 2)*p*(trainer1AttackStats[m]/trainer1DefenceStats[m])/50) + 2)} -> switch(1, m)
[]
[i == 0 && m == 2]damageFoe.i{trainer1HealthStats[m] = trainer1HealthStats[m] - (((((2*trainer1Levels[m])/5) + 2)*p*(trainer1AttackStats[m]/trainer1DefenceStats[m])/50) + 2)} -> switch(1, m)
[]
[i == 0 && m == 3]damageFoe.i{trainer1HealthStats[m] = trainer1HealthStats[m] - (((((2*trainer1Levels[m])/5) + 2)*p*(trainer1AttackStats[m]/trainer1DefenceStats[m])/50) + 2)} -> switch(1, m)
[]
[i == 0 && m == 4]damageFoe.i{trainer1HealthStats[m] = trainer1HealthStats[m] - (((((2*trainer1Levels[m])/5) + 2)*p*(trainer1AttackStats[m]/trainer1DefenceStats[m])/50) + 2)} -> switch(1, m)
[]
[i == 0 && m == 5]damageFoe.i{trainer1HealthStats[m] = trainer1HealthStats[m] - (((((2*trainer1Levels[m])/5) + 2)*p*(trainer1AttackStats[m]/trainer1DefenceStats[m])/50) + 2)} -> switch(1, m)
[]
[i == 1 && m == 0]damageFoe.i{trainer0HealthStats[m] = trainer0HealthStats[m] - (((((2*trainer0Levels[m])/5) + 2)*p*(trainer0AttackStats[m]/trainer0DefenceStats[m])/50) + 2)} -> switch(0, m)
[]
[i == 1 && m == 1]damageFoe.i{trainer0HealthStats[m] = trainer0HealthStats[m] - (((((2*trainer0Levels[m])/5) + 2)*p*(trainer0AttackStats[m]/trainer0DefenceStats[m])/50) + 2)} -> switch(0, m)
[]
[i == 1 && m == 2]damageFoe.i{trainer0HealthStats[m] = trainer0HealthStats[m] - (((((2*trainer0Levels[m])/5) + 2)*p*(trainer0AttackStats[m]/trainer0DefenceStats[m])/50) + 2)} -> switch(0, m)
[]
[i == 1 && m == 3]damageFoe.i{trainer0HealthStats[m] = trainer0HealthStats[m] - (((((2*trainer0Levels[m])/5) + 2)*p*(trainer0AttackStats[m]/trainer0DefenceStats[m])/50) + 2)} -> switch(0, m)
[]
[i == 1 && m == 4]damageFoe.i{trainer0HealthStats[m] = trainer0HealthStats[m] - (((((2*trainer0Levels[m])/5) + 2)*p*(trainer0AttackStats[m]/trainer0DefenceStats[m])/50) + 2)} -> switch(0, m)
[]
[i == 1 && m == 5]damageFoe.i{trainer0HealthStats[m] = trainer0HealthStats[m] - (((((2*trainer0Levels[m])/5) + 2)*p*(trainer0AttackStats[m]/trainer0DefenceStats[m])/50) + 2)} -> switch(0, m);
switch(i, c) =
[i == 1]sendPokemon.i{if (trainer1HealthStats[c] <= 0) {currentPokemon[i] = c + 1}} -> end()
[]
[i == 0]sendPokemon.i{if (trainer0HealthStats[c] <= 0) {currentPokemon[i] = c + 1}} -> end();
end() =
[currentPokemon[0] > 5]trainer1win{trainer[0] = lose; trainer[1] = win} -> Stop
[]
[currentPokemon[1] > 5]trainer0win{trainer[0] = win; trainer[1] = lose} -> Stop
[]
[currentPokemon[0] <= 5 && currentPokemon[1] <= 5] rotate();
start() =
trainer0start{trainer[0] = active; trainer[1] = inactive} -> move(0)
[]
trainer1start{trainer[1] = active; trainer[0] = inactive} -> move(1);
simulate = start();
#define trainer0wins (trainer[0] == win && trainer[1] == lose);
#define trainer1wins (trainer[1] == win && trainer[0] == lose);
#define bothtrainerswin (trainer[0] == win && trainer[1] == win);
#define bothtrainerslose (trainer[0] == lose && trainer[1] == lose);
#assert simulate reaches trainer0wins;
#assert simulate reaches trainer1wins;
#assert simulate reaches bothtrainerswin;
#assert simulate reaches bothtrainerslose;