Example #1
0
        static void Main(string[] args)
        {
            List<Piece> pieces = new List<Piece>();
            pieces.Add(new Piece(false, new System.Drawing.Point(0, 7), PieceColor.Blue, 1));
            pieces.Add(new Piece(false, new System.Drawing.Point(1, 7), PieceColor.Yellow, 0));
            pieces.Add(new Piece(false, new System.Drawing.Point(2, 7), PieceColor.Brown, 1));
            pieces.Add(new Piece(false, new System.Drawing.Point(3, 7), PieceColor.Pink, 0));
            pieces.Add(new Piece(false, new System.Drawing.Point(4, 7), PieceColor.Green, 1));
            pieces.Add(new Piece(false, new System.Drawing.Point(5, 7), PieceColor.Red, 0));
            pieces.Add(new Piece(false, new System.Drawing.Point(6, 7), PieceColor.Orange, 1));
            pieces.Add(new Piece(false, new System.Drawing.Point(7, 7), PieceColor.Purple, 3));

            pieces.Add(new Piece(true, new System.Drawing.Point(0, 0), PieceColor.Yellow, 0));
            pieces.Add(new Piece(true, new System.Drawing.Point(1, 0), PieceColor.Purple, 2));
            pieces.Add(new Piece(true, new System.Drawing.Point(2, 0), PieceColor.Green, 1));
            pieces.Add(new Piece(true, new System.Drawing.Point(3, 0), PieceColor.Orange, 0));
            pieces.Add(new Piece(true, new System.Drawing.Point(4, 0), PieceColor.Red, 1));
            pieces.Add(new Piece(true, new System.Drawing.Point(5, 0), PieceColor.Blue, 0));
            pieces.Add(new Piece(true, new System.Drawing.Point(6, 0), PieceColor.Pink, 0));
            pieces.Add(new Piece(true, new System.Drawing.Point(7, 0), PieceColor.Brown, 2));

            GameState startState = new GameState(pieces, null);
            List<IMove> possibleMoves = startState.PossibleMoves;

            possibleMoves.Sort(new Comparison<IMove>((IMove m1, IMove m2) =>
            {
                return m1.End.Y - m2.End.Y;
            }));

            foreach (IMove move in possibleMoves)
            {
                System.IO.File.AppendAllText(@"C:\Users\Dan\Documents\Visual Studio 2012\Projects\Kamisado\IterativeDeepening\bin\Debug\Output.txt", "Starting move " + move + Environment.NewLine);
                Console.WriteLine("Starting move " + move);

                for (int depth = 1; depth <= 20; depth++)
                {
                    GameState smallState = new GameState(pieces, null);
                    smallState.PossibleMoves = new List<IMove>();
                    smallState.PossibleMoves.Add(new Move(smallState, smallState.PiecePositions[move.Piece.BelongsToPlayerTwo ? 1 : 0][(int)move.Piece.Color],
                        new Point(move.End.X, move.End.Y)));

                    Bot bot = new Bot(depth, (GameState g, bool imPlayerTwo) => { return 0; });
                    MoveInfo info = bot.GetMove(smallState);

                    System.IO.File.AppendAllText(@"C:\Users\Dan\Documents\Visual Studio 2012\Projects\Kamisado\IterativeDeepening\bin\Debug\Output.txt",
                        move + " at depth " + depth + " had value " + info.Value + Environment.NewLine);
                    Console.WriteLine(move + " at depth " + depth + " had value " + info.Value);

                    if (info.Value != 0)
                    {
                        break;
                    }
                }

                System.IO.File.AppendAllText(@"C:\Users\Dan\Documents\Visual Studio 2012\Projects\Kamisado\IterativeDeepening\bin\Debug\Output.txt", Environment.NewLine);
                Console.WriteLine("");
            }
        }
Example #2
0
        public MatchEngine(IPlayer player1, IPlayer player2, int winScore)
        {
            _player1 = player1;
            _player2 = player2;

            _winScore = winScore;

            _startingPlayer = player1;
            _secondPlayer = player2;

            _engine = new GameEngine(_startingPlayer, _secondPlayer, new GameState());
            _matchInfo = new MatchInfo();

            _regroupBot = new Bot(REGROUP_SEARCH_DEPTH, Heuristics.MoveFarEval);
        }
Example #3
0
 public CompositeBot(Bot[] bots, double[] weights)
 {
     _bots = bots;
     _weights = weights;
     Score = 0;
 }
