Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Function GenerateSlidingMoves(CurrentGame As GameInstance, StartSquare As Byte, GenTurn As Turn, PieceType As Byte, ControlledSquares As Boolean) As ULong
- Dim DirectionsAvailableSliding() As SByte = {8, -8, 1, -1, 9, -9, 7, -7}
- Dim TargetSquares As ULong = 0
- Dim StartIndex As Byte = 0
- Dim EndIndex As Byte = 7
- Dim SideBitboard As ULong = CurrentGame.GetSetComputerBitboard()
- Dim OppositeBitboard As ULong = CurrentGame.GetSetPlayerBitboard()
- If PieceType = 2 Then
- EndIndex = 3
- ElseIf PieceType = 3 Then
- StartIndex = 4
- End If
- If GenTurn = Turn.Player Then
- SideBitboard = CurrentGame.GetSetPlayerBitboard()
- OppositeBitboard = CurrentGame.GetSetComputerBitboard()
- End If
- For DirectionIndex = StartIndex To EndIndex
- Dim DEndIndex As SByte = NumSquaresToEdgeSliding(StartSquare)(DirectionIndex) - 1
- For Direction = 0 To DEndIndex
- Dim TargetSquare As Byte = StartSquare + (DirectionsAvailableSliding(DirectionIndex) * (Direction + 1))
- Dim TargetSquare64 As ULong = (1UL << TargetSquare)
- If (SideBitboard And TargetSquare64) > 0 And ControlledSquares = False Then
- Exit For
- ElseIf (SideBitboard And TargetSquare64) > 0 And ControlledSquares = True Then
- TargetSquares = TargetSquares Or TargetSquare64
- Exit For
- End If
- TargetSquares = TargetSquares Or TargetSquare64
- If (OppositeBitboard And TargetSquare64) > 0 Then
- Exit For
- End If
- Next
- Next
- Return TargetSquares
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement