Skip to content

[Feature Request] Add Santorini Base Version with Fixed Worker Placement #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

cstorm125
Copy link

@cstorm125 cstorm125 commented Jun 4, 2025

Description

The Santorini environment implements a strategic board game where players compete to reach the highest level of construction. The implementation features:

  1. A fixed-worker variant where initial positions are optimally preset
  2. A comprehensive move validation system ensuring game rule compliance
  3. A robust state management system tracking:
    • Board state (heights and worker positions)
    • Player turns
    • Game progression
    • Win conditions
      The environment supports both 2 and 3 player modes, with different optimal starting positions for each configuration. The game mechanics are implemented with careful attention to edge cases and rule enforcement, ensuring a fair and engaging gameplay experience.

Motivation and Context

This is a good environment for a 1v1, competitive game that also extends to 3 players.

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New game (adds a new game to TextArena)
  • Game enhancement (improves an existing game)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Refactoring (code improvement without changing functionality)

Game-specific changes

If your PR adds or modifies a game, please specify:

  • Game affected:
  • Changes to game mechanics:
  • Changes to game UI/rendering:
  • Changes to game judging/rules:

Implementation Details

  • Board State Management

    • Implemented 5x5 grid using 2D array
    • Each cell tracks height (0-4) and worker occupancy
    • Initial worker positions defined for both 2 and 3 player games
  • Move Validation System

    • Move pattern validation using regex
    • Worker ownership verification
    • Movement rules enforcement (adjacency, height differences, occupancy)
    • Building rules validation (adjacency, dome placement)
    • Valid moves generation with comprehensive checking
  • Game Flow Control

    • Turn management system
    • State transitions and updates
    • Win condition detection
    • Invalid move handling with early return

Testing

The implementation has been thoroughly tested with a comprehensive test suite covering:

  1. Initialization Tests

    • Environment parameters verification
    • Board setup validation for 2 and 3 players
    • Initial worker position verification
  2. Move Validation Tests

    • Adjacent vs non-adjacent moves
    • Height difference constraints
    • Worker ownership verification
    • Occupied space handling
    • Edge case handling at board boundaries
  3. Build Validation Tests

    • Adjacent vs non-adjacent builds
    • Building on different heights
    • Dome placement rules
    • Worker position conflicts
    • Edge case handling at board boundaries
  4. Game Flow Tests

    • Complete game sequence execution
    • Turn progression verification
    • Win condition detection
    • Random play testing with:
      • Height tracking
      • Turn limit verification
      • Winner/loser reward distribution
      • Game completion validation
  5. Edge Cases and Error Handling

    • Invalid move format handling
    • Out-of-bounds moves
    • Illegal worker selection
    • Invalid build attempts
    • Player count validation

All tests are automated using pytest framework, ensuring consistent behavior and reliable game mechanics.

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the contribution guidelines. (required)
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes. (required for bug fixes or new features)
  • All new and existing tests passed.
  • For game changes, I have verified that the game still runs correctly end-to-end.

Charin Polpanumas added 7 commits June 4, 2025 13:25
- Remove start/end anchors from move pattern regex to allow text before/after the move format
- Update test_valid_moves to use search() instead of match() for pattern validation
- Add test cases for moves with additional text before/after the core move format
- Maintain strict validation of the core [worker_num source dest build] format
Refactor Santorini board renderer to use a clearer [height worker] format for each cell, making it easier for LLMs to parse the game state. Add legend explaining cell format and worker symbols.
- Change Player 1 color from Red to White
- Change Player 2 color from Green to Grey
- Update colors in both Initial Setup and Board Legend sections
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant