forked from ClarityCoders/Fall-Guys-AI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandomAgent.py
61 lines (49 loc) · 1.27 KB
/
RandomAgent.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
import random
import time
from utils.getkeys import key_check
import pydirectinput
import keyboard
from utils.directkeys import PressKey, ReleaseKey, W, D, A
# Sleep time after actions
sleepy = 0.1
# Wait for me to push B to start.
keyboard.wait('B')
time.sleep(sleepy)
# Hold down W no matter what!
keyboard.press('w')
# Randomly pick action then sleep.
# 0 do nothing release everything ( except W )
# 1 hold left
# 2 hold right
# 3 Press Jump
while True:
action = random.randint(0,3)
if action == 0:
print("Doing nothing....")
keyboard.release("a")
keyboard.release("d")
keyboard.release("space")
time.sleep(sleepy)
elif action == 1:
print("Going left....")
keyboard.press("a")
keyboard.release("d")
keyboard.release("space")
time.sleep(sleepy)
elif action == 2:
print("Going right....")
keyboard.press("d")
keyboard.release("a")
keyboard.release("space")
time.sleep(sleepy)
elif action == 3:
print("JUMP!")
keyboard.press("space")
keyboard.release("a")
keyboard.release("d")
time.sleep(sleepy)
# End simulation by hitting h
keys = key_check()
if keys == "H":
break
keyboard.release('W')