Skip to content

Commit cbd1ab1

Browse files
committed
Add Spelunky
1 parent f50738f commit cbd1ab1

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,13 @@ This script runs on a pokemon emulator, the keys that are used are seen in the s
2323
This script has managed to catch a shiny pidgey and after 9 hours, defeat the first gym leader.
2424

2525
### Behaviour
26-
This script enjoys opening and closing the bag, and running away from nearly fainted opponents.
26+
This script enjoys opening and closing the bag, and running away from nearly fainted opponents.
27+
28+
## Spelunky_AI
29+
Script to play Spelunky.
30+
31+
### Achievements
32+
This scripts has managed to beat the first level multiple times and get to the door of the second.
33+
34+
### Behaviour
35+
This script enjoys throwing bombs and ropes, wiggling, and making actually impressive moves.

Spelunky_AI.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
#Code to play games, text ppl, etc.
3+
4+
import keyboard
5+
import random
6+
import time
7+
8+
def release_all():
9+
keyboard.release('i')
10+
keyboard.release('j')
11+
keyboard.release('k')
12+
keyboard.release('l')
13+
keyboard.release('x')
14+
keyboard.release('z')
15+
keyboard.release('s')
16+
keyboard.release('a')
17+
keyboard.release('space')
18+
19+
exit = False
20+
print('5')
21+
time.sleep(1)
22+
print('4')
23+
time.sleep(1)
24+
print('3')
25+
time.sleep(1)
26+
print('2')
27+
time.sleep(1)
28+
print('1')
29+
time.sleep(1)
30+
while (exit == False):
31+
32+
# First key press
33+
randInt = random.randint(0, 100)
34+
if(randInt < 10):
35+
keyboard.press('i')
36+
elif randInt < 20 :
37+
keyboard.press('j')
38+
elif randInt < 30 :
39+
keyboard.press('k')
40+
elif randInt < 40 :
41+
keyboard.press('l')
42+
elif randInt < 60 :
43+
keyboard.press('x')
44+
elif randInt < 80 :
45+
keyboard.press('z')
46+
elif randInt < 82 :
47+
keyboard.press('s')
48+
elif randInt < 85 :
49+
keyboard.press('a')
50+
else :
51+
keyboard.press('space')
52+
53+
# Second key press
54+
randInt = random.randint(0, 100)
55+
if(randInt < 10):
56+
keyboard.press('i')
57+
elif randInt < 20 :
58+
keyboard.press('j')
59+
elif randInt < 30 :
60+
keyboard.press('k')
61+
elif randInt < 40 :
62+
keyboard.press('l')
63+
elif randInt < 60 :
64+
keyboard.press('x')
65+
elif randInt < 80 :
66+
keyboard.press('z')
67+
elif randInt < 82 :
68+
keyboard.press('s')
69+
elif randInt < 85 :
70+
keyboard.press('a')
71+
else :
72+
keyboard.press('space')
73+
74+
time.sleep(0.1)
75+
76+
release_all()
77+
78+
exit = keyboard.is_pressed('esc')
79+
80+
release_all()

0 commit comments

Comments
 (0)