|
dear friends,
I would like to ask some help. I am a beginner in vb.net programming and right now we have a thesis in school to develop an Application of Programming to Chemistry Dama. I already have a sample codes that I attached below.
The problem that I have right now is how can I capture 2 or 3 chips in one move. The code that I have is for capturing 1 chip per move. Need some help to have some idea on how I can modify my codes.
Thank you
sample code that I have in my program
'-----single chip taken-----------------'chip 9
If picCheckers9.Location = square17 And picCheckers13.Location.X > 307 And picCheckers13.Location.Y > 189 And Open14 = True And Open17 = False Then
picCheckers13.Location = square14
str13 = 14
Open17 = True
Open14 = False
Open21 = True
picCheckers9.Location = square40
lblTurn.Text = "Red"
DataGridView1.Rows.Add(New Object() {"Al", "3,4", "Al", "AlAl", "-54"})
'----extra for double taken chips----- chip 9
ElseIf picCheckers9.Location = square17 And picCheckers1.Location = square9 Or picCheckers2.Location = square9 Or picCheckers5.Location = square9 Or picCheckers6.Location = square9 And picCheckers13.Location.X > 307 And picCheckers13.Location.Y > 189 And Open14 = True And Open17 = False And Open9 = False And Open5 = True Then
picCheckers13.Location = square14
str13 = 14
Open17 = True
Open14 = False
Open21 = True
picCheckers9.Location = square40
DataGridView1.Rows.Add(New Object() {"Al", "3,4", "Al", "AlAl", "-54"})
'----extra for double taken chips-----
'Else
'lblTurn.Text = "Red"
|
|
|
|
|
Chips? Checkers? Moves?? Capture?? What in the hell are you talking about??
And I'm getting the vibe that this should have been posted in the Algorithms forum.
|
|
|
|
|
Hello Enzomatriz,
It looks like a game of checkers?
And you say your code to take one chip works?
Ok so as I see it maybe you can place the (YOUR CODE) code block which takes the oppositions chips in a LOOP where, after taking one chip you see if there are other chips to take (as partof the same same move using the same peice/chip/counter that you use to make the initial move and if not another then obviously let the otherplayer have his/her turn.
So to explain roughly you would end up with....
PSEUDO CODE
===========
Start game
Player 1 turn (your code)
My_Turn_Complete = False
My_Turn_Partial = False
Do
'The next line looks for pieces that can be taken by your Piece
If I can take opposition pieces Then
Take oppostion peice
YOUR CODE FROM HERE
'i have started a move which may let me take take more pieces
My_Turn_Partial = True
ElseIf My_Turn_Partial = true Then
'I took opposition peice and no more can be taken (so my turn is finished now)
My_Turn_Complete = True
Else
'I could not take any opposition peices
'and My_Turn_Partial was false so i will defend my lines
YOUR CODE HERE (to defend your lines NOT take oppososiotn peices
My_Turn_Complete = True
End IF
Loop until My_Turn_Complete
Player 2 turn
Let player 2 make his/her move
Loop until end of game
There is a bit more than above obviosuly,
because you cannot use a different piece/chip/counter once you have started a move,
so you need to check if its the same piece that allows you continue.
but i think there is enough above to give you an idea
|
|
|
|