-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
44 lines (32 loc) · 916 Bytes
/
Copy pathtest.py
File metadata and controls
44 lines (32 loc) · 916 Bytes
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
from pyboy import PyBoy
from pyboy.utils import bcd_to_dec
import time
import imageio
ADDR_SCORE = 0xD637
SCORE_BYTE_WIDTH = 3
MAX_SCORE = 999999
ADDR_INVINCIBLE_TIMER = 0xD658
ADDR_INVINCIBLE_TIMER_2 = 0xD659
ADDR_IS_DEAD = 0xD667
pyboy = PyBoy("Pac-Man (Europe).gb", window="null")
while True:
pyboy.tick(1, False)
if pyboy.tilemap_background[2, 3:8] == [128, 144, 160, 176, 192]: # Main menu
break
pyboy.tick(1, False)
pyboy.button("right")
pyboy.tick(1, False)
pyboy.button("start")
pyboy.tick(265, False)
screens = []
while pyboy.tick(8):
time.sleep(1)
score = bcd_to_dec(
int.from_bytes(pyboy.memory[ADDR_SCORE : ADDR_SCORE + SCORE_BYTE_WIDTH], "little"),
byte_width=SCORE_BYTE_WIDTH,
)
screens.append(pyboy.screen.ndarray[7:138, 5:106, 0:3].copy())
imageio.mimsave("logs/render_test.gif", screens, fps=8)
print(score)
pass
pyboy.stop()