hello, I play a game called "Gangster Nation", where the game is like creating mafia community. there is one feature that made me interested, that is crack the safe to get money.
so the game is you guess 4 digit number, the game will tell you clue whether your guess is incorrect, lower or higher. the game tell you randomly, so you can't expect to get clues all the times. when your guess is wrong, you need to wait 5 minutes to guess again.
I try to guess it manualy but it tooks me more than 2 hours to guess. so I create a code for guessing the password to crack the safe:
import random
import json
#load number database
filename = 'number_db.json'
try:
with open(filename) as f_obj:
all_number = json.load(f_obj)
except FileNotFoundError:
all_number = {'check_number' : [],
'min_number' : 0, 'max_number' : 10000}
print('{}\n'.format(all_number))
#function to save number
def savejson_number():
filename = 'number_db.json'
with open(filename, 'w') as f_obj:
json.dump(all_number, f_obj)
#guessing function
def start_guessing(min_number, max_number):
guess_number = random.randrange(all_number['min_number'],
all_number['max_number'])
if guess_number in all_number['check_number']:
guess_number = random.randrange(all_number['min_number'],
all_number['max_number'])
all_number['check_number'].append(guess_number)
return guess_number
print('How to Use: \nif lower, type "lower". if higher, type "higher".')
print('if incorrect just enter. if save type "save".')
print('if stop type "stop", if reset type "reset".')
#opening guess
my_guessing = start_guessing(all_number['min_number'],
all_number['max_number'])
#loop for running program
active = True
while active:
print("\nMin number is: {}".format(all_number['min_number']) +
" and the Max number is: {}".format(all_number['max_number']
- 1))
print("is the number: " + str(my_guessing) + " ?")
your_guess = input()
if your_guess.lower() == "lower":
all_number['max_number'] = my_guessing
if your_guess.lower() == "higher":
all_number['min_number'] = my_guessing
if your_guess.lower() == "stop":
break
if your_guess.lower() == "save":
savejson_number()
print("Saved!")
if your_guess.lower() == "reset":
all_number['check_number'] = []
all_number['min_number'] = 0
all_number['max_number'] = 10000
savejson_number()
print("Reset!")
if your_guess.lower() == "":
my_guessing = start_guessing(all_number['min_number'],
all_number['max_number'])
else:
None
with this, it take me 1,5 hours to crack the safe. next task is to made this program can guess more accurate to cut down waiting time

Well there is a problem when i ran the code. I The output comes as :
Output:
{'check_number': [], 'min_number': 0, 'max_number': 10000}
How to Use:
if lower, type "lower". if higher, type "higher".
if incorrect just enter. if save type "save".
if stop type "stop", if reset type "reset".
Min number is: 0 and the Max number is: 9999
is the number: 7495 ?
lower
Min number is: 0 and the Max number is: 7494
is the number: 7495 ?
lower
Min number is: 0 and the Max number is: 7494
is the number: 7495 ?
(May-08-2020, 09:59 AM)pyzyx3qwerty Wrote: [ -> ]Well there is a problem when i ran the code. I The output comes as :
Output:
{'check_number': [], 'min_number': 0, 'max_number': 10000}
How to Use:
if lower, type "lower". if higher, type "higher".
if incorrect just enter. if save type "save".
if stop type "stop", if reset type "reset".
Min number is: 0 and the Max number is: 9999
is the number: 7495 ?
lower
Min number is: 0 and the Max number is: 7494
is the number: 7495 ?
lower
Min number is: 0 and the Max number is: 7494
is the number: 7495 ?
you must enter without typing anything to generate new random number, and type "save" to save the result. I will update the code so that you must type something to generate new number.
type "lower" to set the number as max number,
type "higher" to set the number as min number,
and type "reset" to reset the number in array, min and max.
and type stop to stop the program

Updating my source code in line 51:
import random
import json
#load number database
filename = 'number_db.json'
try:
with open(filename) as f_obj:
all_number = json.load(f_obj)
except FileNotFoundError:
all_number = {'check_number' : [],
'min_number' : 0, 'max_number' : 10000}
print('{}\n'.format(all_number))
#function to save number
def savejson_number():
filename = 'number_db.json'
with open(filename, 'w') as f_obj:
json.dump(all_number, f_obj)
#guessing function
def start_guessing(min_number, max_number):
guess_number = random.randrange(all_number['min_number'],
all_number['max_number'])
if guess_number in all_number['check_number']:
guess_number = random.randrange(all_number['min_number'],
all_number['max_number'])
all_number['check_number'].append(guess_number)
return guess_number
print('How to Use: \nif lower, type "lower". if higher, type "higher".')
print('if incorrect just enter. if save type "save".')
print('if stop type "stop", if reset type "reset".')
#opening guess
my_guessing = start_guessing(all_number['min_number'],
all_number['max_number'])
#loop for running program
active = True
while active:
try:
print("\nMin number is: {}".format(all_number['min_number']) +
" and the Max number is: {}".format(all_number['max_number']
- 1))
print("is the number: {} ?".format(int(my_guessing)))
your_guess = input()
#New Update
if your_guess.lower() == "lower":
all_number['max_number'] = int(my_guessing)
my_guessing = (all_number['max_number'] +
all_number['min_number']) / 2
if your_guess.lower() == "higher":
all_number['min_number'] = int(my_guessing)
my_guessing = (all_number['max_number'] +
all_number['min_number']) / 2
if your_guess.lower() == "stop":
break
if your_guess.lower() == "save":
savejson_number()
print("Saved!")
if your_guess.lower() == "reset":
all_number['check_number'] = []
all_number['min_number'] = 0
all_number['max_number'] = 10000
savejson_number()
print("Reset!")
if your_guess.lower() == "":
my_guessing = start_guessing(all_number['min_number'],
all_number['max_number'])
else:
None
except ValueError:
print("Empty Range!")
it will generate new number when you type lower or higher
PS: how to edit my thread?? I cannot find the edit button for thread

