Loading .idea/workspace.xml +56 −26 Original line number Diff line number Diff line Loading @@ -12,8 +12,12 @@ <option name="autoReloadType" value="SELECTIVE" /> </component> <component name="ChangeListManager"> <list default="true" id="78671b20-6a1e-42c8-be28-50b7f38fa7ff" name="Default Changelist" comment=""> <change afterPath="$PROJECT_DIR$/src/README.md" afterDir="false" /> <list default="true" id="a5ee3e72-0481-428a-a4b6-e7db1973cb1f" name="Changes" comment="Fixed concurrency issue."> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/README.md" beforeDir="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/sameGameTris/SameGameTris.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/sameGameTris/SameGameTris.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" /> </list> <option name="SHOW_DIALOG" value="false" /> <option name="HIGHLIGHT_CONFLICTS" value="true" /> Loading Loading @@ -45,28 +49,28 @@ <option name="hideEmptyMiddlePackages" value="true" /> <option name="showLibraryContents" value="true" /> </component> <component name="PropertiesComponent">{ "keyToString": { "ASKED_ADD_EXTERNAL_FILES": "true", "Application.EC504 SameGameTris.executor": "Run", "RunOnceActivity.OpenProjectViewOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true", "WebServerToolWindowFactoryState": "false", "git-widget-placeholder": "master", "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 name="PropertiesComponent"><![CDATA[{ "keyToString": { "ASKED_ADD_EXTERNAL_FILES": "true", "Application.EC504 SameGameTris.executor": "Run", "RunOnceActivity.OpenProjectViewOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true", "WebServerToolWindowFactoryState": "false", "git-widget-placeholder": "master", "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": "Modules", "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" /> Loading @@ -88,13 +92,20 @@ </method> </configuration> </component> <component name="SharedIndexes"> <attachedChunks> <set> <option value="jdk-17.0.10-corretto-17.0.10-4caba194b151-53826d6a" /> </set> </attachedChunks> </component> <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> <component name="SvnConfiguration"> <configuration /> </component> <component name="TaskManager"> <task active="true" id="Default" summary="Default task"> <changelist id="78671b20-6a1e-42c8-be28-50b7f38fa7ff" name="Default Changelist" comment="" /> <changelist id="" name="Default Changelist" comment="" /> <created>1548370618181</created> <option name="number" value="Default" /> <option name="presentableId" value="Default" /> Loading @@ -107,7 +118,7 @@ <workItem from="1706070762735" duration="2123000" /> <workItem from="1706112889389" duration="6798000" /> <workItem from="1706139932552" duration="8790000" /> <workItem from="1707184524992" duration="48000" /> <workItem from="1707184524992" duration="8230000" /> </task> <task id="LOCAL-00001" summary="Apparently working version."> <created>1580084914114</created> Loading Loading @@ -178,12 +189,31 @@ <option name="project" value="LOCAL" /> <updated>1706152811353</updated> </task> <option name="localTasksCounter" value="10" /> <task id="LOCAL-00010" summary="Fixed concurrency issue."> <option name="closed" value="true" /> <created>1707184613524</created> <option name="number" value="00010" /> <option name="presentableId" value="LOCAL-00010" /> <option name="project" value="LOCAL" /> <updated>1707184613524</updated> </task> <option name="localTasksCounter" value="11" /> <servers /> </component> <component name="TypeScriptGeneratedFilesManager"> <option name="version" value="3" /> </component> <component name="Vcs.Log.Tabs.Properties"> <option name="TAB_STATES"> <map> <entry key="MAIN"> <value> <State /> </value> </entry> </map> </option> </component> <component name="VcsManagerConfiguration"> <MESSAGE value="Apparently working version." /> <MESSAGE value="Final version." /> Loading src/README.mddeleted 100644 → 0 +0 −2 Original line number Diff line number Diff line # Hello by Rohan Kumar No newline at end of file src/edu/bu/ec504/spr24/brain/SmarterBrain.java +68 −2 Original line number Diff line number Diff line package edu.bu.ec504.spr24.brain; import edu.bu.ec504.spr24.brain.Board.Pos; import edu.bu.ec504.spr24.sameGameTris.CircleColor; import javax.swing.*; import java.util.LinkedList; /** * A smarter brain, for you to produce. */ public class SmarterBrain extends Brain { private Board currBoard; public SmarterBrain() { super(); } Loading @@ -18,8 +23,69 @@ public class SmarterBrain extends Brain { @Override Pos nextMove() { JOptionPane.showMessageDialog(null, "Please insert brain here!"); return null; currBoard = new Board(); for (int xx = 0; xx < myGUI.boardWidth(); xx++) for (int yy = 0; yy < myGUI.boardHeight(); yy++) currBoard.modify(xx, yy, myGUI.colorAt(xx, myGUI.boardHeight() - yy - 1)); return chooseMove(); } private Pos chooseMove() { Pos bestPos = new Pos(0, 0); Board currStateCopy = new Board(currBoard); // first, find column with greatest height int maxColHeight = 0; LinkedList<Integer> maxCols = new LinkedList<>(); // iterate through each column for(int ii = 0; ii < currStateCopy.columns(); ii++){ // calculate # of circles in the column int h = 0; for(int jj = 0; jj < currStateCopy.rows(ii); jj++){ if(currStateCopy.getAt(ii, jj) != CircleColor.NONE){ h++; } } // if equal # of circles, add to list, else, clear list and update maxHeight if(h == maxColHeight){ maxCols.add(ii); } if(h > maxColHeight){ maxColHeight = h; // update max column height (max # of circles) maxCols.clear(); maxCols.add(ii); } } // then, choose option that has greatest score increase int maxScore = 0; for(Integer i : maxCols){ System.out.println(i); for (int j = 0; j < currBoard.rows(i); j++) { if (currStateCopy.getAt(i, j) != CircleColor.NONE) { Board test = new Board(currStateCopy); // mark all other nodes in the region as "clear" (but does not delete anything) currStateCopy.clickNodeHelper(i, j, test.getAt(i, j)); // try removing the region to see what is left over int count = test.clickNode(i, j); if (count > maxScore) { // record a new best move maxScore = count; bestPos = new Board.Pos(i, myGUI.boardHeight()-1-j); } } } } return bestPos; } } src/edu/bu/ec504/spr24/sameGameTris/SameGameTris.java +1 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,7 @@ public class SameGameTris extends GUI implements ActionListener, ItemListener { * true iff the game is over (i.e., not running) */ boolean gameOver = false; /** * An instance of the SGE GUI. */ Loading src/edu/bu/ec504/spr24/sameGameTris/SelfAwareCircle.java +1 −0 Original line number Diff line number Diff line Loading @@ -166,6 +166,7 @@ class SelfAwareCircle extends Component implements MouseListener, SelfAwareListe regionLength.getAndIncrement(); // update the region length by the newly highlighted item // announce the rollover to other circles _fireButtonRolloverEvent(stt); } Loading Loading
.idea/workspace.xml +56 −26 Original line number Diff line number Diff line Loading @@ -12,8 +12,12 @@ <option name="autoReloadType" value="SELECTIVE" /> </component> <component name="ChangeListManager"> <list default="true" id="78671b20-6a1e-42c8-be28-50b7f38fa7ff" name="Default Changelist" comment=""> <change afterPath="$PROJECT_DIR$/src/README.md" afterDir="false" /> <list default="true" id="a5ee3e72-0481-428a-a4b6-e7db1973cb1f" name="Changes" comment="Fixed concurrency issue."> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/README.md" beforeDir="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/sameGameTris/SameGameTris.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/edu/bu/ec504/spr24/sameGameTris/SameGameTris.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" /> </list> <option name="SHOW_DIALOG" value="false" /> <option name="HIGHLIGHT_CONFLICTS" value="true" /> Loading Loading @@ -45,28 +49,28 @@ <option name="hideEmptyMiddlePackages" value="true" /> <option name="showLibraryContents" value="true" /> </component> <component name="PropertiesComponent">{ "keyToString": { "ASKED_ADD_EXTERNAL_FILES": "true", "Application.EC504 SameGameTris.executor": "Run", "RunOnceActivity.OpenProjectViewOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true", "WebServerToolWindowFactoryState": "false", "git-widget-placeholder": "master", "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 name="PropertiesComponent"><![CDATA[{ "keyToString": { "ASKED_ADD_EXTERNAL_FILES": "true", "Application.EC504 SameGameTris.executor": "Run", "RunOnceActivity.OpenProjectViewOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true", "WebServerToolWindowFactoryState": "false", "git-widget-placeholder": "master", "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": "Modules", "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" /> Loading @@ -88,13 +92,20 @@ </method> </configuration> </component> <component name="SharedIndexes"> <attachedChunks> <set> <option value="jdk-17.0.10-corretto-17.0.10-4caba194b151-53826d6a" /> </set> </attachedChunks> </component> <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> <component name="SvnConfiguration"> <configuration /> </component> <component name="TaskManager"> <task active="true" id="Default" summary="Default task"> <changelist id="78671b20-6a1e-42c8-be28-50b7f38fa7ff" name="Default Changelist" comment="" /> <changelist id="" name="Default Changelist" comment="" /> <created>1548370618181</created> <option name="number" value="Default" /> <option name="presentableId" value="Default" /> Loading @@ -107,7 +118,7 @@ <workItem from="1706070762735" duration="2123000" /> <workItem from="1706112889389" duration="6798000" /> <workItem from="1706139932552" duration="8790000" /> <workItem from="1707184524992" duration="48000" /> <workItem from="1707184524992" duration="8230000" /> </task> <task id="LOCAL-00001" summary="Apparently working version."> <created>1580084914114</created> Loading Loading @@ -178,12 +189,31 @@ <option name="project" value="LOCAL" /> <updated>1706152811353</updated> </task> <option name="localTasksCounter" value="10" /> <task id="LOCAL-00010" summary="Fixed concurrency issue."> <option name="closed" value="true" /> <created>1707184613524</created> <option name="number" value="00010" /> <option name="presentableId" value="LOCAL-00010" /> <option name="project" value="LOCAL" /> <updated>1707184613524</updated> </task> <option name="localTasksCounter" value="11" /> <servers /> </component> <component name="TypeScriptGeneratedFilesManager"> <option name="version" value="3" /> </component> <component name="Vcs.Log.Tabs.Properties"> <option name="TAB_STATES"> <map> <entry key="MAIN"> <value> <State /> </value> </entry> </map> </option> </component> <component name="VcsManagerConfiguration"> <MESSAGE value="Apparently working version." /> <MESSAGE value="Final version." /> Loading
src/README.mddeleted 100644 → 0 +0 −2 Original line number Diff line number Diff line # Hello by Rohan Kumar No newline at end of file
src/edu/bu/ec504/spr24/brain/SmarterBrain.java +68 −2 Original line number Diff line number Diff line package edu.bu.ec504.spr24.brain; import edu.bu.ec504.spr24.brain.Board.Pos; import edu.bu.ec504.spr24.sameGameTris.CircleColor; import javax.swing.*; import java.util.LinkedList; /** * A smarter brain, for you to produce. */ public class SmarterBrain extends Brain { private Board currBoard; public SmarterBrain() { super(); } Loading @@ -18,8 +23,69 @@ public class SmarterBrain extends Brain { @Override Pos nextMove() { JOptionPane.showMessageDialog(null, "Please insert brain here!"); return null; currBoard = new Board(); for (int xx = 0; xx < myGUI.boardWidth(); xx++) for (int yy = 0; yy < myGUI.boardHeight(); yy++) currBoard.modify(xx, yy, myGUI.colorAt(xx, myGUI.boardHeight() - yy - 1)); return chooseMove(); } private Pos chooseMove() { Pos bestPos = new Pos(0, 0); Board currStateCopy = new Board(currBoard); // first, find column with greatest height int maxColHeight = 0; LinkedList<Integer> maxCols = new LinkedList<>(); // iterate through each column for(int ii = 0; ii < currStateCopy.columns(); ii++){ // calculate # of circles in the column int h = 0; for(int jj = 0; jj < currStateCopy.rows(ii); jj++){ if(currStateCopy.getAt(ii, jj) != CircleColor.NONE){ h++; } } // if equal # of circles, add to list, else, clear list and update maxHeight if(h == maxColHeight){ maxCols.add(ii); } if(h > maxColHeight){ maxColHeight = h; // update max column height (max # of circles) maxCols.clear(); maxCols.add(ii); } } // then, choose option that has greatest score increase int maxScore = 0; for(Integer i : maxCols){ System.out.println(i); for (int j = 0; j < currBoard.rows(i); j++) { if (currStateCopy.getAt(i, j) != CircleColor.NONE) { Board test = new Board(currStateCopy); // mark all other nodes in the region as "clear" (but does not delete anything) currStateCopy.clickNodeHelper(i, j, test.getAt(i, j)); // try removing the region to see what is left over int count = test.clickNode(i, j); if (count > maxScore) { // record a new best move maxScore = count; bestPos = new Board.Pos(i, myGUI.boardHeight()-1-j); } } } } return bestPos; } }
src/edu/bu/ec504/spr24/sameGameTris/SameGameTris.java +1 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,7 @@ public class SameGameTris extends GUI implements ActionListener, ItemListener { * true iff the game is over (i.e., not running) */ boolean gameOver = false; /** * An instance of the SGE GUI. */ Loading
src/edu/bu/ec504/spr24/sameGameTris/SelfAwareCircle.java +1 −0 Original line number Diff line number Diff line Loading @@ -166,6 +166,7 @@ class SelfAwareCircle extends Component implements MouseListener, SelfAwareListe regionLength.getAndIncrement(); // update the region length by the newly highlighted item // announce the rollover to other circles _fireButtonRolloverEvent(stt); } Loading