Commit 0a36a8ee authored by Ari Trachtenberg's avatar Ari Trachtenberg
Browse files

Cleaning up.

parent c9b092e2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
    <option name="OPTION_DOCUMENT_TAG_USE" value="true" />
    <option name="OPTION_DOCUMENT_TAG_AUTHOR" value="true" />
  </component>
  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
  <component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
    <output url="file://$PROJECT_DIR$/classes" />
  </component>
</project>
 No newline at end of file
+44 −112
Original line number Diff line number Diff line
@@ -5,9 +5,25 @@
      <artifact name="sge_dist:jar" />
    </artifacts-to-build>
  </component>
  <component name="AutoImportSettings">
    <option name="autoReloadType" value="SELECTIVE" />
  </component>
  <component name="ChangeListManager">
    <list default="true" id="78671b20-6a1e-42c8-be28-50b7f38fa7ff" name="Default Changelist" comment="">
      <change beforePath="$PROJECT_DIR$/.highscores.db" beforeDir="false" afterPath="$PROJECT_DIR$/.highscores.db" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/edu/bu/ec504/spr19/Brain/Brain.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/Brain/Brain.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/edu/bu/ec504/spr19/Brain/lazyBrain.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/Brain/LazyBrain.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/edu/bu/ec504/spr19/Brain/simpleBrain.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/Brain/SimpleBrain.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/edu/bu/ec504/spr19/Brain/smarterBrain.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/Brain/SmarterBrain.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/edu/bu/ec504/spr19/highScores/highScore.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/highScores/highScore.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/edu/bu/ec504/spr19/sameGameTris/CircleColor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/sameGameTris/CircleColor.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/edu/bu/ec504/spr19/sameGameTris/CircleRolloverEvent.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/sameGameTris/CircleRolloverEvent.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/edu/bu/ec504/spr19/sameGameTris/GUI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/sameGameTris/GUI.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/edu/bu/ec504/spr19/sameGameTris/SelfAwareCircle.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/sameGameTris/SelfAwareCircle.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/edu/bu/ec504/spr19/sameGameTris/SelfAwareListener.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/sameGameTris/SelfAwareListener.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/edu/bu/ec504/spr19/sameGameTris/sge.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/sameGameTris/sge.java" afterDir="false" />
    </list>
    <option name="SHOW_DIALOG" value="false" />
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -24,24 +40,35 @@
  <component name="Git.Settings">
    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
  </component>
  <component name="MacroExpansionManager">
    <option name="directoryName" value="iond1hng" />
  </component>
  <component name="ProjectColorInfo">{
  &quot;associatedIndex&quot;: 0
}</component>
  <component name="ProjectId" id="1WwNkHNN3P3eLWEr1fM1C55vWZG" />
  <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
  <component name="ProjectViewState">
    <option name="hideEmptyMiddlePackages" value="true" />
    <option name="showExcludedFiles" value="true" />
    <option name="showLibraryContents" value="true" />
  </component>
  <component name="PropertiesComponent">
    <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
    <property name="WebServerToolWindowFactoryState" value="false" />
    <property name="aspect.path.notification.shown" value="true" />
    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1548371024044" />
    <property name="project.structure.last.edited" value="Artifacts" />
    <property name="project.structure.proportion" value="0.15" />
    <property name="project.structure.side.proportion" value="0.2" />
    <property name="run.code.analysis.last.selected.profile" value="pProject Default" />
    <property name="settings.editor.selected.configurable" value="preferences.keymap" />
  </component>
  <component name="PropertiesComponent"><![CDATA[{
  "keyToString": {
    "WebServerToolWindowFactoryState": "false",
    "node.js.detected.package.eslint": "true",
    "node.js.detected.package.tslint": "true",
    "node.js.selected.package.eslint": "(autodetect)",
    "node.js.selected.package.tslint": "(autodetect)",
    "project.structure.last.edited": "Project",
    "project.structure.proportion": "0.0",
    "project.structure.side.proportion": "0.36091954",
    "vue.rearranger.settings.migration": "true"
  }
}]]></component>
  <component name="RecentsManager">
    <key name="MoveMembersDialog.RECENTS_KEY">
      <recent name="edu.bu.ec504.spr24.Brain.LazyBrain.Board" />
    </key>
    <key name="MoveClassesOrPackagesDialog.RECENTS_KEY">
      <recent name="edu.bu.ec504.spr19" />
      <recent name="edu.bu.ec504.spr19.sameGameTris" />
