-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathquickstart.py
More file actions
40 lines (32 loc) · 1021 Bytes
/
quickstart.py
File metadata and controls
40 lines (32 loc) · 1021 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
import random
from arcengine import GameState
import arc_agi
# Initialize the ARC-AGI-3 client
arc = arc_agi.Arcade()
# Create an environment with terminal rendering
env = arc.make("ls20", render_mode="terminal")
if env is None:
print("Failed to create environment")
exit(1)
# Play the game
for step in range(100):
# Choose a random action
action = random.choice(env.action_space)
action_data = {}
if action.is_complex():
action_data = {
"x": random.randint(0, 63),
"y": random.randint(0, 63),
}
# Perform the action (rendering happens automatically)
obs = env.step(action, data=action_data)
# Check game state
if obs and obs.state == GameState.WIN:
print(f"Game won at step {step}!")
break
elif obs and obs.state == GameState.GAME_OVER:
env.reset()
# Get and display scorecard
scorecard = arc.get_scorecard()
if scorecard:
print(f"Final Score: {scorecard.score}, Actions: {scorecard.total_actions}")