public MoveRepresentationGenerator(GammonInterface game) { m_BgGame = game; m_MoveList = new BgMoveList(); m_MoveGenerator = new BgMoveGenerator(game); m_PatternEncoder = new PatternEncoder(); m_CurrentGeneratedMoves = new MoveRepresentationList(); }
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); }
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); } } }
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)); } } }
public void GenerateMoves(BgMoveList moveList) { moveList.Clear(); GenerateMoves(moveList, null); }
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 ) ); } }
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 ); } } }
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; }
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(); }