public MoveRepresentationGenerator(GammonInterface game)
 {
     m_BgGame                = game;
     m_MoveList              = new BgMoveList();
     m_MoveGenerator         = new BgMoveGenerator(game);
     m_PatternEncoder        = new PatternEncoder();
     m_CurrentGeneratedMoves = new MoveRepresentationList();
 }
예제 #2
0
        private BgMoveList FindAllSingleMoves()
        {
            BgMoveList result = new BgMoveList();

            int prevMoveVal = 0;

            for (int i = 0; i < 4; i++)
            {
                int moveVal = m_BgGame.GetMove(i);
                if (moveVal != 0 && moveVal != prevMoveVal)
                {
                    FindSingleMoves(result, moveVal);
                }
                prevMoveVal = moveVal;
            }

            return(result);
        }
예제 #3
0
 private void FindSingleMoves(BgMoveList moveList, int val)
 {
     for (int i = m_BgGame.BoardSquareCount - 1; i > 0; i--)
     {
         if (m_BgGame.SquareOwner(i) == m_BgGame.CurrentPlayer)
         {
             if (m_BgGame.ValidateMove(i, i - val))
             {
                 BgMove move = new BgMove(i, i - val, null);
                 moveList.AddBgMove(move);
             }
         }
         if (i <= 6 && m_BgGame.ValidateMove(i, 26))
         {
             BgMove move = new BgMove(i, 26, null);
             moveList.AddBgMove(move);
         }
     }
 }
예제 #4
0
        private void GenerateMoves(BgMoveList moveList, BgMove prevMove)
        {
            BgMoveList singleMoves = FindAllSingleMoves();

            if (singleMoves.Count() > 0)
            {
                for (int i = 0; i < singleMoves.Count(); i++)
                {
                    BgMove currentMove = new BgMove(singleMoves.GetBgMove(i).From, singleMoves.GetBgMove(i).To, prevMove);

                    m_BgGame.MakeMove(currentMove.From, currentMove.To);
                    GenerateMoves(moveList, currentMove);

                    m_BgGame.Undo();
                }
            }
            else
            {
                if (prevMove != null)
                {
                    moveList.AddBgMove(BgMove.CloneFromFirst(prevMove.FirstMove));
                }
            }
        }
예제 #5
0
 public void GenerateMoves(BgMoveList moveList)
 {
     moveList.Clear();
     GenerateMoves(moveList, null);
 }
예제 #6
0
        private void GenerateMoves( BgMoveList moveList, BgMove prevMove )
        {
            BgMoveList singleMoves = FindAllSingleMoves();

            if ( singleMoves.Count() > 0 )
            {
                for ( int i = 0; i < singleMoves.Count(); i++ )
                {
                    BgMove currentMove = new BgMove( singleMoves.GetBgMove( i ).From, singleMoves.GetBgMove( i ).To, prevMove );

                    m_BgGame.MakeMove( currentMove.From, currentMove.To );
                    GenerateMoves( moveList, currentMove );

                    m_BgGame.Undo();
                }
            }
            else
            {
                if ( prevMove != null )
                    moveList.AddBgMove( BgMove.CloneFromFirst( prevMove.FirstMove ) );
            }
        }
예제 #7
0
 private void FindSingleMoves( BgMoveList moveList, int val )
 {
     for ( int i = m_BgGame.BoardSquareCount - 1; i > 0; i-- )
     {
         if ( m_BgGame.SquareOwner( i ) == m_BgGame.CurrentPlayer )
         {
             if ( m_BgGame.ValidateMove( i, i - val ) )
             {
                 BgMove move = new BgMove( i, i - val, null );
                 moveList.AddBgMove( move );
             }
         }
         if ( i <= 6 && m_BgGame.ValidateMove( i, 26 ) )
         {
             BgMove move = new BgMove( i, 26, null );
             moveList.AddBgMove( move );
         }
     }
 }
예제 #8
0
        private BgMoveList FindAllSingleMoves()
        {
            BgMoveList result = new BgMoveList();

            int prevMoveVal = 0;
            for ( int i = 0; i < 4; i++ )
            {
                int moveVal = m_BgGame.GetMove( i );
                if ( moveVal != 0 && moveVal != prevMoveVal )
                    FindSingleMoves( result, moveVal );
                prevMoveVal = moveVal;
            }

            return result;
        }
예제 #9
0
 public void GenerateMoves( BgMoveList moveList )
 {
     moveList.Clear();
     GenerateMoves( moveList, null );
 }
 public MoveRepresentationGenerator( GammonInterface game )
 {
     m_BgGame = game;
     m_MoveList = new BgMoveList();
     m_MoveGenerator = new BgMoveGenerator( game );
     m_PatternEncoder = new PatternEncoder();
     m_CurrentGeneratedMoves = new MoveRepresentationList();
 }