示例#1
0
    static int alphaBeta(ref GameSim node, int depth, int alpha, int beta)
    {
        /*
         * We will check each piece for the player, but we will order them by priority
         * The ones that are closer to more enemies, or more open to movement, depending on the board or how the computer
         * is choosing to play.
         *
         * The selected piece will then call it's LegalMoves to see all of the viable options.
         * With the list LegalMoves, this is where the AI does it's THINKING
         * It moves this piece to each of these possible places then SCORES this move based off of all of the conditional functions
         * that we've made. HEY LOOK IT'S STARTING TO ALL COME TOGETHER.
         * Highest scoring move will be the best move.
         *
         *
         * Remember that alphabeta has to take in account the other player's (best possible) moves in order to go deeper into it's search
         *
         */
        GameObject piece = node.selectedPiece;
        //GameObject availableMoves = piece.GetComponent<Piece> ().moves;

        //See if the computer has reached the 'surface' or if there are no more moves available
        if (depth == 0 || NoMoves (piece.GetComponent<Piece> ().moves))
            return score (node);
        else
        {

            int forcedMove = -1;

            for(int i = 0; i < piece.GetComponent<Piece> ().moves.Count; i++)
            {
                movePiece (ref node.game, piece);
            }

        }

        return 0;
    }
示例#2
0
 static int score(GameSim node)
 {
     /*
      * This is where we call class Control. In here, we will keep track of moves made and
      * score the instance of the board based on the components in Control AND AI.
      *
      */
     return 0;
 }
示例#3
0
    static void ScorePieces(GameSim node, int depth)
    {
        Stack<GameObject> pieces;
        List<int> bestMoves = new List<int>();
        if (node.game.aiTurn)
            pieces = node.game.comp;
        else
            pieces = node.game.player;
        /*THIS IS WHERE CLASS CONTROL COMES IN
         * We'll need something to pick the pieces that are more likely to score
         * higher than others. Right now, all this does is pick them unbiasedly
         */
        int nMoves = pieces.Count;

        for (int i = 0; i < nMoves; i++)
        {
            node.selectedPiece  =  pieces.Peek ();
            node.selectedPiece.GetComponent<Piece>().moves = new LegalMoves().getLegalMoves(node.selectedPiece);
            Debug.Log ("AI SELECETING PIECE AT: " + node.selectedPiece.transform.position + "  " + nMoves);
            bestMoves.Add(alphaBeta (ref node, depth, -1000000000, 1000000000));
        }
    }
示例#4
0
    static void move(BoardData board, int time)
    {
        GameSim currBoard = new GameSim ();
        currBoard.game = clone (board);
        currBoard.selectedPiece = null;
        Debug.Log ("IN AI HOORAY");
        currBoard.bestMove = new Vector3(7,7,0);
        int depth = getDepth (currBoard.game, time);

        ScorePieces (currBoard, depth);

        //Vector3 moveTo =
        //currBoard.selectedPiece.transform.position = moveTo;
    }