@@ -49,13 +76,14 @@
  </component>
  <component name="RunManager">
    <configuration name="EC504 SameGameTris" type="Application" factoryName="Application">
      <option name="MAIN_CLASS_NAME" value="edu.bu.ec504.spr19.sameGameTris.sge" />
      <option name="MAIN_CLASS_NAME" value="edu.bu.ec504.spr24.sameGameTris.sge" />
      <module name="sge_dist" />
      <method v="2">
        <option name="Make" enabled="true" />
      </method>
    </configuration>
  </component>
  <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
  <component name="SvnConfiguration">
    <configuration />
  </component>
@@ -68,6 +96,8 @@
      <updated>1548370618181</updated>
      <workItem from="1548370619328" duration="375000" />
      <workItem from="1580056843261" duration="23542000" />
      <workItem from="1706041955741" duration="38000" />
      <workItem from="1706042051986" duration="3619000" />
    </task>
    <task id="LOCAL-00001" summary="Apparently working version.">
      <created>1580084914114</created>
@@ -94,7 +124,7 @@
    <servers />
  </component>
  <component name="TypeScriptGeneratedFilesManager">
    <option name="version" value="1" />
    <option name="version" value="3" />
  </component>
  <component name="VcsManagerConfiguration">
    <MESSAGE value="Apparently working version." />
