-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpelunky_AI.py
71 lines (62 loc) · 1.67 KB
/
Spelunky_AI.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
68
69
70
71
import keyboard
import random
import time
import sys
used_keys = [
'i', 'j', 'k', 'l', 'x', 'z', 's', 'a', 'space'
]
def release_all():
for key in used_keys:
keyboard.release(key)
def main():
print('Press Space to begin')
keyboard.wait("space")
while (True):
if keyboard.is_pressed('Esc'):
print("Exiting...")
release_all()
sys.exit(0)
# First key press
randInt = random.randint(0, 100)
if(randInt < 10):
keyboard.press('i')
elif randInt < 20 :
keyboard.press('j')
elif randInt < 30 :
keyboard.press('k')
elif randInt < 40 :
keyboard.press('l')
elif randInt < 60 :
keyboard.press('x')
elif randInt < 80 :
keyboard.press('z')
elif randInt < 82 :
keyboard.press('s')
elif randInt < 85 :
keyboard.press('a')
else :
keyboard.press('space')
# Second key press
randInt = random.randint(0, 100)
if(randInt < 10):
keyboard.press('i')
elif randInt < 20 :
keyboard.press('j')
elif randInt < 30 :
keyboard.press('k')
elif randInt < 40 :
keyboard.press('l')
elif randInt < 60 :
keyboard.press('x')
elif randInt < 80 :
keyboard.press('z')
elif randInt < 82 :
keyboard.press('s')
elif randInt < 85 :
keyboard.press('a')
else :
keyboard.press('space')
time.sleep(0.1)
release_all()
if __name__ == '__main__':
main()