Commit fdaced20 authored by Ari Trachtenberg's avatar Ari Trachtenberg
Browse files

Working on concurrency issues.

parent 1b349e32
Loading
Loading
Loading
Loading
+28 −26
Original line number Diff line number Diff line
@@ -13,12 +13,7 @@
  </component>
  <component name="ChangeListManager">
    <list default="true" id="78671b20-6a1e-42c8-be28-50b7f38fa7ff" name="Default Changelist" comment="">
      <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/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/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/spr24/sameGameTris/SameGameTris.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/sameGameTris/SameGameTris.java" afterDir="false" />
    </list>
    <option name="SHOW_DIALOG" value="false" />
@@ -48,22 +43,26 @@
    <option name="hideEmptyMiddlePackages" value="true" />
    <option name="showLibraryContents" value="true" />
  </component>
  <component name="PropertiesComponent">{
  &quot;keyToString&quot;: {
    &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
    &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
    &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
    &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
    &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
    &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
    &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
    &quot;project.structure.last.edited&quot;: &quot;Project&quot;,
    &quot;project.structure.proportion&quot;: &quot;0.0&quot;,
    &quot;project.structure.side.proportion&quot;: &quot;0.36091954&quot;,
    &quot;run.code.analysis.last.selected.profile&quot;: &quot;pProject Default&quot;,
    &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
  <component name="PropertiesComponent"><![CDATA[{
  "keyToString": {
    "Application.EC504 SameGameTris.executor": "Debug",
    "RunOnceActivity.OpenProjectViewOnStart": "true",
    "RunOnceActivity.ShowReadmeOnStart": "true",
    "WebServerToolWindowFactoryState": "false",
    "kotlin-language-version-configured": "true",
    "node.js.detected.package.eslint": "true",
    "node.js.detected.package.tslint": "true",
    "node.js.selected.package.eslint": "(autodetect)",
    "node.js.selected.package.tslint": "(autodetect)",
    "nodejs_package_manager_path": "npm",
    "project.structure.last.edited": "Project",
    "project.structure.proportion": "0.0",
    "project.structure.side.proportion": "0.36091954",
    "run.code.analysis.last.selected.profile": "pProject Default",
    "settings.editor.selected.configurable": "preferences.lookFeel",
    "vue.rearranger.settings.migration": "true"
  }
}</component>
}]]></component>
  <component name="RecentsManager">
    <key name="MoveMembersDialog.RECENTS_KEY">
      <recent name="edu.bu.ec504.spr24.Brain.LazyBrain.Board" />
@@ -85,6 +84,13 @@
      </method>
    </configuration>
  </component>
  <component name="SharedIndexes">
    <attachedChunks>
      <set>
        <option value="jdk-17.0.10-corretto-17.0.10-f644763e9732-24582b8d" />
      </set>
    </attachedChunks>
  </component>
  <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
  <component name="SvnConfiguration">
    <configuration />
@@ -102,6 +108,7 @@
      <workItem from="1706042051986" duration="6820000" />
      <workItem from="1706057188033" duration="218000" />
      <workItem from="1706070762735" duration="2123000" />
      <workItem from="1706112889389" duration="1257000" />
    </task>
    <task id="LOCAL-00001" summary="Apparently working version.">
      <created>1580084914114</created>
@@ -176,14 +183,9 @@
      <breakpoints>
        <line-breakpoint enabled="true" type="java-line">
          <url>file://$PROJECT_DIR$/src/edu/bu/ec504/spr24/sameGameTris/SameGameTris.java</url>
          <line>697</line>
          <line>143</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/SameGameTris.java</url>
          <line>208</line>
          <option name="timeStamp" value="3" />
        </line-breakpoint>
      </breakpoints>
    </breakpoint-manager>
  </component>
+21 −8
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@ import java.awt.GridLayout;
import java.awt.event.*;
import java.io.Serial;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@@ -262,17 +264,28 @@ public class SameGameTris extends GUI implements ActionListener, ItemListener {
  /*
   * "Clicks" on the circle at location (xx,yy)
   */
  @Override
  public void makeMove(int xx, int yy) {

    circles[xx][yy].mouseEntered(null);  // pretend the mouse was pressed at location (xx,yy)
    try {
      Thread.sleep(DISPLAY_TIME_MS);          // wait a bit for the user to register the move
    } catch (InterruptedException ignored) {
    }
    Timer t = new Timer();
    TimerTask tt = new TimerTask() {
      @Override
      public void run() {
        circles[xx][yy].mouseExited(null);
        circles[xx][yy].mousePressed(null);
        circles[xx][yy].mouseReleased(
            null); // pretend that the mouse button was released at the location
        synchronized(brainThread) {
          brainThread.notify(); // restart thinking
        }
      }
    };
    t.schedule(tt, DISPLAY_TIME_MS);
    synchronized(brainThread) {
      try {
        brainThread.wait();  // pause thinking between moves
      } catch (InterruptedException ignored) {}
    }
  }

  /**