jwalsh / jwalsh/2048-cli-debug

Approach #8: Using Expect for TTY interaction

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Description
Found a working approach using Expect to interact with the game's TTY directly\!

## Background
After struggling with Python TTY libraries and shell scripts timing out, discovered that Expect is perfect for this use case.

## Current Status
- Created `claude_with_expect.exp` - simple script that can see board and make moves
- Created `claude_plays_with_expect.exp` - full player with spam phase and strategies
- Best score achieved: 224 (from the log output)

## Why This Works
- Expect is designed for interactive TTY programs
- Can send keystrokes and wait for output patterns
- No Python abstraction layer needed
- Direct interaction with the game

## Next Steps
- Improve strategic decision making based on board state
- Parse board state within expect to make smarter moves
- Beat the 1708 high score\!

## Related Issues
- #5 (TTY-based manual inspection)
- This is a deviation from the Python approach but shows promise

## Example
```tcl
spawn 2048-cli-0.9.1/2048
expect "Score:"
send "s" # Send down move
expect "Score:"
send "q" # Quit
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.