MCPcopy Create free account
hub / github.com/catabriga/graphwar / evaluateFunction

Method evaluateFunction

src/Graphwar/ComputerPlayer.java:155–259  ·  view source on GitHub ↗
(PolishNotationFunction ft, double angle)

Source from the content-addressed store, hash-verified

153 // }
154
155 private double evaluateFunction(PolishNotationFunction ft, double angle)
156 {
157 Function func = new Function(ft);
158
159 Player[] players = graphwar.getGameData().getPlayers().toArray(new Player[0]);
160 int numPlayers = players.length;
161
162 boolean inverted;
163
164 if(this.team==Constants.TEAM1)
165 {
166 inverted = false;
167 }
168 else
169 {
170 inverted = true;
171 }
172
173 switch(graphwar.getGameData().getGameMode())
174 {
175 case Constants.NORMAL_FUNC:
176 func.processFunctionRange(graphwar.getGameData().getObstacle(), players, numPlayers, graphwar.getGameData().getCurrentTurnIndex(), inverted);
177 break;
178 case Constants.FST_ODE:
179 func.processRK4Range(graphwar.getGameData().getObstacle(), players, numPlayers, graphwar.getGameData().getCurrentTurnIndex(), inverted);
180 break;
181 case Constants.SND_ODE:
182 func.processRK42Range(graphwar.getGameData().getObstacle(), players, numPlayers, graphwar.getGameData().getCurrentTurnIndex(), angle, inverted);
183 break;
184 }
185
186 double minDistSquared = 1000000;
187
188 double totalPoints = 0;
189
190
191 for(int i=0; i<numPlayers; i++)
192 {
193 soldiers:
194 for(int j=0; j<players[i].getNumSoldiers(); j++)
195 {
196 if(players[i].soldiers[j].isAlive())
197 {
198 for(int k=0; k<func.getNumPlayersHit(); k++)
199 {
200 if(func.getPlayerHit(k) == i && func.getSoldierHit(k) == j)
201 {
202 if(players[i].getTeam() != this.team)
203 {
204 totalPoints += 2000000;
205 }
206 else
207 {
208 totalPoints -= 2000000;
209 }
210
211 continue soldiers;
212 }

Callers 1

runMethod · 0.95

Calls 15

processFunctionRangeMethod · 0.95
processRK4RangeMethod · 0.95
processRK42RangeMethod · 0.95
getNumPlayersHitMethod · 0.95
getPlayerHitMethod · 0.95
getSoldierHitMethod · 0.95
getNumStepsMethod · 0.95
getYMethod · 0.95
getXMethod · 0.95
getGameDataMethod · 0.80
getObstacleMethod · 0.80
getCurrentTurnIndexMethod · 0.80

Tested by

no test coverage detected