Skip to content

This is a really simple way to solve English Peg Solitaire problems.

License

Notifications You must be signed in to change notification settings

FLwolfy/Peg-Solitaire-Solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Peg-Solitaire-Solver

Welcome to Peg Solitair Solver. This is a really simple way to solve English Peg Solitaire problems.

Overview

This project explores a simple solution to the English Peg-Solitaire puzzle. The primary method involves using a recursive backtracking approach to handle the game board. Memorization is employed to store previously explored states, reducing computational overhead. To expedite the search for possible solutions, the recursive approach prioritizes moving the current peg along the longest possible path before considering other pegs. This strategy aims to get rid of unnecessary performance costs.

Usage

  1. Download Source Code: Clone or download the source code from the repository.

  2. Create Boards: Create your own boards or use the example board in the Board.py file. Here is the template:

    boardTemplate = """\
      XXX  
      XXX  
    XXXXXXX
    XXXXXXX
    XXXXXXX
      XXX
      XXX  
    """
  3. Run Solver: Execute the following code in the Main.py file:

    Get steps (fromRow, fromCol, toRow, toCol) as a list

    steps = PegSolitaire.solve(board)

    Check runtime

    PegSolitaire.solve_test(board)

    Visualize step-by-step process

    PegSolitaire.show_steps(board)

Notes

This method is a personal learning project summary, and its efficiency is not optimal. There is substantial room for optimization, and discussions and contributions are welcome.

About

This is a really simple way to solve English Peg Solitaire problems.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages