Пример #1
0
 public ChessPosition( ChessPosition chessPos )
 {
     this.posType = chessPos.posType;
     this.nRank = chessPos.nRank;
     this.nPile = chessPos.nPile;
     this.pos = chessPos.pos;
 }
Пример #2
0
    public ChessPosition( int nPosRank, int nPosPile )
    {
        this.posType = GetPositionType( nPosRank, nPosPile );
        if( this.posType != BoardPositionType.eNone ) {

            this.nRank = nPosRank;
            this.nPile = nPosPile;

            this.pos = (BoardPosition)(nPosPile * ChessData.nNumRank + nPosRank);
        }
        else {

            this.nRank = -1;
            this.nPile = -1;
            this.pos = BoardPosition.InvalidPosition;
        }
    }
Пример #3
0
    public ChessPosition( BoardPosition boardPos )
    {
        int nPosRank = 0, nPosPile = 0;
        this.posType = ChessPosition.CalcPositionIndex( boardPos, ref nPosRank, ref nPosPile );
        if( this.posType != BoardPositionType.eNone ) {

            this.nRank = nPosRank;
            this.nPile = nPosPile;

            this.pos = boardPos;
        }
        else {

            this.nRank = -1;
            this.nPile = -1;

            this.pos = BoardPosition.InvalidPosition;
        }
    }
Пример #4
0
    public bool SetPosition( ChessPosition chessPos )
    {
        this.posType = chessPos.posType;
        this.nRank = chessPos.nRank;
        this.nPile = chessPos.nPile;
        this.pos = chessPos.pos;

        if( chessPos.posType == BoardPositionType.eNone ) {

            return false;
        }

        return true;
    }
Пример #5
0
    public bool MovePosition( int nRankMove, int nPileMove )
    {
        int nMovedRank, nMovedPile;
        nMovedRank = nRank + nRankMove;
        nMovedPile = nPile + nPileMove;

        if( nMovedRank >= 0 && nMovedRank < ChessData.nNumRank &&
            nMovedPile >= 0 && nMovedPile < ChessData.nNumPile ) {

            SetPosition( nMovedRank, nMovedPile);
            return true;
        }

        pos = BoardPosition.InvalidPosition;
        posType = BoardPositionType.eNone;
        nRank = -1;
        nPile = -1;

        return false;
    }
Пример #6
0
 private bool OwlShouldStopHere(int position, BoardPositionType desiredColor)
 {
     return(position >= NestPosition ||
            (desiredColor == Board[position] && !Owls.Inhabit(position)));
 }