01-12-2004, 08:07 PM | #1 | ||
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
Why isn't it working properly?
If you toss a disc in at the second row, it'll stay in the loop after the if-statement, after all that has to be done, is done, except when you toss the disc in the first column. Then it works fine. I tried putting an else-statement there, to turn the loop off if the else-statement was called, and it works fine then, but the four on a row diagonally isn't detected then. |
||
|
|
01-12-2004, 09:50 PM | #2 | ||
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
Can you add your documentation.
This should be simple program, if you are not building AI. I'll check the code after dinner. |
||
|
|
01-12-2004, 10:01 PM | #3 | ||
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
My documentation? As in what which calculation does?
Code:
Public Sub NESWDiagonaal(intLastSpot, bytChecking, intPosition) intLastSpot = intPosition Dim intKolom As Integer Dim intRij As Integer Dim intMultiply As Integer Dim intMultiplyFinal As Integer ' * Geen doorvallen langs beneden intLastSpot = intLastSpot - 24 Do Until intLastSpot >= 0 *intLastSpot = intLastSpot + 8 Loop Select Case intPosition *Case 14 * *intLastSpot = 14 *Case 21 * *intLastSpot = 21 *Case 28 * *intLastSpot = 28 *Case 35 * *intLastSpot = 35 End Select ' * Aantal keren dat ge naar rechtsboven kunt intKolom = 6 - intLastSpotKolom MsgBox "intKolom = " & intKolom & "." If intKolom < 3 Then *intMultiply = intKolom Else *intMultiply = 3 End If intMultiplyFinal = intMultiply * 8 MsgBox "Final = " & intMultiplyFinal & "." Do Call WinCheck(intLastSpot, bytChecking) If intMultiply > 0 Then * intLastSpot = intLastSpot + 8 * intMultiply = intMultiply - 1 * MsgBox "intMultiply = " & intMultiply & "." End If Loop Until intLastSpot = (intPosition + intMultiplyFinal) End Sub The intKolom and intMultiply are there to take care of the wrapping around. We don't want people to win when they have two discs diagonal from each other on the right edge and two on the left. |
||
|
|
01-12-2004, 11:07 PM | #4 | ||
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
I was thinking about documentation for the project, as planning and pseudo code.
Reason program loops is in this loop: Code:
Do Call WinCheck(intLastSpot, bytChecking) If intMultiply > 0 Then *intLastSpot = intLastSpot + 8 *intMultiply = intMultiply - 1 *MsgBox "intMultiply = " & intMultiply & "." End If Loop Until intLastSpot = (intPosition + intMultiplyFinal) When do you need to turn in this program? |
||
|
|
01-12-2004, 11:57 PM | #5 | ||
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
You mean the assignment doc? It's in Dutch, but I'll translate.
Quote:
|
||
|
|
02-12-2004, 12:05 AM | #6 | ||
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
So,
how do you like to make sure that player won? Just write pseudo code of your program. |
||
|
|
02-12-2004, 12:08 AM | #7 | ||
|
I will be takin a VB course next semester YAY . What is this program suppose to do? All I ever done was simmple tiny piece of code for my wolf3d mod.
|
||
|
|
02-12-2004, 12:16 AM | #8 | ||
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
Position = LastPosition
counter = 0 <check horizontally> Position = Position - 3 or until it hits the left border do if Position.value = CurrentPlayer { counter ++ } else { counter = 0 } if counter = 4 { win! } Position ++ loop until Position = Position + 3 or Position = last column <check vertically> Position = Position - 21 or - 7 until it's at the bottom row do if Position.value = CurrentPlayer { counter ++ } else { counter = 0 } if counter = 4 { win! } Position += 7 loop until Position = Position + 21 or Position = top <check diagonally / > Position = Position - 24 or - 8 until it's either at the leftmost column or the bottom row do if Position.value = CurrentPlayer { counter ++ } else { counter = 0 } if counter = 4 { win! } position += 8 loop until Position = Position + 24 or Position = rightmost column or top row <check diagonally \ > Position = Position - 18 or - 6 until it's either at the rightmost column or the bottom row do if Position.value = CurrentPlayer { counter++ } else { counter = 0 } if counter = 4 { win! } position += 6 loop until Position = Position + 18 or Position = leftmost column or top row. |
||
|
|
02-12-2004, 01:01 AM | #9 | ||
Join Date: Nov 2004
Location: Afrim, Albania
Posts: 2,113
|
This code does not make much sense to me.
Here is what you have to do: (pseudo code) 1. Make a function which will return index value in the cell for given row / column 2. Make a function which will return row / column for a given index 3. Make a function which will for column check where the top is and place a coin there 4. Check anywhere you have 4 cells horizontally that mach 5. Check anywhere you have 4 cells vertically that mach 6. Check anywhere you have 4 cells up diagonal that mach 7. Check anywhere you have 4 cells down diagonal that mach 8. Check if all fields are used 9. Make a function that checks steps 4 - 7 and then give a winner, move to next player, or if all fields are used (draw). Details: STEP 3 Check top value for that column ( using function in step 2, eg col 1, row 5) -- if is filled: don’t allow to place piece there (message) -- if is empty, check next one (-8) Loop this way till you don’t place a coin on the bottom. STEP 4 Create loop for Column 0 – 3 -- Create loop for Rows 0 - 5 ----Check if CP (Current position), CP + 1 , CP + 2 and CP + 3 are the same ------If yes, we have a winner STEP 5 Create loop for Columns 0 – 7 -- Create loop for Rows 0 - 2 ----Check if CP (Current position), CP + 7 , CP + 14 and CP + 21 are the same ------If yes, we have a winner STEP 6 Create loop for Column 0 – 3 -- Create loop for Rows 0 - 2 ----Check if CP (Current position), CP + 8 , CP + 16 and CP + 24 are the same ------If yes, we have a winner STEP 7 Create loop for Column 3 – 6 -- Create loop for Rows 3 - 5 ----Check if CP (Current position), CP - 8 , CP - 16 and CP - 24 are the same ------If yes, we have a winner STEP 8 Run separate functions similar to step 3 where you’ll find top for each column. If you have 7 hits and you at this step, then it’s draw STEP 9 Just to make it easy, functions which incorporates steps 4 – 8 If you follow this pseudo code, it should be a piece of cake to make this program. |
||
|
|
02-12-2004, 01:19 AM | #10 | ||
Join Date: Sep 2004
Location: Dentergem, Belgium
Posts: 1,811
|
That's basically what I've been trying to do. Although I don't understand why you're only checking to row 2, or to column 3, and in the diagonals, how it would know cases like this?
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 2 2 0 0 0 0 1 2 2 0 0 0 1 2 1 1 0 0 1 2 2 1 1 0 0 |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Visual problem in all dos games | rkrd | Troubleshooting | 6 | 07-12-2007 09:43 PM |
AdLib Visual Composer | crazedloon | Gaming Zone | 1 | 20-09-2007 11:30 AM |
Damn It | punch999 | Blah, blah, blah... | 2 | 01-07-2007 06:39 PM |
Visual Basic, Helpme! | hotty_green | Programming | 7 | 19-07-2006 06:39 PM |
Visual Basic | tomf | Programming | 11 | 05-03-2006 10:35 PM |
|
|
||
  |