Guess My Number
#5
Guess Number 2019... 2021
https://qb64forum.alephc.xyz/index.php?topic=3999

Computer guessing from Milliard
https://qb64forum.alephc.xyz/index.php?t...#msg133452

Code: (Select All)
t = 0: h1 = 0: h2 = 10^7: RANDOMIZE TIMER ' DANILIN daMilliard.bas
human = INT(RND*h2) 'human
comp = 1 'INT(RND*h2) 'comp
10 t = t+1: PRINT t; "human ="; human; "     comp ="; comp;
IF comp < human THEN PRINT "MORE": a = comp: comp = INT((comp+h2)/2): h1 = a: GOTO 10
IF human < comp THEN PRINT "less": a = comp: comp = INT((h1+comp)/2): h2 = a: GOTO 10
PRINT "win by "; t; " steps"
END

Code: (Select All)
h1=0: h2=10^7: t=1: f=0: Randomize Timer ' DANILIN daMilliard.bas
human = Int(Rnd*h2) 'human
comp = Int(Rnd*h2) 'comp
While f < 1
Print t; "human ="; human; "     comp ="; comp;
If comp < human Then
Print " MORE": a=comp: comp=Int((comp+h2)/2): h1=a
  Else If human < comp Then
  Print " less": a=comp: comp=Int((h1+comp)/2): h2=a
    Else If human=comp Then
    Print " win by "; t; " steps": f=1
End If: End If: End If: t = t + 1
Wend: End

Code: (Select All)
1  human = 1326126     comp = 1928303  less
2  human = 1326126     comp = 964151  MORE
3  human = 1326126     comp = 1446227  less
4  human = 1326126     comp = 1205189  MORE
5  human = 1326126     comp = 1325708  MORE
6  human = 1326126     comp = 1385967  less
7  human = 1326126     comp = 1355837  less
8  human = 1326126     comp = 1340772  less
9  human = 1326126     comp = 1333240  less
10  human = 1326126     comp = 1329474  less
11  human = 1326126     comp = 1327591  less
12  human = 1326126     comp = 1326649  less
13  human = 1326126     comp = 1326178  less
14  human = 1326126     comp = 1325943  MORE
15  human = 1326126     comp = 1326060  MORE
16  human = 1326126     comp = 1326119  MORE
17  human = 1326126     comp = 1326148  less
18  human = 1326126     comp = 1326133  less
19  human = 1326126     comp = 1326126  win by 19 steps

+ C# + Python version

OnLine Execute

https://jdoodle.com/ia/vY4
Write name of program in 1st line to copy & paste & save filename.bas
Insert program pictures: press print-screen-shot button
Open paint & Paste & Save as PNG
Add picture file to program topic

Russia looks world from future. Big data is peace data.
I never recommend anything & always write only about myself
Reply


Messages In This Thread
Guess My Number - by SierraKen - 09-18-2022, 11:04 PM
RE: Guess My Number - by PhilOfPerth - 09-18-2022, 11:11 PM
RE: Guess My Number - by bplus - 09-19-2022, 12:25 AM
RE: Guess My Number - by SierraKen - 09-20-2022, 09:23 PM
RE: Guess My Number - by DANILIN - 09-25-2022, 12:47 PM
RE: Guess My Number - by mnrvovrfc - 09-25-2022, 05:21 PM
RE: Guess My Number - by SierraKen - 09-25-2022, 08:21 PM
RE: Guess My Number - by mnrvovrfc - 09-26-2022, 05:16 AM
RE: Guess My Number - by SierraKen - 09-25-2022, 08:24 PM
RE: Guess My Number - by DANILIN - 11-07-2022, 10:45 AM
RE: Guess My Number - by DANILIN - 02-23-2023, 02:45 AM
RE: Guess My Number - by Sprezzo - 02-24-2023, 02:33 PM
RE: Guess My Number - by DANILIN - 02-24-2023, 04:22 PM
RE: Guess My Number - by bplus - 02-24-2023, 04:36 PM
RE: Guess My Number - by DANILIN - 02-24-2023, 04:52 PM
RE: Guess My Number - by bplus - 02-24-2023, 05:09 PM
RE: Guess My Number - by DANILIN - 04-04-2023, 08:35 AM
RE: Guess My Number - by SMcNeill - 04-04-2023, 10:58 AM
RE: Guess My Number - by DANILIN - 05-20-2023, 03:36 AM



Users browsing this thread: 16 Guest(s)