public void addMove(string move, int round, MoveMaker moveMaker, double score)
        {
            if (round > 0 && round <= rounds)
            {
                if (moveMaker == MoveMaker.Self)
                    dataContainer[round - 1, 0] = move;
                else
                    dataContainer[round - 1, 1] = move;

                logMove(move, round, moveMaker, score);
            }
        }
示例#2
0
    private void InitAI()
    {
        MoveMaker          myStrategy = null;
        EvaluationFunction eval       = null;
        UtilityFunction    ufunc      = null;

        ////////////////
        // your code here to initialize the MinMax algorithm
        // 1. Evaluation function
        // 2. Utility function
        // 3. Strategy (MinMax and MinMax Alpha Beta)
        ///////////////
        switch (evalfunc)
        {
        case EvaluatationFunc.Eval:
            eval = new EvaluationFunction();
            break;

        default:
            Debug.Log("Not an option");
            break;
        }

        switch (utilfunc)
        {
        case UtilityFunc.Util:
            ufunc = new UtilityFunction();
            break;

        default:
            Debug.Log("Not an option");
            break;
        }

        switch (strategy)
        {
        case TypeStrategy.RandomStrategy:
            myStrategy = new RandomSolution(this, GameManager.instance.GetAdversary(this));
            break;

        case TypeStrategy.MinMax:
            myStrategy = new MinMaxAlgorithm(this, eval, ufunc, GameManager.instance.GetAdversary(this));
            break;

        default:
            Debug.Log("Not an option");
            break;
        }

        moveMaker = myStrategy;
    }
示例#3
0
        public int CalcShortestSolutionWithExtra()
        {
            BuildingMaker maker      = new BuildingMaker();
            Building      startState = maker.BuildingForPuzzle2Input();
            Building      endState   = maker.SolvedBuilding(startState);
            MoveMaker     mover      = new MoveMaker();

            List <BuildingMove> possibleSolutions = new List <BuildingMove>();
            Stopwatch           watch             = new Stopwatch();

            watch.Start();
            int lowestSolution = mover.CalcMoveDepthAStar(startState, endState);

            watch.Stop();
            Console.WriteLine("It took " + watch.Elapsed.ToString() + " to process");
            return(lowestSolution);
        }
示例#4
0
        public int CalcAStarSolution()
        {
            BuildingMaker maker = new BuildingMaker();
            //Building startState = maker.TestPuzzleInput();
            Building  startState = maker.BuildingForPuzzleInput();
            Building  endState   = maker.SolvedBuilding(startState);
            MoveMaker mover      = new MoveMaker();

            Stopwatch watch = new Stopwatch();

            watch.Start();
            int lowestLongSolution = mover.CalcMoveDepthAStar(startState, endState);

            watch.Stop();
            Console.WriteLine("It took " + watch.Elapsed.ToString() + " to process, with result " + lowestLongSolution);

            return(lowestLongSolution);
        }
示例#5
0
 private void AddMove(string move, int round, MoveMaker moveMaker)
 {
     gameDataContainer.addMove(move, round, moveMaker,score);
 }
示例#6
0
 public void Setup()
 {
     moveMaker = new MoveMaker();
 }
示例#7
0
        private static void MakeMove(CheckerBoard board, Move move)
        {
            var moveMaker = new MoveMaker(board);

            moveMaker.MakeMove(move);
        }
        private void logMove(string move, int round, MoveMaker moveMaker, double score)
        {
            string logMessage = move + fieldSeparator + round.ToString() + fieldSeparator + moveMaker.ToString() + fieldSeparator + score.ToString();

            StreamWriter w = null;

            if (File.Exists(ScoreFilePath))
            {
                w = File.AppendText(ScoreFilePath);
            }
            else
            {
                w = new StreamWriter(File.Create(ScoreFilePath));
            }

            w.WriteLine(logMessage);
            w.Flush();
            w.Close();
        }
        /// <summary>
        /// Returns self or opponent move, given round number.
        /// If data not found, returns "NONE"
        /// </summary>
        /// <param name="moveMaker"></param>
        /// <param name="round"></param>
        /// <returns></returns>
        public string getMove(MoveMaker moveMaker, int round)
        {
            string move = "";
            if (round > 0 && round <= rounds)
                if (moveMaker == MoveMaker.Self)
                    move = dataContainer[round - 1, 0];
                else
                    move = dataContainer[round - 1, 1];
            else
                move = "NONE";

            if (string.IsNullOrEmpty(move))
                move = "NONE";

            return move;
        }