Пример #1
0
        public Player Player()
        {
            var evaluator = new ImmediateEvaluatorOnlyEmptyCells(WeightsEvenPlayer.ToArray(), WeightsOddPlayer.ToArray());
            var strategy  = new AlphaBetaStrategyWithOrdering(evaluator, 3);

            return(new Player
            {
                Strategy = strategy
            });
        }
Пример #2
0
        // TODO optimize when loading board: only scan top of non-empty columns
        // TODO improve evaluation function: prefer 3 in a row on left bottom instead of 3 in a row on top of board
        public void Run()
        {
            Console.SetIn(new StreamReader(Console.OpenStandardInput(512)));
            string line;

            Board board = new Board(6, 7);

            IStrategy strategy = new AlphaBetaStrategyWithOrdering(new ImmediateEvaluatorOnlyEmptyCells(), 4);

            while ((line = Console.ReadLine()) != null)
            {
                if (line == String.Empty)
                {
                    continue;
                }

                var parts = line.Split(' ');

                switch (parts[0])
                {
                case "settings":
                    switch (parts[1])
                    {
                    case "your_botid":
                        var myBotId = int.Parse(parts[2]);
                        board.SetMyBotId(myBotId);
                        break;
                    }
                    break;

                case "update":
                    switch (parts[1])
                    {
                    case "game":
                        switch (parts[2])
                        {
                        case "field":
                            var boardArray = parts[3].Split(';')
                                             .Select(x => x.Split(',')
                                                     .Select(int.Parse).ToArray())
                                             .ToArray();
                            board.Update(boardArray);
                            break;
                        }
                        break;
                    }
                    break;

                case "action":
                    var move = strategy.NextMove(board);
                    Console.WriteLine("place_disc {0}", move);
                    break;
                }
            }
        }