![]() |
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. |
Can you add your documentation.
This should be simple program, if you are not building AI. I'll check the code after dinner. |
My documentation? As in what which calculation does?
Code:
Public Sub NESWDiagonaal(intLastSpot, bytChecking, intPosition) 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. |
I was thinking about documentation for the project, as planning and pseudo code.
Reason program loops is in this loop: Code:
Do When do you need to turn in this program? |
You mean the assignment doc? It's in Dutch, but I'll translate.
Quote:
|
So,
how do you like to make sure that player won? Just write pseudo code of your program. |
I will be takin a VB course next semester YAY :D. What is this program suppose to do? All I ever done was simmple tiny piece of code for my wolf3d mod.
|
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. |
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. ;) |
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 |
The current time is 06:30 AM (GMT) |
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.