Skip to content

Implement spiral pattern for mass room creation#11

Draft
Copilot wants to merge 6 commits intomasterfrom
copilot/change-mass-room-creation-pattern
Draft

Implement spiral pattern for mass room creation#11
Copilot wants to merge 6 commits intomasterfrom
copilot/change-mass-room-creation-pattern

Conversation

Copy link

Copilot AI commented Jan 20, 2026

Mass room creation currently uses sequential placement (left-to-right, top-to-bottom). This changes it to use a spiral pattern starting from center, matching AI/computer assistance behavior.

Changes

Data Structure

  • Added spiral state to RoomSpace: forward_direction, turns_made, steps_to_take_before_turning, steps_remaining_before_turn
  • Direction encoding: 0=North, 1=East, 2=South, 3=West with deltas {(0,-1), (1,0), (0,1), (-1,0)}

Algorithm

  • initialize_spiral_state(): Positions at center with steps_remaining=0 to trigger immediate setup
  • advance_spiral(): Decrements steps, rotates direction on turn, increments step count every 2 turns (odd turns), then moves
  • Pattern: Center → 1E → 1S → 2W → 2N → 3E → 3S → 4W → 4N → ...

Modified Functions

  • keeper_build_roomspace(): Initialize spiral from center instead of top-left
  • keeper_sell_roomspace(): Initialize spiral from center instead of drag start
  • keeper_update_roomspace(): Replace sequential traversal (4 directional switch cases) with single spiral loop
// Before: Sequential based on drag direction
case top_left_to_bottom_right:
    roomspace->buildx++;
    if (roomspace->buildx > roomspace->right) {
        roomspace->buildx = roomspace->left;
        roomspace->buildy++;
    }
    
// After: Unified spiral from center
advance_spiral(roomspace);  // Handles all directions via spiral state

The spiral algorithm matches the AI implementation in player_comptask.c exactly, using the same turn logic and step progression.

Original prompt

This section details on the original issue you should resolve

<issue_title>Change mass room creation pattern from sequential to spiral</issue_title>
<issue_description>Feature Request:
The current drag-to-create room tiles feature places tiles sequentially, which differs from how the computer AI/assistance mode creates rooms.

Current Behavior:
When dragging to mass create room tiles, they are placed in a sequential pattern (likely left-to-right, top-to-bottom or similar).

Requested Change:
Change the mass room creation logic to use a spiral pattern, similar to how enemy keepers and the computer assistance mode builds rooms. This would create rooms starting from the center and spiraling outward.

Benefits:

  • Consistency with AI behavior
  • More aesthetically pleasing room layouts
  • Potentially better room functionality as rooms typically work better when built from the center outward
  • More intuitive and matches player expectations based on how computer players build</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits January 20, 2026 21:43
- Add spiral state variables to RoomSpace structure
- Add spiral direction lookup table (N, E, S, W)
- Modify keeper_build_roomspace() to initialize spiral from center
- Modify keeper_sell_roomspace() to initialize spiral from center
- Replace sequential room placement logic with spiral pattern in keeper_update_roomspace()
- Spiral starts from center and spirals outward clockwise, matching AI behavior

Co-authored-by: Cerwym <1760289+Cerwym@users.noreply.github.com>
- Add advance_spiral() helper function to eliminate code duplication
- Clean up keeper_update_roomspace() logic
- Improve code readability and maintainability

Co-authored-by: Cerwym <1760289+Cerwym@users.noreply.github.com>
- Add SPIRAL_NUM_DIRECTIONS and SPIRAL_DIRECTION_MASK constants
- Improve comments explaining spiral pattern progression
- Document the safety limit multiplier for spiral search
- Replace magic numbers with named constants for better readability

Co-authored-by: Cerwym <1760289+Cerwym@users.noreply.github.com>
- Fix spiral initialization to start with steps=0
- Fix turn counting to increment on odd turns (1st, 3rd, 5th...)
- Add initialize_spiral_state() helper to eliminate duplication
- Improve comments to explain spiral progression
- Pattern: Center first, then 1E, 1S, 2W, 2N, 3E, 3S, 4W, 4N...

Co-authored-by: Cerwym <1760289+Cerwym@users.noreply.github.com>
- Update comments to accurately reflect pattern: center, then 1E, 1S, 2W, 2N, 3E, 3S...
- Clarify that center is built on first call before any spiral movement
- Improve documentation of the spiral algorithm flow

Co-authored-by: Cerwym <1760289+Cerwym@users.noreply.github.com>
Copilot AI changed the title [WIP] Update mass room creation pattern to spiral Implement spiral pattern for mass room creation Jan 20, 2026
Copilot AI requested a review from Cerwym January 20, 2026 21:53
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.

Change mass room creation pattern from sequential to spiral

2 participants