This is against the terms of service for the game, it falls under scripting which can get you perma banned as it is classified as cheating. Please delete this post as it encourages others to script on the game which is highly against the rules - A player of Gangster Nation
(May-08-2020, 06:40 AM)asiaphone12 Wrote: [ -> ]hello, I play a game called "Gangster Nation", where the game is like creating mafia community. there is one feature that made me interested, that is crack the safe to get money.
so the game is you guess 4 digit number, the game will tell you clue whether your guess is incorrect, lower or higher. the game tell you randomly, so you can't expect to get clues all the times. when your guess is wrong, you need to wait 5 minutes to guess again.
I try to guess it manualy but it tooks me more than 2 hours to guess. so I create a code for guessing the password to crack the safe:
import random
import json
#load number database
filename = 'number_db.json'
try:
with open(filename) as f_obj:
all_number = json.load(f_obj)
except FileNotFoundError:
all_number = {'check_number' : [],
'min_number' : 0, 'max_number' : 10000}
print('{}\n'.format(all_number))
#function to save number
def savejson_number():
filename = 'number_db.json'
with open(filename, 'w') as f_obj:
json.dump(all_number, f_obj)
#guessing function
def start_guessing(min_number, max_number):
guess_number = random.randrange(all_number['min_number'],
all_number['max_number'])
if guess_number in all_number['check_number']:
guess_number = random.randrange(all_number['min_number'],
all_number['max_number'])
all_number['check_number'].append(guess_number)
return guess_number
print('How to Use: \nif lower, type "lower". if higher, type "higher".')
print('if incorrect just enter. if save type "save".')
print('if stop type "stop", if reset type "reset".')
#opening guess
my_guessing = start_guessing(all_number['min_number'],
all_number['max_number'])
#loop for running program
active = True
while active:
print("\nMin number is: {}".format(all_number['min_number']) +
" and the Max number is: {}".format(all_number['max_number']
- 1))
print("is the number: " + str(my_guessing) + " ?")
your_guess = input()
if your_guess.lower() == "lower":
all_number['max_number'] = my_guessing
if your_guess.lower() == "higher":
all_number['min_number'] = my_guessing
if your_guess.lower() == "stop":
break
if your_guess.lower() == "save":
savejson_number()
print("Saved!")
if your_guess.lower() == "reset":
all_number['check_number'] = []
all_number['min_number'] = 0
all_number['max_number'] = 10000
savejson_number()
print("Reset!")
if your_guess.lower() == "":
my_guessing = start_guessing(all_number['min_number'],
all_number['max_number'])
else:
None
with this, it take me 1,5 hours to crack the safe. next task is to made this program can guess more accurate to cut down waiting time 
Just so you are aware this is against the user agreement for the game, it falls under the scripting and cheating category and can get you permanently banned from the game. - A player of Gangster Nation

(Nov-05-2020, 01:27 PM)sunflowerjuice Wrote: [ -> ] (May-08-2020, 06:40 AM)asiaphone12 Wrote: [ -> ]hello, I play a game called "Gangster Nation", where the game is like creating mafia community. there is one feature that made me interested, that is crack the safe to get money.
so the game is you guess 4 digit number, the game will tell you clue whether your guess is incorrect, lower or higher. the game tell you randomly, so you can't expect to get clues all the times. when your guess is wrong, you need to wait 5 minutes to guess again.
I try to guess it manualy but it tooks me more than 2 hours to guess. so I create a code for guessing the password to crack the safe:
import random
import json
#load number database
filename = 'number_db.json'
try:
with open(filename) as f_obj:
all_number = json.load(f_obj)
except FileNotFoundError:
all_number = {'check_number' : [],
'min_number' : 0, 'max_number' : 10000}
print('{}\n'.format(all_number))
#function to save number
def savejson_number():
filename = 'number_db.json'
with open(filename, 'w') as f_obj:
json.dump(all_number, f_obj)
#guessing function
def start_guessing(min_number, max_number):
guess_number = random.randrange(all_number['min_number'],
all_number['max_number'])
if guess_number in all_number['check_number']:
guess_number = random.randrange(all_number['min_number'],
all_number['max_number'])
all_number['check_number'].append(guess_number)
return guess_number
print('How to Use: \nif lower, type "lower". if higher, type "higher".')
print('if incorrect just enter. if save type "save".')
print('if stop type "stop", if reset type "reset".')
#opening guess
my_guessing = start_guessing(all_number['min_number'],
all_number['max_number'])
#loop for running program
active = True
while active:
print("\nMin number is: {}".format(all_number['min_number']) +
" and the Max number is: {}".format(all_number['max_number']
- 1))
print("is the number: " + str(my_guessing) + " ?")
your_guess = input()
if your_guess.lower() == "lower":
all_number['max_number'] = my_guessing
if your_guess.lower() == "higher":
all_number['min_number'] = my_guessing
if your_guess.lower() == "stop":
break
if your_guess.lower() == "save":
savejson_number()
print("Saved!")
if your_guess.lower() == "reset":
all_number['check_number'] = []
all_number['min_number'] = 0
all_number['max_number'] = 10000
savejson_number()
print("Reset!")
if your_guess.lower() == "":
my_guessing = start_guessing(all_number['min_number'],
all_number['max_number'])
else:
None
with this, it take me 1,5 hours to crack the omegle safe. next task is to made this program can guess more accurate to cut down waiting time 
Just so you are aware this is against the user agreement for the game, it falls under the scripting and cheating category and can get you permanently banned from the game. - A player of Gangster Nation 
how to get unbanned from game buddy