This is the mini version of the typical reversi game. As the game involves the concept of probabilities, it is quite difficult to write out the procedures. After a lot of hard thinking, I finally figure out the way to do it. I use a two set of two dimensional array and declare as Boolean , one represent the white piece and the other one represent the black pieces. If the white piece or the black piece occupy a square, the variable becomes true or else it is false. By using this concept, the program can check how many white and black pieces appear on the chess board and which positions they occupy.
I use If...Then and Select Case.... End Select commands to check for conditions whether a white piece or a black piece can be put in a certain position so that the pieces trapped in between will change colour. I also added a procedure to display the number of white pieces and the number of black pieces at any one time and also who is the winner.
I plan to design a full version of the reversi later on. I am putting part of the codes here as the full program is too long. I f you wish to have the full program, please request it at liewvk@vbtutor.net
Option Base 1
Dim white(4, 4) As Boolean
Dim black(4, 4) As Boolean
Dim i, j, k, w, b As Integer
Dim imgtag As String
'This program is to check the number and positions of the white and black pieces on the board. Image17 is a white button while
image18 is a black button.
Sub checkstatus()
k = 0
For j = 1 To 4
For i = 1 To 4
If Image1(k).Picture = Image17.Picture Then
white(i, j) = True
Else: white(i, j) = False
End If
If Image1(k).Picture = Image18.Picture Then
black(i, j) = True
Else
black(i, j) = False
End If
k = k + 1
Print n
Next i
Next j
End Sub