https://github.com/alishobeiri/hiriq-solver
A* search implemented from scratch and applied to a board game problem
https://github.com/alishobeiri/hiriq-solver
Last synced: 6 months ago
JSON representation
A* search implemented from scratch and applied to a board game problem
- Host: GitHub
- URL: https://github.com/alishobeiri/hiriq-solver
- Owner: alishobeiri
- Created: 2016-10-24T22:53:01.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-08T00:24:06.000Z (almost 7 years ago)
- Last Synced: 2025-02-14T13:50:30.082Z (8 months ago)
- Language: Java
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# The HiRiQ Board Problem
Given any random starting board configuration and two possible moves for each game piece, generate the set of moves required to
take the starting board state to the final solved board configuration. The final board configuration is denoted by a board
where all pieces except the center most piece are black, with the central piece being white.For more information: [Project Descripton](http://crypto.cs.mcgill.ca/~crepeau/COMP250/HW4.pdf)
# Implementation
The implementation found in `HiRiQSolver.java` uses the A* path-finding algorithm. In this algorithm, we first scan the given board
state and generate all possible moves that can be taken. These moves are then passed into a priority queue and sorted in
ascending order (lowest distance at the head of the queue) based on how close
they move the board to the final solved board state. Each board state has a unique integer value which indicates which pegs on the
board are currently white. The final board state has the value 215 = 32768.The distance metric used to to sort the potential moves is dist = abs(d(x) - 32768)
where d(x) denotes the total integer value of the current board state after applying move x.At each iteration, the most optimal move is applied to the current board state, a new set of moves is generated and
sorted using the distance function above. This
is repeated until the solution state is found or the algorithm encounters a dead end. In the case of a dead end, the algorithm tries the
second most optimal move from the previous iteration and continues until all the states have been explored.