forked from jonitram/pokebreederbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
steps2breedingduration.py
executable file
·68 lines (64 loc) · 2.21 KB
/
steps2breedingduration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
import sys
# error Handling
try:
steps = sys.argv[1]
except IndexError:
print("Please input a step count")
sys.exit(0)
else:
try:
steps = float(steps)
except ValueError:
print("Please use an integer for the step count")
sys.exit(0)
steps = float(sys.argv[1])
steptimeratio = float(123 / 10240)
eggtime = int(steps * steptimeratio)
totaleggs = 500 # total number of eggs to be tested
# test escalating biking duration times until the optimal value is found
# start at eggtime / 5 due to max 5 eggs in party at once
for bikingtime in range(int(eggtime / 5), eggtime):
# reset party before trying new biking time
party = []
for i in range(totaleggs):
party.append(0)
fail = False
hatchcount = 0
# ensure all eggs hatch
while hatchcount < totaleggs:
hatch = False
# add times to each egg in party
for eggnum in range(len(party)):
if party[eggnum] > 0 and party[eggnum] <= eggtime:
# if an egg has hatched this iteration then add reduced time
if hatch:
party[eggnum] += (bikingtime - 20)
else:
party[eggnum] += bikingtime
# if an egg hatched check animation time
if party[eggnum] >= eggtime:
if party[eggnum] - eggtime <= 20:
fail = True
break
else:
hatch = True
hatchcount += 1
# add new egg to party then begin next iteration
elif party[eggnum] == 0:
if hatch:
party[eggnum] = (bikingtime - 20)
else:
party[eggnum] = bikingtime
break
if fail:
break
if fail:
continue
else:
timedurationratio = int(3500 / 83)
# add 1 second for a small buffer window
result = timedurationratio * (bikingtime + 1)
print("Use this for the breeding duration: " + str(result))
exit(0)
print("No functional breeding duration for a step count this low. Try doubling the step count and try again.")