|
Post by bplus on Jan 27, 2024 21:05:47 GMT
Watch the algo for Binary Search narrow down the Guess number with clues of higher or lower:
'2024-01-25 update DefInt A-Z While 1 Hi = 101: Lo = 0: number = Int(Rnd * 100) + 1 ' guess number 1 to 100 ' number = 1 'test limits ' number = 100 Do guess = Int((Hi + Lo) / 2) Print "AI guesses the number ("; _Trim$(Str$(number)); ") as"; guess If guess < number Then Print "low": Lo = guess + 1 If guess > number Then Print "high": Hi = guess - 1 Loop Until guess = number Input "Yeah, press enter for another..."; w$ Cls Wend
|
|