#Binary search new problems

1 messages Β· Page 1 of 1 (latest)

soft patio
#

Hey all, this issue is quite frustrating and we're not really sure how to solve it. Any help would be appreciated.

ivory forum
#

Can you explain a bit more?

#

Like what line should be hit but is not being hit in your code?

wet swift
#

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

ivory forum
#

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 πŸ˜‰

soft patio
#

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 :)

ivory forum
#

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.

wet swift
#

okay, then let me paste everything i have right now

ivory forum
#

And what line is the last one before your 8th is being skipped?

wet swift
#

114-124, it keeps repeating until the seventh one, and then stops

ivory forum
#

So 123 is { one too much, isnt it? Just wondering

wet swift
#

oh yeah, sorry haha

ivory forum
#

and how does this Ienumerator repeat itself? I seem to be blind, but its only running once, isnt it

wet swift
#

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

ivory forum
#

So it runs the TurnCard , which calls ChangeTurn and that calls the IENumerator again, right?

wet swift
#

exactly

ivory forum
#

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

wet swift
#

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)

ivory forum
#

So does 102 or 116 being hit with card 8? or what happens instead?

wet swift
#

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

ivory forum
#

Okay, so it enters the TurnCard function correctly?

wet swift
#

let me check

ivory forum
#

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]);
wet swift
wet swift
#

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

ivory forum
#

Sounds good πŸ™‚ same here πŸ˜„