Commit 4f329bc6 authored by Ari Trachtenberg's avatar Ari Trachtenberg
Browse files

Nice and clean ...

parent f9a9a89b
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="AnalysisUIOptions">
    <option name="ANALYZE_INJECTED_CODE" value="false" />
  </component>
  <component name="ArtifactsWorkspaceSettings">
    <artifacts-to-build>
      <artifact name="sge_dist:jar" />
@@ -10,12 +13,14 @@
  </component>
  <component name="ChangeListManager">
    <list default="true" id="78671b20-6a1e-42c8-be28-50b7f38fa7ff" name="Default Changelist" comment="">
      <change afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/Brain/Board.java" 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/spr24/Brain/Board.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/Brain/Board.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/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/spr24/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/spr24/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/spr24/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/spr24/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/spr24/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/spr24/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/spr24/sameGameTris/sge.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/sameGameTris/sge.java" afterDir="false" />
    </list>
@@ -56,6 +61,7 @@
    "project.structure.last.edited": "Project",
    "project.structure.proportion": "0.0",
    "project.structure.side.proportion": "0.36091954",
    "run.code.analysis.last.selected.profile": "pProject Default",
    "vue.rearranger.settings.migration": "true"
  }
}]]></component>
@@ -94,7 +100,7 @@
      <workItem from="1548370619328" duration="375000" />
      <workItem from="1580056843261" duration="23542000" />
      <workItem from="1706041955741" duration="38000" />
      <workItem from="1706042051986" duration="5200000" />
      <workItem from="1706042051986" duration="6481000" />
    </task>
    <task id="LOCAL-00001" summary="Apparently working version.">
      <created>1580084914114</created>
@@ -133,7 +139,15 @@
      <option name="project" value="LOCAL" />
      <updated>1706048316975</updated>
    </task>
    <option name="localTasksCounter" value="6" />
    <task id="LOCAL-00006" summary="Working version ...">
      <option name="closed" value="true" />
      <created>1706049809584</created>
      <option name="number" value="00006" />
      <option name="presentableId" value="LOCAL-00006" />
      <option name="project" value="LOCAL" />
      <updated>1706049809584</updated>
    </task>
    <option name="localTasksCounter" value="7" />
    <servers />
  </component>
  <component name="TypeScriptGeneratedFilesManager">
@@ -144,19 +158,20 @@
    <MESSAGE value="Final version." />
    <MESSAGE value="Minor tweaks" />
    <MESSAGE value="Cleaning up." />
    <option name="LAST_COMMIT_MESSAGE" value="Cleaning up." />
    <MESSAGE value="Working version ..." />
    <option name="LAST_COMMIT_MESSAGE" value="Working version ..." />
  </component>
  <component name="XDebuggerManager">
    <breakpoint-manager>
      <breakpoints>
        <line-breakpoint enabled="true" type="java-line">
          <url>file://$PROJECT_DIR$/src/edu/bu/ec504/spr24/sameGameTris/sge.java</url>
          <line>643</line>
          <line>658</line>
          <option name="timeStamp" value="1" />
        </line-breakpoint>
        <line-breakpoint enabled="true" type="java-line">
          <url>file://$PROJECT_DIR$/src/edu/bu/ec504/spr24/sameGameTris/sge.java</url>
          <line>167</line>
          <line>169</line>
          <option name="timeStamp" value="3" />
        </line-breakpoint>
      </breakpoints>
+2 −2
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ class Board {
      }

      // ... delete the column if it is empty
      if (Objects.requireNonNull(getAt(ii)).size() == 0) {delete(ii);}
      if (Objects.requireNonNull(getAt(ii)).isEmpty()) {delete(ii);}
    }

    return count;
@@ -177,7 +177,7 @@ class Board {
  /**
   * @return a "pretty-printed" version of the data structure
   */
  public String display() {
  public String print() {
    String temp = data.toString();
    return temp.replace("], [", "]\n[");
  }
+9 −5
Original line number Diff line number Diff line
@@ -6,10 +6,11 @@ import edu.bu.ec504.spr24.sameGameTris.sge;
/**
 * The Brain is the artificial intelligence that tries to come up with the
 * best possible moves for the current position.
 * 
 * <p>
 * It typically runs in its own thread so that it will not interfere with other processing.
 */
public abstract class Brain implements Runnable {

	// FIELDS
	protected final GUI myGUI; // stores the GUI class attached to this Brain
	/**
@@ -28,11 +29,12 @@ public abstract class Brain implements Runnable {
	 * 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.
	 */
	final public void allDone() { allDone=true; };
	final public void allDone() {allDone = true;}

	/**
	 * Starts the Brain a'thinking.
	 * This is the code for requests decisions about which circles you Brain selects.
	 *
	 * @see java.lang.Runnable#run()
	 */
	final public void run() {
@@ -43,8 +45,10 @@ public abstract class Brain implements Runnable {
	}

	// ... METHODS FOR SUBCLASSES TO DEFINE

	/**
	 * Each Brain should have a name, which is provided by this method.
	 *
	 * @return the name of the brain
	 */
	public abstract String myName();
@@ -52,6 +56,6 @@ public abstract class Brain implements Runnable {
	/**
	 * Returns the next move of the Brain.
	 */
	public abstract Board.Pos nextMove();
	abstract Board.Pos nextMove();

}
+12 −14
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ public class LazyBrain extends Brain {
	}

	@Override
	public Pos nextMove() {
	Pos nextMove() {
		// Initialize and set up the internal board state with the current position
		currBoard = new Board();
		for (int xx = 0; xx < myGUI.boardWidth(); xx++)
@@ -42,10 +42,11 @@ public class LazyBrain extends Brain {
		return chooseMove();
	}


	// PRIVATE METHODS

	/**
	 * Chooses the next move to make.
	 *
	 * @return the move chosen, in Board coordinates
	 */
	private Board.Pos chooseMove() {
@@ -58,7 +59,8 @@ public class LazyBrain extends Brain {
			for (int yy = 0; yy < currBoard.rows(xx); yy++) {
				if (currStateCopy.getAt(xx, yy) != CircleColor.NONE) {
					Board test = new Board(currStateCopy);
					currStateCopy.clickNodeHelper(xx, yy, test.getAt(xx,yy)); // mark all other nodes in the region as "clear" (but does not delete anything)
					currStateCopy.clickNodeHelper(xx, yy, test.getAt(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
@@ -77,9 +79,5 @@ public class LazyBrain extends Brain {
		// return the result to the GUI
		return bestPos;
	}


	// INTERNAL CLASSES

}
+2 −6
Original line number Diff line number Diff line
@@ -7,14 +7,10 @@ import edu.bu.ec504.spr24.Brain.Board.Pos;
 */
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() {
		super();
	}


	/**
	 * {@inheritDoc}
	 */
@@ -23,7 +19,7 @@ private volatile boolean allDone = false; // when set to true, the Brain should
	}

	@Override
	public Pos nextMove() {
	Pos nextMove() {
		return new Pos(0, myGUI.boardHeight() - 1);
	}
}
Loading