Advertisement
Just_Tom

Untitled

Mar 24th, 2024
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VisualBasic 1.64 KB | Source Code | 0 0
  1. Private Function GenerateSlidingMoves(CurrentGame As GameInstance, StartSquare As Byte, GenTurn As Turn, PieceType As Byte, ControlledSquares As Boolean) As ULong
  2.     Dim DirectionsAvailableSliding() As SByte = {8, -8, 1, -1, 9, -9, 7, -7}
  3.     Dim TargetSquares As ULong = 0
  4.     Dim StartIndex As Byte = 0
  5.     Dim EndIndex As Byte = 7
  6.     Dim SideBitboard As ULong = CurrentGame.GetSetComputerBitboard()
  7.     Dim OppositeBitboard As ULong = CurrentGame.GetSetPlayerBitboard()
  8.     If PieceType = 2 Then
  9.         EndIndex = 3
  10.     ElseIf PieceType = 3 Then
  11.         StartIndex = 4
  12.     End If
  13.     If GenTurn = Turn.Player Then
  14.         SideBitboard = CurrentGame.GetSetPlayerBitboard()
  15.         OppositeBitboard = CurrentGame.GetSetComputerBitboard()
  16.     End If
  17.     For DirectionIndex = StartIndex To EndIndex
  18.         Dim DEndIndex As SByte = NumSquaresToEdgeSliding(StartSquare)(DirectionIndex) - 1
  19.         For Direction = 0 To DEndIndex
  20.             Dim TargetSquare As Byte = StartSquare + (DirectionsAvailableSliding(DirectionIndex) * (Direction + 1))
  21.             Dim TargetSquare64 As ULong = (1UL << TargetSquare)
  22.             If (SideBitboard And TargetSquare64) > 0 And ControlledSquares = False Then
  23.                 Exit For
  24.             ElseIf (SideBitboard And TargetSquare64) > 0 And ControlledSquares = True Then
  25.                 TargetSquares = TargetSquares Or TargetSquare64
  26.                 Exit For
  27.             End If
  28.             TargetSquares = TargetSquares Or TargetSquare64
  29.             If (OppositeBitboard And TargetSquare64) > 0 Then
  30.                 Exit For
  31.             End If
  32.         Next
  33.     Next
  34.     Return TargetSquares
  35. End Function
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement