ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/Microscope.java
(Generate patch)

Comparing jsr166/src/test/loops/Microscope.java (file contents):
Revision 1.3 by jsr166, Mon Sep 27 19:15:15 2010 UTC vs.
Revision 1.4 by jsr166, Sat Oct 16 16:22:57 2010 UTC

# Line 19 | Line 19 | import java.util.concurrent.*;
19   * Microscope</a> version for instructions.
20   * <p>
21   * The code has been mangled beyond recognition
22 < * as a test of ForkJoin
23 < **/
24 <
22 > * as a test of ForkJoin.
23 > */
24   public class Microscope extends JPanel {
25  
26      static final CountDownLatch cd = new CountDownLatch(1);
# Line 230 | Line 229 | public class Microscope extends JPanel {
229              boardPanel.repaint();
230      }
231  
232 <    public void init()  {
232 >    public void init() {
233          initializeBoard();
234          if (autostart) {
235              startMover(auto);
# Line 438 | Line 437 | public class Microscope extends JPanel {
437  
438      /**
439       *  Player is just a glorified enumeration
440 <     **/
442 <
440 >     */
441      static final class Player {
442  
443          public static final int EMPTY = 0;
# Line 480 | Line 478 | public class Microscope extends JPanel {
478       * Boards are not immutable, but are never passed around across
479       * threads (instead new ones are constructed), so don't
480       * need any synch.
481 <     **/
484 <
481 >     */
482      static final class Board   {
483  
484          /*
# Line 584 | Line 581 | public class Microscope extends JPanel {
581          public void occupy(Player player, int row, int col) {
582              long m = 1L << (row + col * RANKS);
583              long nm = ~m;
584 <            if (player.code_ == Player.BLUE)  {
584 >            if (player.code_ == Player.BLUE) {
585                  blue_ |= m;
586                  green_ &= nm;
587              }
# Line 699 | Line 696 | public class Microscope extends JPanel {
696  
697      /**
698       * Moves represent transitions across Board states
699 <     **/
700 <
704 <
705 <    static final class Move  {
699 >     */
700 >    static final class Move {
701  
702          static final int NO_VALUE = -1;     // row/col value if not yet set
703          static final int PASS_VALUE = -2;   // special value for pass moves
# Line 821 | Line 816 | public class Microscope extends JPanel {
816          synchronized void commit() { // update board to reflect move
817              if (!committed) {
818                  committed = true;
819 <                if (isLegal() && !isPass())  {
819 >                if (isLegal() && !isPass()) {
820                      if (isJump()) board_.occupy(Player.Empty, fromRow, fromCol);
821                      board_.take(player_, toRow, toCol);
822                  }
# Line 853 | Line 848 | public class Microscope extends JPanel {
848      }
849  
850      /**
851 <     *  User builds moves via instructions/clicks by users
852 <     **/
858 <
851 >     * User builds moves via instructions/clicks by users
852 >     */
853      static class User extends Mover {
854  
855          private Move current;
# Line 909 | Line 903 | public class Microscope extends JPanel {
903  
904  
905      /**
906 <     *     AutoMover constructs Finders that compute actual moves
907 <     **/
914 <
906 >     * AutoMover constructs Finders that compute actual moves
907 >     */
908      static class AutoMover extends Mover {
909  
910          boolean cancelled = false;
# Line 932 | Line 925 | public class Microscope extends JPanel {
925  
926  
927          public synchronized void cancel() {
928 <            if (placing())  {
928 >            if (placing()) {
929                  currentFinder.cancel(false);
930                  stopPlacing();
931              }
# Line 964 | Line 957 | public class Microscope extends JPanel {
957       * since most expansions are duplicates of others. It could also
958       * be changed to prune moves, although this is unlikely to work
959       * well without better partial evaluation functions.
960 <     **/
968 <
960 >     */
961      static class Finder extends RecursiveAction {
962  
963          static final int NOMOVE = Integer.MIN_VALUE;
# Line 1070 | Line 1062 | public class Microscope extends JPanel {
1062  
1063          /**
1064           * Join all subtasks and evaluate moves. Default is sub-finder version.
1065 <         * Overridden in RootFinder
1066 <         **/
1075 <
1065 >         * Overridden in RootFinder.
1066 >         */
1067          void collect(Finder forked) {
1068              int best = NOMOVE;
1069              while (forked != null) {
# Line 1103 | Line 1094 | public class Microscope extends JPanel {
1094          }
1095  
1096          /**
1097 <         * Cancel all forked subtasks in list
1098 <         **/
1108 <
1097 >         * Cancels all forked subtasks in list.
1098 >         */
1099          void cancelAll(Finder forked) {
1100              while (forked != null) {
1101                  forked.cancel(false);
# Line 1117 | Line 1107 | public class Microscope extends JPanel {
1107  
1108      /**
1109       * Root Finder class -- wait out other finders and issue callback to game.
1110 <     **/
1121 <
1110 >     */
1111      static class RootFinder extends Finder {
1112          final AutoMover automover;
1113          final Player player;
# Line 1136 | Line 1125 | public class Microscope extends JPanel {
1125          /**
1126           * This differs from default version by recording
1127           * and calling back with best move
1128 <         **/
1128 >         */
1129          void collect(Finder forked) {
1130              int best = NOMOVE;
1131              Finder bestFinder = null;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines