@@ -132,9 +132,6 @@ public Game(JFrame frame) {
132132 searchButton (); // returning the button to enable the button after search
133133 resetButton (); // it will enable the search button after reseting the game
134134
135- // load food image
136- // loadFoodImg();
137-
138135 // Add the button panel
139136 add (buttonPanel , BorderLayout .NORTH );
140137 setPreferredSize (new Dimension (getPreferredSize ().width + 200 , getPreferredSize ().height ));
@@ -383,7 +380,6 @@ private void handleStartLocationSelection(Tile clickedTile) {
383380 grasslandCount = 0 ;
384381 openTerrainCount = 0 ;
385382
386-
387383 // Set the clicked tile as the start location
388384 clickedTile .setStart ();
389385 startTile = clickedTile ;
@@ -557,8 +553,7 @@ public void animateAnt() {
557553 ant .setX (path .get (path .size () - 1 ).getXpixel ());
558554 ant .setY (path .get (path .size () - 1 ).getYpixel ());
559555
560-
561-
556+ // start the timer
562557 Timer timer = new Timer (delay , new ActionListener () {
563558 int i ;
564559 double speed ;
@@ -614,9 +609,9 @@ private double setSpeed(Tile nextTile) {
614609 double output = Tile .COST_SWAMPLAND ; // highest cost 4 for open terrain
615610
616611 if (nextTile .isSwampland ()){
617- output = (output /Tile .COST_SWAMPLAND ) + 0.25 ; // 1.25
612+ output = (output /Tile .COST_SWAMPLAND ) + 0.5 ; // 1.25
618613 } else if (nextTile .isGrassland ()){
619- output = output *2 /Tile .COST_GRASSLAND + 0.5 ; // 3.16
614+ output = output *2 /Tile .COST_GRASSLAND + 0.5 ; // 2.5
620615 }
621616
622617 return output ;
@@ -643,20 +638,21 @@ protected void paintComponent(Graphics g) {
643638
644639 printIfNoPath (g );
645640
646-
647641 // Draw the elapsed time
648642 g .setColor (Color .RED ); // Sets the color to red.
649643 g .setFont (new Font ("Courier New" , Font .PLAIN , 20 ));
650- g .drawString ("Mage Create: " + elapsedTimeStringBeforeSearch , timerX , timerY );
651- g .drawString ("Solved Time: " + elapsedTimeStringAfterAnimation , timerX , timerY + 20 );
644+ g .drawString ("Mage Create: " + elapsedTimeStringBeforeSearch , timerX , timerY );
645+ g .drawString ("Solved Time: " + elapsedTimeStringAfterAnimation , timerX , timerY + 20 );
652646
653647 // draw the counts of each terrain
654648 g .setColor (Color .BLACK );
655649 g .setFont (new Font ("Courier New" , Font .PLAIN , 20 ));
656- g .drawString ("Obstacle: " +obstacleCount , terrainCountX , terrainCountY );
657- g .drawString ("Swampland: " +swamplandCount , terrainCountX , terrainCountY + 20 );
658- g .drawString ("Grassland: " +grasslandCount , terrainCountX , terrainCountY + 40 );
659- g .drawString ("Open Terrain: " +openTerrainCount , terrainCountX , terrainCountY + 60 );
650+ g .drawString ("Grid Settings: " + NUM_ROWS + " x " + NUM_COLS , terrainCountX , terrainCountY -20 );
651+ g .drawString ("Open Terrain: " + openTerrainCount , terrainCountX , terrainCountY + 0 );
652+ g .drawString ("Obstacle: " + obstacleCount , terrainCountX , terrainCountY + 20 );
653+ g .drawString ("Swampland: " + swamplandCount , terrainCountX , terrainCountY + 40 );
654+ g .drawString ("Grassland: " + grasslandCount , terrainCountX , terrainCountY + 60 );
655+
660656
661657
662658 } // end paintComponent
@@ -704,6 +700,15 @@ private void printBoardAndCount(Graphics g) {
704700 }
705701 }
706702 }
703+
704+ if (startTile != null ){
705+ openTerrain --;
706+ }
707+
708+ if (goalTile != null ){
709+ openTerrain --;
710+ }
711+
707712 obstacleCount = obstacle ;
708713 swamplandCount = swampland ;
709714 grasslandCount = grassland ;
0 commit comments