コード例 #1
0
ファイル: pieces.py プロジェクト: gamda/chess
 def validMoves( self, squares ):
     moves = []
     for i in DIRECTIONS:
         newmoves = square.line( squares, self.pos, i , False )
         if( len(newmoves) > 1 ):
             if not self._isOppositeSide( squares[newmoves[-1]] ):
                 # remove last square becaues it is an allie
                 newmoves = newmoves[0:-1]
         elif( len(newmoves) == 1 ):
             if not self._isOppositeSide( squares[newmoves[0]] ):
                 newmoves = []
         moves.extend( newmoves )
     return moves
コード例 #2
0
ファイル: pieces.py プロジェクト: gamda/chess
 def validMoves( self, squares ):
     moves = []
     for i in STRAIGHT_DIR:
         newmoves = square.line( squares, self.pos, i , False )
         if( len(newmoves) > 1 ):
             if not self._isOppositeSide( squares[newmoves[-1]] ):
                 # remove last square becaues it is an allie
                 newmoves = newmoves[0:-1]
         elif( len(newmoves) == 1 ):
             if not self._isOppositeSide( squares[newmoves[0]] ):
                 # the only move is to a square containing an allie
                 newmoves = []
         moves.extend( newmoves )
     return moves
コード例 #3
0
ファイル: pieces.py プロジェクト: gamda/chess
 def squaresAttacked( self, squares ):
     attackedSquares = []
     for i in DIRECTIONS:
         newSqrs = square.line( squares, self.pos, i , True )
         attackedSquares.extend( newSqrs )
     return attackedSquares
コード例 #4
0
ファイル: pieces.py プロジェクト: gamda/chess
 def squaresAttacked( self, squares ):
     attackedSquares = []
     for i in STRAIGHT_DIR:
         newSqrs = square.line( squares, self.pos, i , True )
         attackedSquares.extend( newSqrs )
     return attackedSquares