Home>

Here is my code:

Import Requests
Import Random
Requuser= Input ('Let's play the game Guess the number !? \ Ny-yes')
If Requuser.upper ()== 'y':
    Print ('start to play')
    Result= Requests.get ('https://game.aleksserg.repl.co/gnum')
    gamehash= result.json () ['Answer']
    Print ('The game has begun. The robot faded the number. From 0 to 1 000 000')
    Print ('Run the bot to search for a mandated number!')
    Maxnum= 1000000.
    minnum= 0.
    While True:
        Numbot= Random.Randint (Minnum, Maxnum)
        Print (F'Read number {numbot} ')
        result= requests.get (F'Https: //game.aleksserg.repl.co/gnum/{GameHash} /{Numbot} ')
        Result= result.json () ['Answer']
        IF Result== 'Larger':
            Print ('not guess! My number is more!')
            Minnum= Numbot.
        ELIF RESULT== 'LESS':
            Print ('not guess! My number is less!')
            Maxnum= Numbot.
        ELIF RESULT== 'VICTORY!':
            Print ('Bot found a number !!!!')
            Print (F'Cissed was: {numbot} ')
            Break
  • Answer # 1

    instead Numbot= Random.Randint (Minnum, Maxnum) Use Numbot= (Minnum + Maxnum) /2 . It is also worth checking what user "deceives" you.

    Numbot= (Minnum + Maxnum) /2
    result= requests.get (F'Https: //game.aleksserg.repl.co/gnum/{GameHash} /{Numbot} ')
    Result= result.json () ['Answer']
    IF Result== 'Victory!':
        Print ('Bot found a number !!!!')
        Print (F'Cissed was: {numbot} ')
        Break
    Elif Maxnum== Minnum:
        Print ('deceiver!')
    ELIF RESULT== 'LARGER':
        Print ('not guess! My number is more!')
        Minnum= Numbot.
    ELIF RESULT== 'LESS':
        Print ('not guess! My number is less!')
        Maxnum= Numbot.
    
Trends