Example #4
0
        static void Match9()
        {
            Bot[] comp = new Bot[2];
            comp[0] = new Bot(5, Heuristics.MoveFarEval);
            comp[1] = new Bot(5, Heuristics.PiecesInStrikingEval);

            double[] weights = new double[2];
            weights[0] = 1;
            weights[1] = 1;

            CompositeBot player1 = new CompositeBot(comp, weights);
            string player1Description = "depth 5, 1 MoveFar, 1 PiecesInStriking";

            Bot[] comp2 = new Bot[2];
            comp2[0] = new Bot(5, Heuristics.MoveFarEval);
            comp2[1] = new Bot(5, Heuristics.PiecesInStrikingEval);

            double[] weights2 = new double[2];
            weights2[0] = 5;
            weights2[1] = 1;

            CompositeBot player2 = new CompositeBot(comp2, weights2);
            string player2Description = "depth 5, 5 MoveFar, 1 PiecesInStriking";

            Compare(player1, player1Description, player2, player2Description, "5_1MoveFar_1PiecesInStriking_vs_5_5MoveFar_1PiecesInStriking");
        }
Example #5
0
        static void Match31()
        {
            Bot[] comp = new Bot[3];
            comp[0] = new Bot(5, Heuristics.MoveFarEval);
            comp[1] = new Bot(5, Heuristics.PiecesInStrikingEval);
            comp[2] = new Bot(5, Heuristics.NumPossibleMovesEval);

            double[] weights = new double[3];
            weights[0] = 1;
            weights[1] = 1;
            weights[2] = 1;

            CompositeBot player1 = new CompositeBot(comp, weights);
            string player1Description = "depth 5, 1 MoveFar, 1 PiecesInStriking, 1 NumPossibleMoves";

            Bot[] comp2 = new Bot[4];
            comp2[0] = new Bot(5, Heuristics.MoveFarEval);
            comp2[1] = new Bot(5, Heuristics.PiecesInStrikingEval);
            comp2[2] = new Bot(5, Heuristics.NumPossibleMovesEval);
            comp2[3] = new Bot(5, Heuristics.NumPossibleColorsEval);

            double[] weights2 = new double[4];
            weights2[0] = 1.5;
            weights2[1] = 1.5;
            weights2[2] = 1.5;
            weights2[3] = 1;

            CompositeBot player2 = new CompositeBot(comp2, weights2);
            string player2Description = "depth 5, 1.5 MoveFar, 1.5 PiecesInStriking, 1.5 NumPossibleMoves, 1 Colors";

            Compare(player1, player1Description, player2, player2Description, "5_1MoveFar_1PiecesInStriking_1NumPossibleMoves_vs_5_15_MoveFar_15PiecesInStriking_15NumPossibleMoves_1Colors");
        }
Example #6
0
        static void Match21()
        {
            Bot[] comp = new Bot[2];
            comp[0] = new Bot(5, Heuristics.PiecesInStrikingEval);
            comp[1] = new Bot(5, Heuristics.NumPossibleMovesEval);

            double[] weights = new double[2];
            weights[0] = 1;
            weights[1] = 1;

            CompositeBot player1 = new CompositeBot(comp, weights);
            string player1Description = "depth 5, 1 PiecesInStriking, 1 NumPossibleMoves";

            Bot player2 = new Bot(5, Heuristics.NumPossibleMovesEval);
            string player2Description = "depth 5, NumPossibleMoves";

            Compare(player1, player1Description, player2, player2Description, "5_1PiecesInStriking_1NumPossibleMoves_vs_5_NumPossibleMoves");
        }
Example #7
0
        static void Match16()
        {
            Bot[] comp = new Bot[2];
            comp[0] = new Bot(5, Heuristics.MoveFarEval);
            comp[1] = new Bot(5, Heuristics.NumPossibleMovesEval);

            double[] weights = new double[2];
            weights[0] = 1;
            weights[1] = 1;

            CompositeBot player1 = new CompositeBot(comp, weights);
            string player1Description = "depth 5, 1 MoveFar, 1 NumPossibleMoves";

            Bot player2 = new Bot(5, Heuristics.MoveFarEval);
            string player2Description = "depth 5, MoveFar";

            Compare(player1, player1Description, player2, player2Description, "5_1MoveFar_1NumPossibleMoves_vs_5_MoveFar");
        }