File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed
aima-core/src/main/java/aima/core/environment
aima-gui/src/main/java/aima/gui/fx/views Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 22
33import java .util .ArrayList ;
44import java .util .List ;
5+ import java .util .Objects ;
56
67import aima .core .search .adversarial .Game ;
78
@@ -54,7 +55,7 @@ public String getPlayer(int playerNum) {
5455 */
5556 public int getPlayerNum (String player ) {
5657 for (int i = 0 ; i < players .length ; i ++)
57- if (players [i ] == player )
58+ if (Objects . equals ( players [i ], player ) )
5859 return i +1 ;
5960 throw new IllegalArgumentException ("Wrong player number." );
6061 }
@@ -84,7 +85,7 @@ public boolean isTerminal(ConnectFourState state) {
8485 public double getUtility (ConnectFourState state , String player ) {
8586 double result = state .getUtility ();
8687 if (result != -1 ) {
87- if (player == players [1 ])
88+ if (Objects . equals ( player , players [1 ]) )
8889 result = 1 - result ;
8990 } else {
9091 throw new IllegalArgumentException ("State is not terminal." );
Original file line number Diff line number Diff line change 11package aima .core .environment .tictactoe ;
22
33import java .util .List ;
4+ import java .util .Objects ;
45
56import aima .core .search .adversarial .Game ;
67import aima .core .util .datastructure .XYLocation ;
@@ -52,7 +53,7 @@ public boolean isTerminal(TicTacToeState state) {
5253 public double getUtility (TicTacToeState state , String player ) {
5354 double result = state .getUtility ();
5455 if (result != -1 ) {
55- if (player == TicTacToeState .O )
56+ if (Objects . equals ( player , TicTacToeState .O ) )
5657 result = 1 - result ;
5758 } else {
5859 throw new IllegalArgumentException ("State is not terminal." );
Original file line number Diff line number Diff line change 22
33import java .util .ArrayList ;
44import java .util .List ;
5+ import java .util .Objects ;
56
67import aima .core .agent .Agent ;
78import aima .core .agent .Environment ;
@@ -78,7 +79,7 @@ protected void update() {
7879 // print track of first agent
7980 if (!env .getAgents ().isEmpty ()) {
8081 String aLoc = env .getAgentLocation (env .getAgents ().get (0 ));
81- if (track .isEmpty () || track .get (track .size () - 1 ) != aLoc )
82+ if (track .isEmpty () || ! Objects . equals ( track .get (track .size () - 1 ), aLoc ) )
8283 track .add (aLoc );
8384 for (int i = 1 ; i < track .size (); i ++) {
8485 Point2D pt1 = map .getPosition (track .get (i - 1 ));
You can’t perform that action at this time.
0 commit comments