This is a JavaScript-based solver for KAMI puzzles, utilizing graph theory and linked list representation to efficiently find solutions.
KAMI is a puzzle game where the objective is to fill the entire board with a single color in as few moves as possible. This program uses graph theory to model the puzzle and a linked list representation to efficiently solve it. It uses p5.js to render the graph
- Solves KAMI puzzles using graph theory
- Utilizes linked list representation for efficient computation
- Uses easy to use keys to create, connect and color nodes
- Supports custom puzzle inputs
-
Clone the repository:
git clone https://github.com/Njancodes/KAMI-Solver.git
-
Navigate to the project directory:
cd KAMI-Solver
-
Open the index.html file
-
Create Nodes (n mode):
- Click on the canvas to create nodes.
- Ensure you are in "n mode" by pressing
n
.
-
Create Edges (e mode):
- Press
e
to switch to "e mode". - Click on two nodes to create an edge between them.
- Press
-
Add Colors:
- Enter the number of colors needed.
- Assign colors to each node by switching to "c mode" by pressing
c
.
-
Change Colors:
- While in "c mode", press the respective number key to select a color.
- For example, press
2
to select Color #2.
-
Get the Solution:
- After drawing the graph, press
p
to get the sequence of moves to solve the puzzle.
- After drawing the graph, press
-
Output:
- The output will be displayed as the sequence of moves required to solve the puzzle.
Each KAMI puzzle is represented as a graph. In this graph, each node represents a cell in the puzzle, and edges represent connections between cells of the same color. The color of each node specifies the type of the cell.
The graph is then transformed into a linked list using conventional methods in JavaScript. This linked list representation allows efficient manipulation and traversal of the puzzle state.
-
Graph Conversion:
- Convert the graph representation of the puzzle into a linked list.
-
Find the Most Connected Node:
- Identify the node with the highest number of edges or connections in the graph.
-
Select the Optimal Node:
- Within the linked list, select the node that has the most edges connected to the head of the linked list.
-
Change Color:
- Change the color of the head node to match the color of the selected optimal node.
Contributions are welcome! If you have any improvements or bug fixes, please create a pull request or open an issue on GitHub.