Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Function GenerateKnightMoves(CurrentGame As GameInstance, StartSquare As Byte, GenTurn As Turn, ControlledSquares As Boolean) As ULong
- Dim TargetSquares As ULong = 0
- Dim StartRank As Byte = Math.Floor(StartSquare / 8)
- Dim StartFile As Byte = StartSquare Mod 8
- Dim XDirection() As SByte = {-2, -1, 1, 2, 2, 1, -1, -2}
- Dim YDirection() As SByte = {-1, -2, -2, -1, 1, 2, 2, 1}
- Dim SideBitboard As ULong = CurrentGame.GetSetComputerBitboard()
- If GenTurn = Turn.Player Then
- SideBitboard = CurrentGame.GetSetPlayerBitboard()
- End If
- For XYIndex = 0 To 7
- Dim EndFile As SByte = StartFile + XDirection(XYIndex)
- Dim EndRank As SByte = StartRank + YDirection(XYIndex)
- If (EndFile > -1 And EndFile < 8) And (EndRank > -1 And EndRank < 8) Then
- Dim TargetSquare64 As ULong = (1UL << (EndRank * 8 + EndFile))
- If ControlledSquares = True Then
- TargetSquares = TargetSquares Or TargetSquare64
- ElseIf (SideBitboard And TargetSquare64) = 0 Then
- TargetSquares = TargetSquares Or TargetSquare64
- End If
- End If
- Next
- Return TargetSquares
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement