Last active
November 8, 2017 11:39
-
-
Save Rast1234/e748405015f0381dc3f4a1048357cd45 to your computer and use it in GitHub Desktop.
Quickly hacked bot for virgil coin miner game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pprint import pprint | |
import time | |
import requests | |
""" | |
assists in buying most optimal gears to increase mining speed | |
""" | |
class Miner: | |
def __init__(self, type, cost, delta, mined): | |
self.type = type | |
self.cost = cost | |
self.delta = delta | |
self.eff = cost/delta | |
self.mined = mined | |
def __str__(self): | |
return("[{0:20}, {1:20}, {2:20}, {3:20}]".format(self.type, self.cost, self.delta, int(self.eff))) | |
def __repr__(self): | |
return str(self) | |
def buy(self, old_speed, cash): | |
cookies = { | |
'__cfduid': 'd7cf63d0477426ae73835750e6ad3dbf41510056175', | |
'crypto_cookies.sid': 's%3A1ppInUszbXAlT7uUOp5Ll8f55tUSAEGq.9kSyDzmxKZ3mYO5pcJOZDZz%2FFP%2F5MLnH3kZQghPNzC8', | |
'__cflb': '1172794474', | |
} | |
headers = { | |
'Origin': 'https://quest.virgilsecurity.com', | |
'Accept-Encoding': 'gzip, deflate, br', | |
'Accept-Language': 'en-US,en;q=0.8,ru;q=0.6', | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36', | |
'content-type': 'application/json', | |
'Accept': '*/*', | |
'Referer': 'https://quest.virgilsecurity.com/', | |
'Connection': 'keep-alive', | |
} | |
time_to_wait = None | |
if cash > self.cost: | |
time_to_wait = 0 | |
else: | |
time_to_wait = int((self.cost-cash)/old_speed/60) | |
print("Will buy {0} for {1:_}. Has {2:_}. Time to wait: {3:_} min.".format(self.type, self.cost, cash, time_to_wait)) | |
#exit(-1) # uncomment just to print stats and buying decision | |
data = '{"click_timestamps":[],"unit":"'+self.type+'"}' | |
url_build = 'https://quest.virgilsecurity.com/api/build' | |
r = requests.post(url_build, data=data, headers=headers, cookies=cookies, verify=False) | |
j = r.json() | |
new_speed = j['data']['pointsPerSecond'] | |
# true if bought desired item | |
result = new_speed > old_speed | |
if result: | |
print("Bought {0}".format(self.type)) | |
else: | |
print("-Fail- {0}".format(self.type)) | |
return result | |
def should_buy(x, y, speed): | |
time_to_x = x.cost/speed | |
maybe_y = y.cost/speed + x.cost/(speed+y.delta) | |
return time_to_x - maybe_y | |
def get_wealth(miners): | |
return sum([x.mined for x in miners]) | |
def stats(): | |
headers = { | |
'Origin': 'https://quest.virgilsecurity.com', | |
'Accept-Encoding': 'gzip, deflate, br', | |
'Accept-Language': 'en-US,en;q=0.8,ru;q=0.6', | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36', | |
'content-type': 'application/json', | |
'Accept': '*/*', | |
'Referer': 'https://quest.virgilsecurity.com/', | |
'Cookie': '__cfduid=d7cf63d0477426ae73835750e6ad3dbf41510056175; crypto_cookies.sid=s%3A1ppInUszbXAlT7uUOp5Ll8f55tUSAEGq.9kSyDzmxKZ3mYO5pcJOZDZz%2FFP%2F5MLnH3kZQghPNzC8; __cflb=1172794474', | |
'Connection': 'keep-alive', | |
} | |
url_sync = 'https://quest.virgilsecurity.com/api/sync' | |
data = {"click_timestamps":[]} | |
r = requests.post(url_sync, data=data, headers=headers, verify=False) | |
j = r.json() | |
#pprint(j) | |
speed = j['data']['pointsPerSecond'] | |
cash = j['data']['points'] | |
miners = [] | |
for x in j['data']['units']: | |
m = Miner(x['type'], x['cost']['1'], x['itemProduction'], x['totalMined']) | |
# hack to estimate PS4 instead of Quantum because it's cheaper o_O | |
#if m.type == "QuantumComputer": | |
# m.type = "PS4" | |
# m.cost=100_000_000_000 | |
miners.append(m) | |
miners.sort(key=lambda x: -x.delta) | |
#pprint(miners) | |
print(speed, cash) | |
for i in range(len(miners)): | |
x = miners[i] | |
for j in range(len(miners)-i-1): | |
y = miners[i+j+1] | |
should = should_buy(x,y,speed) | |
print("{0:15} vs {1:15} : {2:15} {3:15}".format(x.type, y.type, y.type if should>0 else x.type, should)) | |
wealth = get_wealth(miners) | |
print("wealth: {0:_}".format(wealth)) | |
return miners, speed, cash | |
def main(): | |
repeat = True | |
while repeat: | |
try: | |
miners, speed, cash = stats() | |
top = [x for x in miners if x.type == 'QuantumComputer'][0] | |
current_index = miners.index(top) | |
repeat = False | |
except Exception as e: | |
print(e) | |
time.sleep(30) | |
while(True): | |
try: | |
current = miners[current_index] | |
candidates = [m for m in miners if m.delta<current.delta] | |
all = [(c, should_buy(current, c, speed)) for c in candidates] | |
all.sort(key=lambda x: -x[1]) | |
top = all[0] | |
bought = None | |
if top[1] < 0: | |
# buy current | |
# current++ ? | |
bought = current.buy(speed, cash) | |
if bought: | |
current_index -= 1 | |
print("index--") | |
if current_index == -1: | |
# out of range! | |
current_index = 0 | |
print("reached maximum?") | |
else: | |
# buy top | |
bought = top[0].buy(speed, cash) | |
print("Current {0}, bought success: {1}".format(current.type, bought)) | |
#input("--------------") | |
time.sleep(30) | |
miners, speed, cash = stats() | |
except Exception as e: | |
print(e) | |
time.sleep(30) | |
# should = should_buy(current,y,speed) | |
# print("{0:15} vs {1:15} : {2:15} {3:15}".format(current.type, y.type, y.type if should>0 else current.type, should)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment