Created
August 31, 2012 05:41
-
-
Save majiang/3549430 to your computer and use it in GitHub Desktop.
駒を裏返す処理
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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