@@ -102,102 +132,4 @@
    <MESSAGE value="Minor tweaks" />
    <option name="LAST_COMMIT_MESSAGE" value="Minor tweaks" />
  </component>
  <component name="WindowStateProjectService">
    <state x="841" y="354" key="#Project_Structure" timestamp="1580086148601">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state x="841" y="354" key="#Project_Structure/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580086148601" />
    <state x="744" y="354" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1580060472495">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state x="744" y="354" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580060472495" />
    <state x="998" y="407" key="#com.intellij.ide.util.MemberChooser" timestamp="1580086367455">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state x="998" y="407" key="#com.intellij.ide.util.MemberChooser/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580086367455" />
    <state x="980" y="473" key="#com.intellij.ide.util.PackageChooserDialog" timestamp="1580089168186">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state x="980" y="473" key="#com.intellij.ide.util.PackageChooserDialog/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580089168186" />
    <state x="-881" y="453" key="#com.intellij.ide.util.TreeClassChooserDialog" timestamp="1580085697611">
      <screen x="-2560" y="0" width="2560" height="1440" />
    </state>
    <state x="-881" y="453" key="#com.intellij.ide.util.TreeClassChooserDialog/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580085697611" />
    <state x="822" y="379" key="#com.intellij.openapi.keymap.impl.ui.EditKeymapsDialog" timestamp="1580063056139">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state x="822" y="379" key="#com.intellij.openapi.keymap.impl.ui.EditKeymapsDialog/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580063056139" />
    <state x="937" y="450" key="#com.intellij.refactoring.memberPullUp.PullUpDialog" timestamp="1580090901945">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state x="937" y="450" key="#com.intellij.refactoring.memberPullUp.PullUpDialog/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580090901945" />
    <state x="1006" y="601" key="#com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesDialog.packages" timestamp="1580089169702">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state x="1006" y="601" key="#com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesDialog.packages/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580089169702" />
    <state x="699" y="23" key="#com.intellij.refactoring.rename.AutomaticRenamingDialog" timestamp="1580087575121">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state x="699" y="23" key="#com.intellij.refactoring.rename.AutomaticRenamingDialog/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580087575121" />
    <state x="-815" y="390" key="#xdebugger.evaluate" timestamp="1580069192111">
      <screen x="-2560" y="0" width="2560" height="1440" />
    </state>
    <state x="-815" y="390" key="#xdebugger.evaluate/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580069192111" />
    <state x="1025" y="555" key="ANALYSIS_DLG_com.intellij.analysis.BaseAnalysisAction$1" timestamp="1580093399530">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state x="1025" y="555" key="ANALYSIS_DLG_com.intellij.analysis.BaseAnalysisAction$1/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580093399530" />
    <state x="1025" y="292" key="CommitChangelistDialog2" timestamp="1580097683527">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state x="1025" y="292" key="CommitChangelistDialog2/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580097683527" />
    <state width="2013" height="271" key="GridCell.Tab.0.bottom" timestamp="1580097406247">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state width="2013" height="271" key="GridCell.Tab.0.bottom/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580097406247" />
    <state width="2013" height="271" key="GridCell.Tab.0.center" timestamp="1580097406247">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state width="2013" height="271" key="GridCell.Tab.0.center/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580097406247" />
    <state width="2013" height="271" key="GridCell.Tab.0.left" timestamp="1580097406246">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state width="2013" height="271" key="GridCell.Tab.0.left/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580097406246" />
    <state width="2013" height="271" key="GridCell.Tab.0.right" timestamp="1580097406247">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state width="2013" height="271" key="GridCell.Tab.0.right/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580097406247" />
    <state width="2013" height="466" key="GridCell.Tab.1.bottom" timestamp="1580074485214">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state width="2013" height="466" key="GridCell.Tab.1.bottom/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580074485214" />
    <state width="2013" height="466" key="GridCell.Tab.1.center" timestamp="1580074485214">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state width="2013" height="466" key="GridCell.Tab.1.center/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580074485214" />
    <state width="2013" height="466" key="GridCell.Tab.1.left" timestamp="1580074485213">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state width="2013" height="466" key="GridCell.Tab.1.left/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580074485213" />
    <state width="2013" height="466" key="GridCell.Tab.1.right" timestamp="1580074485214">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state width="2013" height="466" key="GridCell.Tab.1.right/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580074485214" />
    <state x="-1131" y="242" key="SettingsEditor" timestamp="1580097700447">
      <screen x="-2560" y="0" width="2560" height="1440" />
    </state>
    <state x="-1131" y="242" key="SettingsEditor/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580097700447" />
    <state x="1046" y="429" key="Vcs.Push.Dialog.v2" timestamp="1580097685403">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state x="1046" y="429" key="Vcs.Push.Dialog.v2/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580097685403" />
    <state x="934" y="525" key="com.intellij.ide.util.TipDialog" timestamp="1580056854823">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state x="934" y="525" key="com.intellij.ide.util.TipDialog/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580056854823" />
    <state x="618" y="294" key="new project wizard" timestamp="1580094027542">
      <screen x="0" y="23" width="2560" height="1337" />
    </state>
    <state x="618" y="294" key="new project wizard/0.23.2560.1337/-2560.0.2560.1440@0.23.2560.1337" timestamp="1580094027542" />
  </component>
</project>
 No newline at end of file
+14 −13
Original line number Diff line number Diff line
package edu.bu.ec504.spr19.Brain;
package edu.bu.ec504.spr24.Brain;

import edu.bu.ec504.spr19.sameGameTris.GUI;
import edu.bu.ec504.spr24.sameGameTris.GUI;

/**
 * The Brain is the artificial intelligence that tries to come up with the
@@ -9,20 +9,16 @@ import edu.bu.ec504.spr19.sameGameTris.GUI;
 * It typically runs in its own thread so that it will not interfere with other processing.
 */
public abstract class Brain implements Runnable {
	// fields
	// FIELDS
	protected final GUI myGUI; // the GUI class attached to this Brain
	
	// methods
	/**
	 * A constructor that accepts a parameter representing the GUI interface on which the game is played.
	 */
	Brain(GUI myGUI) { this.myGUI = myGUI; }
	// METHODS

	/**
	 * This is called when the Brain is being asked to close down (i.e., the game is over).
	 * It should clean up any data structures and/or signal threads to close, etc.
	 * Constructs the brain
	 * @param myGUI A reference to the Graphical User Interface on which the game is being played.
	 */
	public abstract void allDone();
	Brain(GUI myGUI) { this.myGUI = myGUI; }

	/**
	 * Each Brain should have a name, which is provided by this method.
@@ -30,11 +26,16 @@ public abstract class Brain implements Runnable {
	 */
	public abstract String myName();

	/**
	 * This is called when the Brain is being asked to close down (i.e., the game is over).
	 * It should clean up any data structures and/or signal threads to close, etc.
	 */
	public abstract void allDone();
	
	/**
	 * Starts the Brain a'thinking.
	 * This is the code for making decisions about which circles you Brain selects.
	 * @see java.lang.Runnable#run()
	 */
	public abstract void run();

}
+93 −73
Original line number Diff line number Diff line
package edu.bu.ec504.spr19.Brain;
package edu.bu.ec504.spr24.Brain;

import java.util.LinkedList;
import java.util.Objects;

import edu.bu.ec504.spr19.sameGameTris.GUI;
import edu.bu.ec504.spr19.sameGameTris.CircleColor;
import edu.bu.ec504.spr24.sameGameTris.GUI;
import edu.bu.ec504.spr24.sameGameTris.CircleColor;

/**
 * Does whatever a lazy brain does ...
 */
public class lazyBrain extends Brain {
	// fields
	private volatile boolean allDone = false; // when set to true, the Brain should stop what it's doing and exit (at an appropriate time)
	private board currState;
public class LazyBrain extends Brain {

	/** Instantiates a Brain linked to a specified myGUI
	// FIELDS

	/**
	 * When set to true, the Brain should stop what it's doing and exit as soon as is appropriate.
	 */
	private volatile boolean allDone = false;

	/**
	 * The Brain's recording of the current state of the board.
	 */
	private Board currBoard;

	// METHODS

