Beispiel #1
0
        public string Encode(GammonInterface game)
        {
            string result = BitStringPatternToStringPattern(NumberPatternToBitStringPattern(BoardToNumberPattern(game)));

            result += game.GetDiceValue(0).ToString() + game.GetDiceValue(1).ToString();
            return(result);
        }
 public MoveRepresentationGenerator(GammonInterface game)
 {
     m_BgGame                = game;
     m_MoveList              = new BgMoveList();
     m_MoveGenerator         = new BgMoveGenerator(game);
     m_PatternEncoder        = new PatternEncoder();
     m_CurrentGeneratedMoves = new MoveRepresentationList();
 }
Beispiel #3
0
        public Agent(GammonInterface game)
        {
            m_GUI    = new AgentGUI("Agent " + (++m_InstanceCounter));
            m_Rand   = new Random();
            m_BgGame = game;
            m_MoveRepresentationList = new MoveRepresentationList();

            if (m_MoveRepresentationGenerator == null)
            {
                m_MoveRepresentationGenerator = new MoveRepresentationGenerator(game);
            }

            LoadPlugins();
            OutputMovesAndScore = true;
        }
Beispiel #4
0
        public int[] BoardToNumberPattern(GammonInterface game)
        {
            int[] result = new int[26];

            for (int i = 0; i < game.BoardSquareCount; i++)
            {
                if (game.SquareOwner(i) == game.CurrentPlayer)
                {
                    result[i] = game.SquareCheckerCount(i);
                }
                else if (game.SquareOwner(i) == game.CurrentOpponentPlayer)
                {
                    result[i] = -(game.SquareCheckerCount(i));
                }
                else
                {
                    result[i] = 0;
                }
            }
            return(result);
        }
        public MoveRepresentation(GammonInterface game, BgMove move) : base(game)
        {
            m_Score = 0.0;
            m_Move  = move;

            BgMove m = m_Move.FirstMove;

            while (m != null)
            {
                if (m.To != 26 && m_BoardPattern[m.To] == -1)
                {
                    m_BoardPattern[m.To] = 0;
                    m_BoardPattern[0]--;
                }

                m_BoardPattern[m.From]--;
                if (m.To != 26)
                {
                    m_BoardPattern[m.To]++;
                }

                m = m.NextMove;
            }
        }
Beispiel #6
0
 public BgMoveGenerator(GammonInterface game)
 {
     m_BgGame = game;
 }
 private MoveRepresentation(GammonInterface game) : base(game)
 {
 }