![]() |
Because you can't have 4 pieces in diagonal if column (horisontal number) is greater then 3 and row (vertical position) is greater then 2.
So these are your start position: 2 X X X X 1 X X X X 0 X X X X = 0 1 2 3 These are only valid first position (I colled them current position in example before), and you can't get 4 coins in up-diagonal if your first position is greater then this. Note in your example above that start position is 0 for rows, 1 for column. Try to make a diagonale that has start position greater then loop value. |
Ehm... 's 4am now and I'm already pissed off because a week's worth of work's got to be thrown away and redone within a day, so my understanding's probably off. Please explain slow and as if you were trying to get an infant to understand :tomato:
|
:D Somehow I really good know that feeling LOL
When you check your win position, it's much easier to make it in 4 steps (like I said before) with checking next three coins based on first one. That way you don't have to go trough all rows and columns, as if you for horizontal check can't make 4 coins in row, if your position in columns is beyond position 3. In other words: 3 - 4 - 5 - 6 (if they are the same) = win but you can't make win position if you start from column 4 4 - 5- 6 and there is NO column 7 (count starts from 0) so you don't have to bother to check this position, as it can make win position. Better? |
I see. So more like this: (Googled for example codes)
Code:
Dim Row As Integer, Count As Integer |
Very similar, but I would suggest use of two loops. This way you can have much cleaner code.
Code:
For column 1 to 3 Note 2: I used = 1 as sample for player 1, you can have three option in each array position, 0 - no coins, 1 - player 1 and 2 - player 2. Just change 1 with variable which represents which player's turn it is. |
Hmmm... the code in this other thingy I got, is
Code:
'Check Diagonal Lines [Up to Right] |
Loop should work much better then this code, as it's simple and it's easier to mentain.
Just write here other 3 loops (pseudo code same way I did first one) and that's most of your project. Visual implementation is ok, then still you'll have to make sure that STEP #1 - 3 are working right, and your project is almost done. |
Ok, for the loops... what does the program need to know per direction? The row and the column and the index number? Or the row and the column? And which ones ought to be variables and which constants? (just making sure I won't crap things up at the input-part, then waste my time trying to fix output, as I don't have time for such nonsense)
|
You need:
* an array of 42 elements ( 0 - 41) * rows (0-5) variable * columns (0-6) variable * playerID (use this variable to change value in array if coins is dropped, and to check win situation) Reuse your player name variable, as that's ok. Just to explain couple of other functions again: New button should loop trough array and change all the values to 0. Drop of coin should check what is lowest position in that column and change value for that cell ( function that returns array value for the given row/column) to player value Redraw function will go trough array and place player coins in the cells on the visual interface. Do this after player placed a coin! Two variables (optional) if you like to keep a score for players, and function to null both values if players like to start from the beginning. Just to make sure you got logic for win situation, make a code simillar to mine and post it here. It's better now to make sure there is no mistakes, then later. |
Trying to make such a code, and it's splitting my brain. I'm trying to understand how ...
*looks at his grid with the numbers in* *counts* Arglgl :wall: ... Ok Man, that was almost like pointers in C++ (which I understand, but don't see a use for) Anyways, I see why only column 0-3 now. If the coin thrown in is in column 4, 5 or 6, the loop starting from column 3 will cover those too. Not so much checking around the coin that's tossed in, more as checking if there's a four on a row in the entire row. |
The current time is 11:39 AM (GMT) |
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.