private static double getOptimizedHeuristic(int depth, int maxDepth, GameLogic g)
        {
            if (depth == maxDepth || g.getGameStatus() != GameStatus.NOWINNER) {
                return g.calculateHeuristic();
            } else {
                PieceColor currentPlayer = g.whoseMove();
                List<MoveAttempt> starting = g.getAllDoableMoveJumpAttempts();
                List<List<MoveAttempt>> poss = new List<List<MoveAttempt>>();
                foreach (MoveAttempt possibility in starting) {
                    List<MoveAttempt> p = new List<MoveAttempt>();
                    p.Add(possibility);
                    foreach(List<MoveAttempt> fullturn in getFullTurns(p, new GameLogic(g))) {
                        poss.Add(fullturn);
                    }
                }
                System.Diagnostics.Debug.WriteLine("starting length: " + starting.Count + ". poss length: " + poss.Count);

            }
            return .345;
        }
 public static List<List<MoveAttempt>> getFullTurns(List<MoveAttempt> possibility, GameLogic g)
 {
     List<List<MoveAttempt>> fullturns = new List<List<MoveAttempt>>();
     g.makeMove(possibility[possibility.Count-1]);
     if(g.multiJumpLoc == null) {
         fullturns.Add(possibility);
     } else {
         foreach(Vector v in g.getDoableJumps(g.board.getCellContents(g.multiJumpLoc))) {
             MoveAttempt move = new MoveAttempt(v, g.board.getCellContents(g.multiJumpLoc));
             List<MoveAttempt> p = new List<MoveAttempt>();
             p.AddRange(possibility);
             p.Add(move);
             GameLogic newG = new GameLogic(g);
             g.makeMove(move);
             fullturns.AddRange(getFullTurns(p, newG));
         }
     }
     return fullturns;
 }
 private void createPieces()
 {
     logic = new GameLogic(row_W, row_W, MainPage.FORCE_JUMP);
     int row = 0, col = 0;
     for (int k = 0; k < 24; k++)
     {
         row = (k / 4) + ((k >= 12) ? 2 : 0);
         col = 2 * (k % 4) + (row % 2 == 0 ? 0 : 1);
         Checker c = new Checker(col, row, (k < 12) ? Colors.Red : DarkGrey,
                                         (k < 12) ? DarkRed : Colors.Black);
         Vector vect = new Vector(row, col);
         Piece piece = new Piece((k < 12) ? PieceColor.RED : PieceColor.BLACK, vect, PieceType.REGULAR);
         logic.addPiece(piece);
         spaces[col, row].setChecker(c);
         mainCanvas.Children.Add(spaces[col, row].getChecker().getEl2());
         mainCanvas.Children.Add(spaces[col, row].getChecker().getEl1());
         mainCanvas.Children.Add(spaces[col, row].getChecker().getCrown());
     }
 }
 public GameLogic(GameLogic g)
 {
     //does a deep copy of GameLogic
     this.forceJumps = g.forceJumps;
     this.board = g.getBoardCopy();
     this.moveNumber = g.moveNumber;
     this.blackPieces = g.blackPieces;
     this.redPieces = g.redPieces;
     if (multiJumpLoc != null) {
         this.multiJumpLoc = new Vector(g.multiJumpLoc);
     } else {
         this.multiJumpLoc = null;
     }
     this.turnNumber = g.turnNumber;
 }
Example #5
0
        public static List <List <MoveAttempt> > getFullTurns(List <MoveAttempt> possibility, GameLogic g)
        {
            List <List <MoveAttempt> > fullturns = new List <List <MoveAttempt> >();

            g.makeMove(possibility[possibility.Count - 1]);
            if (g.multiJumpLoc == null)
            {
                fullturns.Add(possibility);
            }
            else
            {
                foreach (Vector v in g.getDoableJumps(g.board.getCellContents(g.multiJumpLoc)))
                {
                    MoveAttempt        move = new MoveAttempt(v, g.board.getCellContents(g.multiJumpLoc));
                    List <MoveAttempt> p    = new List <MoveAttempt>();
                    p.AddRange(possibility);
                    p.Add(move);
                    GameLogic newG = new GameLogic(g);
                    g.makeMove(move);
                    fullturns.AddRange(getFullTurns(p, newG));
                }
            }
            return(fullturns);
        }