# Day 19 – It starts getting hard!

Whelp, nine-minute video today, and it was a doozy. We’re getting into the nitty-gritty, and I can’t tell you how annoyed I am that I’m watching from the sidelines instead of actually doing the coding alongside him. Once I return to Austin on the 29th I’ll have to spend a day fixing that.

But I’m doing the next best thing and following along making sure I understand exactly what happens at every step. Today we learned about setting items outside of either the Start or Instance function if you wish them to be unrestrained by either qualifier. We used this to help define the max (whats the maximum possible number?), min (What’s the lowest possible number?) and guess (What number did I just guess?) variables.

(1) At every step we redefined the min and guess variables thusly:

min = guess:

guess = ( max +min / 2);

Okay great, this redefines our guess. But I don’t get why it didn’t break everything by immediately thereafter redefining min based on the new guess. Apparently this is the part where coding and mathematics variables differ because it appears old lines will not redeploy after being executed, otherwise our current code would break into infinite loop.

(2) The professor solved an ‘edge case’ (unusual circumstance caused by using the extreme borderline values) where the computer would never guess 1000, only guessing 999 due to the way the aforementioned code rounded down. He solved this by adding this to the Start function:

max = max + 1;

So let’s walk through this logically: We’re setting the maximum to 1000 at the beginning of the game, then immediately redefining it to Max+1. Why aren’t we just defining the max to be 1001 before executing the Start function? The weird workaround seems silly and an unnecessary complication.

Update: Oh wait, just realized. If you do that, the game will tell the player that the highest number they can pick is 1001. Also shoutout to this guy who spotted a problem that made the code even better: