Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import aima.core.search.adversarial.Game;

Expand Down Expand Up @@ -54,7 +55,7 @@ public String getPlayer(int playerNum) {
*/
public int getPlayerNum(String player) {
for (int i = 0; i < players.length; i++)
if (players[i] == player)
if (Objects.equals(players[i], player))
return i+1;
throw new IllegalArgumentException("Wrong player number.");
}
Expand Down Expand Up @@ -84,7 +85,7 @@ public boolean isTerminal(ConnectFourState state) {
public double getUtility(ConnectFourState state, String player) {
double result = state.getUtility();
if (result != -1) {
if (player == players[1])
if (Objects.equals(player, players[1]))
result = 1 - result;
} else {
throw new IllegalArgumentException("State is not terminal.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aima.core.environment.tictactoe;

import java.util.List;
import java.util.Objects;

import aima.core.search.adversarial.Game;
import aima.core.util.datastructure.XYLocation;
Expand Down Expand Up @@ -52,7 +53,7 @@ public boolean isTerminal(TicTacToeState state) {
public double getUtility(TicTacToeState state, String player) {
double result = state.getUtility();
if (result != -1) {
if (player == TicTacToeState.O)
if (Objects.equals(player, TicTacToeState.O))
result = 1 - result;
} else {
throw new IllegalArgumentException("State is not terminal.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import aima.core.agent.Agent;
import aima.core.agent.Environment;
Expand Down Expand Up @@ -78,7 +79,7 @@ protected void update() {
// print track of first agent
if (!env.getAgents().isEmpty()) {
String aLoc = env.getAgentLocation(env.getAgents().get(0));
if (track.isEmpty() || track.get(track.size() - 1) != aLoc)
if (track.isEmpty() || !Objects.equals(track.get(track.size() - 1), aLoc))
track.add(aLoc);
for (int i = 1; i < track.size(); i++) {
Point2D pt1 = map.getPosition(track.get(i - 1));
Expand Down