コード例 #1
0
ファイル: AIGameController.cs プロジェクト: jaideng123/TRITIX
    private void PlanMove()
    {
        Debug.Log("Planning Move");
        var         watch         = System.Diagnostics.Stopwatch.StartNew();
        Move        bestMove      = null;
        int         bestValue     = -9999;
        List <Move> possibleMoves = BoardStateUtils.EnumerateAvailableMoves(_moves);
        List <Move> shuffledMoves = Shuffle.FisherYatesCardDeckShuffle <Move>(possibleMoves);

        foreach (Move move in shuffledMoves)
        {
            List <Move> moves = new List <Move>(_moves);
            moves.Add(move);
            int value = MiniMax.minimax(minimaxDepth, moves, -1000, 1000, false);
            if (value > bestValue)
            {
                bestMove  = move;
                bestValue = value;
            }
        }
        watch.Stop();
        Debug.Log("Time Taken: " + watch.ElapsedMilliseconds);
        if (watch.Elapsed.Milliseconds < 1000)
        {
            int delay = 1000 - watch.Elapsed.Milliseconds;
            Thread.Sleep(delay);
        }
        plannedMove = bestMove;
        planning    = false;
    }
コード例 #2
0
ファイル: AIGameController.cs プロジェクト: jaideng123/TRITIX
    private void PlanRandomMove()
    {
        Debug.Log("Planning Random Move");
        var         watch         = System.Diagnostics.Stopwatch.StartNew();
        List <Move> possibleMoves = BoardStateUtils.EnumerateAvailableMoves(_moves);
        List <Move> shuffledMoves = Shuffle.FisherYatesCardDeckShuffle <Move>(possibleMoves);

        plannedMove = shuffledMoves[0];
        watch.Stop();
        Debug.Log("Time Taken: " + watch.Elapsed.Milliseconds);
        if (watch.Elapsed.Milliseconds < 1000)
        {
            int delay = 1000 - watch.Elapsed.Milliseconds;
            Thread.Sleep(delay);
        }
        planning = false;
        return;
    }