#Binary search new problems
1 messages Β· Page 1 of 1 (latest)
Hey all, this issue is quite frustrating and we're not really sure how to solve it. Any help would be appreciated.
Can you explain a bit more?
Like what line should be hit but is not being hit in your code?
at the moment, it seems every line is working, but somehow, the iteration won't make it past certain list position, in this case, the 8th position
if you need the whole code to see context i can also send it - it's a little bit difficult to explain what is happening since i don't know
I only see a coroutine, which is started once. Thats not an iteration
so if you want help on the iteration part, you should at least send that π
the code should repeat every time it is the AIs turn, which is what we refer to as an iteration. That may not be the correct term, but that's what they meant :)
Yeah but your code (I see here) is not repeating for now. So you should paste more of the code that is actually calling this several times.
okay, then let me paste everything i have right now
https://hatebin.com/cmsyoerngm :) now you can see it in context
And what line is the last one before your 8th is being skipped?
114-124, it keeps repeating until the seventh one, and then stops
So 123 is { one too much, isnt it? Just wondering
oh yeah, sorry haha
and how does this Ienumerator repeat itself? I seem to be blind, but its only running once, isnt it
it doesn't repeat because that would mean starting the search over and over, the only thing that repeats is the else statement
i've tried with a for and with just the else statement, both giving me the same results
So it runs the TurnCard , which calls ChangeTurn and that calls the IENumerator again, right?
exactly
Kinda spaghetti, but okay. So, if you debug your card number in that ienumerator, is it even called with number 8? Or what line is not being called?
If you say 114-124, you should debug outside of the if statement, if its being called at all.
Cause either 102 or 116 is not being true
no, it doesn't call numer 8, but it debugs (i've tried it before) every number except 8 (meaning cards 4, 6, 7 are shown in console in their respective turns)
So does 102 or 116 being hit with card 8? or what happens instead?
it should turn because 116 is true, it isn't turned until the ai turns it, but it just ignores it, and 102 is also correct because the position of the correct card (in this case) is exactly the one that is in the center of the range in that turn
Okay, so it enters the TurnCard function correctly?
let me check
And don't guess that its true, debug and prove it π otherwise you might miss a simple mistake π
And one suggestion, why dont you use the same as in the if statement to turn the card? Instead of your confusing calculation variables
TurnCard(allCards[centralCard]);
i left that unchanged before sending the code, it's now like that :)
it actually enters the if statement at 102 but it doesn't make past it
i think i'll stop now and i'll continue tomorrow morning- it's pretty late. If I still have the same errors, I'll send a message again
Sounds good π same here π