Skip to content

Implement hasValuableMoves() in BeleagueredCastleRules #399

@SorraTheOrc

Description

@SorraTheOrc

Summary

Add a pure function hasValuableMoves(state: BeleagueredCastleState): boolean to BeleagueredCastleRules.ts that determines whether any of the currently legal moves are 'valuable' -- i.e. executing the move would make at least one new move available involving a card not already involved in the current legal moves.

Implementation Approach

  1. Get the current set of legal moves via getLegalMoves(state).
  2. Extract the set of card identifiers involved in those moves (the top cards of source/destination columns and foundation targets).
  3. For each legal move:
    a. Apply the move to a snapshot/clone of the state.
    b. Get the new set of legal moves in the resulting state.
    c. Extract the set of card identifiers involved in the new moves.
    d. If any card in the new set was NOT in the original set, this move is valuable.
    e. Undo the move to restore the original state.
  4. Return true if at least one valuable move was found.

Note: Foundation moves are always valuable since they permanently advance progress.

Acceptance Criteria

  • Function exported from BeleagueredCastleRules.ts
  • A move is valuable if after executing it, at least one new move involves a card not involved in any move before
  • Foundation moves are always valuable (they always expose a new card or win)
  • Returns false when the only available moves just shuffle cards without exposing new possibilities
  • Works correctly with empty columns, single-card columns
  • Pure function: does not mutate state

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions