@@ -154,7 +154,21 @@ private Coordinates choosePawnHard() {
154154 cacheMoves .addAll (moves .getPossibleKick ());
155155 cacheMoves .addAll (moves .getPossibleMoves ());
156156
157- cachePossiblePawn .addAll (getListWithOnlyMinNumber (cacheMoves , Board .getPawn (coordinates ), minNumber ));
157+ for (Coordinates moveCoordinates : cacheMoves ) {
158+ PawnClass oldPawn = Board .addPawnWithoutDesign (moveCoordinates , Board .getPawn (coordinates ));
159+
160+ int point = boardPoint .calculateBoard ();
161+
162+ if (point == minNumber ) {
163+ cachePossiblePawn .add (coordinates );
164+ }
165+
166+ Board .removePawnWithoutDesign (moveCoordinates );
167+
168+ if (oldPawn != null ) {
169+ Board .addPawnWithoutDesign (moveCoordinates , oldPawn );
170+ }
171+ }
158172 }
159173
160174 return selectRandom (cachePossiblePawn );
@@ -202,9 +216,7 @@ private Coordinates chooseMoveHard(Coordinates coordinates) {
202216 possibleMove .addAll (moves .getPossibleMoves ());
203217 possibleMove .addAll (moves .getPossibleKick ());
204218
205- int minNumber = getMinNumber (possibleMove , pawn );
206-
207- Set <Coordinates > test = getListWithOnlyMinNumber (possibleMove , pawn , minNumber );
219+ Set <Coordinates > test = getListWithOnlyMinNumber (possibleMove , pawn );
208220
209221 return selectRandom (test );
210222 }
@@ -231,7 +243,8 @@ private int getMinNumber(Set<Coordinates> list, PawnClass actualPawn) {
231243 return minNumber ;
232244 }
233245
234- private Set <Coordinates > getListWithOnlyMinNumber (Set <Coordinates > list , PawnClass actualPawn , int minNumber ) {
246+ private Set <Coordinates > getListWithOnlyMinNumber (Set <Coordinates > list , PawnClass actualPawn ) {
247+ int minNumber = getMinNumber (list , actualPawn );
235248 Set <Coordinates > returnList = new HashSet <>();
236249
237250 for (Coordinates coordinates : list ) {
0 commit comments