示例#1
0
        public int GetScore(BoardFloodit b)
        {
            int _old = b.GetStartColor();

            b.FloodFill(100000, _old, 0, 0);
            int score = b.GetScore(100000);

            b.FloodFill(_old, 100000, 0, 0);
            return(score);
        }
示例#2
0
        public void Step(BoardFloodit b, int color)
        {
            int _old = b.GetStartColor();

            if (_old == color)
            {
                return;
            }
            else
            {
                b.FloodFill(color, _old, 0, 0);
            }
        }
示例#3
0
        public int AutoPlay(GameFloodit g, BoardFloodit b)
        {
            int   totalsteps = 0;
            Board _org       = new Board();

            _org.InitialBoard(b.GetBoard());
            Board _maxSolution = new Board();

            _maxSolution.InitialBoard(b.GetBoard());
            BoardFloodit work = new BoardFloodit();

            work.InitialBoard(b.GetBoard());

            int colorsize = b.ColorSize;
            int setp      = 0;

            while (true)
            {
                int max_score = 0;
                for (int i = 0; i < colorsize; i++)
                {
                    g.Step(work, i);
                    int _s = g.GetScore(work);
                    if (_s > max_score)
                    {
                        max_score = _s;
                        setp      = i;
                        _maxSolution.InitialBoard(work.GetBoard());
                    }
                    work.InitialBoard(_org.GetBoard());
                }

                totalsteps++;
                if (g.isWin(work))
                {
                    break;
                }

                //_maxSolution.PrintBoard();
                //Console.Write(setp.ToString()+":");
                //Console.WriteLine(max_score);

                work.InitialBoard(_maxSolution.GetBoard());
                _org.InitialBoard(work.GetBoard());
            }
            return(totalsteps);
        }
示例#4
0
 public Boolean isWin(BoardFloodit b)
 {
     return(b.isAllSameColor());
 }