	/** Constructs a Brain linked to a specified myGUI
	 * @param myGUI The GUI that will be instantiating the Brain
	 */
	public lazyBrain(GUI myGUI) {
	public LazyBrain(GUI myGUI) {
		super(myGUI);
	}

@@ -32,48 +43,84 @@ public class lazyBrain extends Brain {
	 * {@inheritDoc}
	 */
	public String myName() {
		return "Greedy Brain";
		return "Lazy Brain";
	}

	/**
	 * {@inheritDoc}
	 */
	public void run() {
		// Initialize and set up the board with the current position
		currState = new board();
		// Initialize and set up the internal board state with the current position
		currBoard = new Board();
		for (int xx=0; xx<myGUI.boardWidth(); xx++)
			for (int yy=0; yy<myGUI.boardHeight(); yy++)
				currState.modify(xx, yy, myGUI.colorAt(xx, myGUI.boardHeight()-yy-1));
				currBoard.modify(xx, yy, myGUI.colorAt(xx, myGUI.boardHeight()-yy-1));

		// Keep making moves until the game is over
		while (!allDone && !myGUI.gameOverQ()) {
				pos nextMove = chooseMove();
				Board.Pos nextMove = chooseMove();
				myGUI.makeMove(nextMove.xx, nextMove.yy); // i.e. click on the lower left corner
			}
	}

	// internal classes

	// PRIVATE METHODS
	/**
	 * Stores an (xx,yy) coordinate
	 * Chooses the next move to make.
	 * @return the move chosen, in Board coordinates
	 */
	static class pos {
		final int xx;
		int yy;
		pos(int xx, int yy) {this.xx=xx; this.yy=yy;}
	private Board.Pos chooseMove() {
		// greedy choice
		int max=0;                  // the maximum number of points for the best position found
		Board.Pos bestPos = new Board.Pos(0, 0); // the best position found
		Board currStateCopy = new Board(currBoard);

		for (int xx=0; xx< currBoard.columns(); xx++)
			for (int yy=0; yy< currBoard.rows(xx); yy++) {
				if (currStateCopy.get(xx,yy)!= CircleColor.NONE) {
					Board test = new Board(currStateCopy);
					currStateCopy.clickNodeHelper(xx, yy, test.get(xx,yy)); // mark all other nodes in the region as "clear" (but does not delete anything)
					int count = test.clickNode(xx, yy); // try removing the region to see what is left over
					if (count > max) {
						// record a new best move
						max = count;
						bestPos = new Board.Pos(xx, yy);
					}

				}
			}

		// register the selected move on the board
		currBoard.clickNode(bestPos.xx, bestPos.yy);
		// convert bestPos to GUI coordinates
		bestPos = new Board.Pos(bestPos.yy, myGUI.boardHeight() - 1 - bestPos.yy);

		// return the result to the GUI
		return bestPos;
	}


	// INTERNAL CLASSES

	/**
	 * Stores a board set up
	 */
	private class board {
	private class Board {

		/**
		 * A 2-d Linked list of colors on the board.
		 */
		final LinkedList< LinkedList <CircleColor>> data;

		/**
		 * The width and height of the board.
		 */
		final private int width, height;

		// constructs a board of specified width and height
		board(int width, int height) {
		Board(int width, int height) {
			this.width = width; this.height = height;

			// allocate the data structure
			// allocate the data structure for storing board contents
			data = new LinkedList<>();

			// set up the data structure
@@ -87,22 +134,22 @@ public class lazyBrain extends Brain {
		/**
		 * default constructor
		 */
		board() {
		Board() {
			this(myGUI.boardWidth(),myGUI.boardHeight());
		}

		/**
		 * copy constructor
		 * @param basis the board to copy
		 * @param baseBoard the board to copy
		 */
		board(board basis) {
			// allocate space
			this(basis.width, basis.height);
		Board(Board baseBoard) {
			// allocate memory for the new board
			this(baseBoard.width, baseBoard.height);

			// copy over all the specific items
			for (int xx=0; xx<columns(); xx++)
				for (int yy=0; yy<rows(xx); yy++)
					modify(xx,yy,basis.get(xx, yy));
					modify(xx,yy,baseBoard.get(xx, yy));
		}

		/**
@@ -225,42 +272,15 @@ public class lazyBrain extends Brain {
			String temp = data.toString();
			return temp.replace("], [", "]\n[");
		}
	}

	// internal methods
		/**
	 * Chooses the next move to make.
	 * @return the move chosen, in GUI coordinates
		 * Stores an (xx,yy) position on the board.
		 */
	private pos chooseMove() {
		// greedy choice
		int max=0;                  // the maximum number of points for the best position found
		pos bestPos = new pos(0, 0); // the best position found
		board currStateCopy = new board(currState);

		for (int xx=0; xx<currState.columns(); xx++)
			for (int yy=0; yy<currState.rows(xx); yy++) {
				if (currStateCopy.get(xx,yy)!= CircleColor.NONE) {
					board test = new board(currStateCopy);
					currStateCopy.clickNodeHelper(xx, yy, test.get(xx,yy)); // mark all other nodes in the region as "clear" (but does not delete anything)
					int count = test.clickNode(xx, yy); // try removing the region to see what is left over
					if (count > max) {
						// record a new best move
						max = count;
						bestPos = new pos(xx, yy);
					}

		static class Pos {
			final int xx;
			final int yy;
			Pos(int xx, int yy) {this.xx=xx; this.yy=yy;}
		}
	}

		// register the selected move on the board
		currState.clickNode(bestPos.xx, bestPos.yy);
		// convert bestPos to GUI coordinates
		bestPos.yy = myGUI.boardHeight() - 1 - bestPos.yy;

		// return the result to the GUI
		return bestPos;
	}

}
+4 −5
Original line number Diff line number Diff line
package edu.bu.ec504.spr19.Brain;
package edu.bu.ec504.spr24.Brain;

import edu.bu.ec504.spr19.sameGameTris.GUI;
import edu.bu.ec504.spr24.sameGameTris.GUI;

/**
 * A very simple Brain for the game.
 */
public class simpleBrain extends Brain {
public class SimpleBrain extends Brain {
	
	// fields
private volatile boolean allDone = false; // when set to true, the Brain should stop what it's doing and exit (at an appropriate time)

	public simpleBrain(GUI myGUI) {
	public SimpleBrain(GUI myGUI) {
		super(myGUI);
	}

@@ -36,4 +36,3 @@ private volatile boolean allDone = false; // when set to true, the Brain should
				myGUI.makeMove(0, myGUI.boardHeight()-1); // i.e. click on the lower left corner
	}
}
	
 No newline at end of file
Loading