Skip to content

Instantly share code, notes, and snippets.

@majiang
Created August 31, 2012 05:41
Show Gist options
  • Select an option

  • Save majiang/3549430 to your computer and use it in GitHub Desktop.

Select an option

Save majiang/3549430 to your computer and use it in GitHub Desktop.
駒を裏返す処理
Private Sub NewBoard(x As Integer, y As Integer)
Dim v As ULong = values(x, y)
Dim dxs As Integer() = {1, 1, 0, -1, -1, -1, 0, 1}
Dim dys As Integer() = {0, 1, 1, 1, 0, -1, -1, -1}
For direction As Integer = 0 To 7
Dim dx = dxs(direction), dy = dys(direction)
Dim cx As Integer, cy As Integer
cx = x + dx
cy = y + dy
Dim first As Boolean
first = True
While 0 <= cx AndAlso cx < Board.size AndAlso 0 <= cy AndAlso cy < Board.size
If values(cx, cy) = 0 Then Exit While
If values(cx, cy) = v Then
If first Then Exit While
While x <> cx OrElse y <> cy
values(cx, cy) = v
cx -= dx
cy -= dy
End While
Continue For
End If
first = False
cx += dx
cy += dy
End While
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment