WordCraft is an engaging word puzzle game where players rearrange words to form target sentences. The game features a grid-based board with obstacles (walls) and a time limit, challenging players to strategically move words and recreate sentences in the correct order, either horizontally or vertically.
- Grid-based gameplay with words and obstacles
- Multiple levels with increasing difficulty
- Responsive design for both desktop and mobile devices
- Touch and keyboard controls
- Animations and visual feedback
- Local storage for best scores
- Demo mode for new players
- Start the game or play the tutorial demo.
- Use arrow keys, WASD, or touch gestures to move the selection rectangle.
- Press Enter/Space or tap to select/deselect words.
- Move selected words using arrow keys, WASD, or swipe gestures.
- Arrange words to form the target sentence horizontally or vertically.
- Complete the level and try to beat your best score!
The solver is designed to solve the word puzzle game by rearranging words on a grid to form a target sentence. It supports multiple algorithms to find the optimal solution:
-
GameState Structure: Represents the state of the game at any point, including the level, target sentence, word positions, walls, grid size, and words.
-
Heuristics: Several heuristic functions are defined to estimate the cost of reaching the goal state from the current state. These include:
- Standard heuristic
- Goal count heuristic
- NRP heuristic
- Linear conflict heuristic
- Manhattan sliding heuristic
- Interaction cost heuristic
-
A Algorithm*: An implementation of the A* algorithm that uses the combined heuristic to find the shortest path to the goal state.
-
Hybrid Algorithm: A combination of BFS and A* algorithms to balance between breadth-first search and heuristic-based search.
-
Level Data Loading: Loads level data from a CSV file, including word positions and wall positions.
-
Solving Levels: The
solve_level
function solves a given level using the specified algorithm (BFS, A*, or hybrid). -
Main Function: The main function loads the level data, updates the grid size, and uses
std::async
to runsolve_level
in parallel for each level.
The solver aims to find the minimum number of moves required to arrange the words on the grid to match the target sentence.
- Built with HTML, CSS (Tailwind CSS), and JavaScript
- Responsive design for cross-device compatibility
- Efficient DOM manipulation and CSS transitions for smooth animations
- Seeded random number generation for consistent level layouts
- Local storage for saving player progress and best scores
The following is a CSV dump of all levels, including word and wall positions for those crazy enough to attempt to create a solver :)
Level,Sentence,Type,Row,Col
1,The quick brown fox,Word 1,7,0
1,The quick brown fox,Word 2,2,4
1,The quick brown fox,Word 3,1,0
1,The quick brown fox,Word 4,2,7
1,The quick brown fox,Wall 1,7,2
1,The quick brown fox,Wall 2,3,6
1,The quick brown fox,Wall 3,4,2
1,The quick brown fox,Wall 4,0,6
1,The quick brown fox,Wall 5,7,6
1,The quick brown fox,Wall 6,3,7
1,The quick brown fox,Wall 7,7,7
1,The quick brown fox,Wall 8,5,1
1,The quick brown fox,Wall 9,3,2
1,The quick brown fox,Wall 10,6,6
1,The quick brown fox,Wall 11,5,6
1,The quick brown fox,Wall 12,6,5
1,The quick brown fox,Wall 13,3,0
1,The quick brown fox,Wall 14,2,1
1,The quick brown fox,Wall 15,6,0
1,The quick brown fox,Wall 16,2,0
1,The quick brown fox,Wall 17,5,7
1,The quick brown fox,Wall 18,0,5
1,The quick brown fox,Wall 19,4,5
2,Jumps over the lazy dog,Word 1,1,1
2,Jumps over the lazy dog,Word 2,5,7
2,Jumps over the lazy dog,Word 3,2,7
2,Jumps over the lazy dog,Word 4,3,5
2,Jumps over the lazy dog,Word 5,4,3
2,Jumps over the lazy dog,Wall 1,2,0
2,Jumps over the lazy dog,Wall 2,4,2
2,Jumps over the lazy dog,Wall 3,6,0
2,Jumps over the lazy dog,Wall 4,7,4
2,Jumps over the lazy dog,Wall 5,5,2
2,Jumps over the lazy dog,Wall 6,4,1
2,Jumps over the lazy dog,Wall 7,5,1
2,Jumps over the lazy dog,Wall 8,3,4
2,Jumps over the lazy dog,Wall 9,7,5
2,Jumps over the lazy dog,Wall 10,7,6
2,Jumps over the lazy dog,Wall 11,2,6
2,Jumps over the lazy dog,Wall 12,7,7
2,Jumps over the lazy dog,Wall 13,7,0
2,Jumps over the lazy dog,Wall 14,1,2
2,Jumps over the lazy dog,Wall 15,6,5
2,Jumps over the lazy dog,Wall 16,3,0
2,Jumps over the lazy dog,Wall 17,2,4
3,Better late than never friend,Word 1,3,5
3,Better late than never friend,Word 2,4,7
3,Better late than never friend,Word 3,5,0
3,Better late than never friend,Word 4,6,7
3,Better late than never friend,Word 5,2,7
3,Better late than never friend,Wall 1,6,5
3,Better late than never friend,Wall 2,7,4
3,Better late than never friend,Wall 3,7,6
3,Better late than never friend,Wall 4,4,3
3,Better late than never friend,Wall 5,1,7
3,Better late than never friend,Wall 6,7,2
3,Better late than never friend,Wall 7,5,5
3,Better late than never friend,Wall 8,5,6
3,Better late than never friend,Wall 9,1,6
3,Better late than never friend,Wall 10,6,1
3,Better late than never friend,Wall 11,0,3
3,Better late than never friend,Wall 12,1,0
3,Better late than never friend,Wall 13,1,1
3,Better late than never friend,Wall 14,3,2
3,Better late than never friend,Wall 15,1,4
3,Better late than never friend,Wall 16,4,5
4,Make hay while the sun shines,Word 1,7,7
4,Make hay while the sun shines,Word 2,7,5
4,Make hay while the sun shines,Word 3,1,6
4,Make hay while the sun shines,Word 4,7,3
4,Make hay while the sun shines,Word 5,1,4
4,Make hay while the sun shines,Word 6,3,2
4,Make hay while the sun shines,Wall 1,2,7
4,Make hay while the sun shines,Wall 2,0,1
4,Make hay while the sun shines,Wall 3,2,6
4,Make hay while the sun shines,Wall 4,7,2
4,Make hay while the sun shines,Wall 5,5,2
4,Make hay while the sun shines,Wall 6,6,3
4,Make hay while the sun shines,Wall 7,1,1
4,Make hay while the sun shines,Wall 8,1,3
4,Make hay while the sun shines,Wall 9,2,5
4,Make hay while the sun shines,Wall 10,6,0
4,Make hay while the sun shines,Wall 11,4,3
4,Make hay while the sun shines,Wall 12,5,7
4,Make hay while the sun shines,Wall 13,6,6
4,Make hay while the sun shines,Wall 14,0,3
4,Make hay while the sun shines,Wall 15,3,0
5,A stitch in time saves nine,Word 1,1,6
5,A stitch in time saves nine,Word 2,1,0
5,A stitch in time saves nine,Word 3,1,2
5,A stitch in time saves nine,Word 4,3,5
5,A stitch in time saves nine,Word 5,4,2
5,A stitch in time saves nine,Word 6,3,0
5,A stitch in time saves nine,Wall 1,6,2
5,A stitch in time saves nine,Wall 2,0,5
5,A stitch in time saves nine,Wall 3,0,3
5,A stitch in time saves nine,Wall 4,0,7
5,A stitch in time saves nine,Wall 5,5,1
5,A stitch in time saves nine,Wall 6,5,7
5,A stitch in time saves nine,Wall 7,7,1
5,A stitch in time saves nine,Wall 8,6,1
5,A stitch in time saves nine,Wall 9,5,2
5,A stitch in time saves nine,Wall 10,7,3
5,A stitch in time saves nine,Wall 11,3,6
5,A stitch in time saves nine,Wall 12,2,7
5,A stitch in time saves nine,Wall 13,2,6
5,A stitch in time saves nine,Wall 14,0,1
5,A stitch in time saves nine,Wall 15,1,3
5,A stitch in time saves nine,Wall 16,6,4
5,A stitch in time saves nine,Wall 17,5,0
5,A stitch in time saves nine,Wall 18,2,5
5,A stitch in time saves nine,Wall 19,6,6
6,Actions speak louder than words,Word 1,2,3
6,Actions speak louder than words,Word 2,3,5
6,Actions speak louder than words,Word 3,2,5
6,Actions speak louder than words,Word 4,3,7
6,Actions speak louder than words,Word 5,4,0
6,Actions speak louder than words,Wall 1,6,7
6,Actions speak louder than words,Wall 2,6,2
6,Actions speak louder than words,Wall 3,4,6
6,Actions speak louder than words,Wall 4,1,6
6,Actions speak louder than words,Wall 5,1,4
6,Actions speak louder than words,Wall 6,4,7
6,Actions speak louder than words,Wall 7,7,7
6,Actions speak louder than words,Wall 8,5,1
6,Actions speak louder than words,Wall 9,2,2
6,Actions speak louder than words,Wall 10,7,0
6,Actions speak louder than words,Wall 11,5,4
6,Actions speak louder than words,Wall 12,4,1
6,Actions speak louder than words,Wall 13,1,1
6,Actions speak louder than words,Wall 14,0,1
6,Actions speak louder than words,Wall 15,6,0
6,Actions speak louder than words,Wall 16,5,6
6,Actions speak louder than words,Wall 17,0,6
6,Actions speak louder than words,Wall 18,7,2
6,Actions speak louder than words,Wall 19,4,3
7,All that glitters is not gold,Word 1,2,3
7,All that glitters is not gold,Word 2,7,5
7,All that glitters is not gold,Word 3,7,4
7,All that glitters is not gold,Word 4,7,6
7,All that glitters is not gold,Word 5,3,2
7,All that glitters is not gold,Word 6,4,7
7,All that glitters is not gold,Wall 1,2,4
7,All that glitters is not gold,Wall 2,4,2
7,All that glitters is not gold,Wall 3,0,6
7,All that glitters is not gold,Wall 4,1,0
7,All that glitters is not gold,Wall 5,0,4
7,All that glitters is not gold,Wall 6,5,3
7,All that glitters is not gold,Wall 7,6,6
7,All that glitters is not gold,Wall 8,4,0
7,All that glitters is not gold,Wall 9,0,5
7,All that glitters is not gold,Wall 10,2,7
7,All that glitters is not gold,Wall 11,0,0
7,All that glitters is not gold,Wall 12,0,7
7,All that glitters is not gold,Wall 13,7,3
7,All that glitters is not gold,Wall 14,5,4
7,All that glitters is not gold,Wall 15,1,4
7,All that glitters is not gold,Wall 16,6,5
7,All that glitters is not gold,Wall 17,6,1
7,All that glitters is not gold,Wall 18,7,0
7,All that glitters is not gold,Wall 19,5,0
8,A rolling stone gathers no moss,Word 1,4,2
8,A rolling stone gathers no moss,Word 2,1,6
8,A rolling stone gathers no moss,Word 3,3,3
8,A rolling stone gathers no moss,Word 4,1,3
8,A rolling stone gathers no moss,Word 5,2,0
8,A rolling stone gathers no moss,Word 6,1,4
8,A rolling stone gathers no moss,Wall 1,5,0
8,A rolling stone gathers no moss,Wall 2,7,3
8,A rolling stone gathers no moss,Wall 3,2,6
8,A rolling stone gathers no moss,Wall 4,3,1
8,A rolling stone gathers no moss,Wall 5,3,2
8,A rolling stone gathers no moss,Wall 6,7,1
8,A rolling stone gathers no moss,Wall 7,3,0
8,A rolling stone gathers no moss,Wall 8,4,6
8,A rolling stone gathers no moss,Wall 9,0,2
8,A rolling stone gathers no moss,Wall 10,6,6
8,A rolling stone gathers no moss,Wall 11,0,7
8,A rolling stone gathers no moss,Wall 12,7,5
8,A rolling stone gathers no moss,Wall 13,0,5
8,A rolling stone gathers no moss,Wall 14,5,7
8,A rolling stone gathers no moss,Wall 15,6,7
8,A rolling stone gathers no moss,Wall 16,5,1
8,A rolling stone gathers no moss,Wall 17,2,7
8,A rolling stone gathers no moss,Wall 18,6,3
8,A rolling stone gathers no moss,Wall 19,7,4
9,Fortune always favors the brave soul,Word 1,6,0
9,Fortune always favors the brave soul,Word 2,6,3
9,Fortune always favors the brave soul,Word 3,1,6
9,Fortune always favors the brave soul,Word 4,7,0
9,Fortune always favors the brave soul,Word 5,1,3
9,Fortune always favors the brave soul,Word 6,5,7
9,Fortune always favors the brave soul,Wall 1,1,0
9,Fortune always favors the brave soul,Wall 2,6,5
9,Fortune always favors the brave soul,Wall 3,0,5
9,Fortune always favors the brave soul,Wall 4,0,1
9,Fortune always favors the brave soul,Wall 5,2,5
9,Fortune always favors the brave soul,Wall 6,3,7
9,Fortune always favors the brave soul,Wall 7,4,3
9,Fortune always favors the brave soul,Wall 8,0,2
9,Fortune always favors the brave soul,Wall 9,3,1
9,Fortune always favors the brave soul,Wall 10,3,6
9,Fortune always favors the brave soul,Wall 11,0,7
9,Fortune always favors the brave soul,Wall 12,7,2
9,Fortune always favors the brave soul,Wall 13,5,5
9,Fortune always favors the brave soul,Wall 14,2,1
9,Fortune always favors the brave soul,Wall 15,7,6
9,Fortune always favors the brave soul,Wall 16,2,7
9,Fortune always favors the brave soul,Wall 17,5,1
9,Fortune always favors the brave soul,Wall 18,4,0
9,Fortune always favors the brave soul,Wall 19,0,0
10,Practice makes perfect or at least less bad,Word 1,5,4
10,Practice makes perfect or at least less bad,Word 2,6,1
10,Practice makes perfect or at least less bad,Word 3,3,4
10,Practice makes perfect or at least less bad,Word 4,5,5
10,Practice makes perfect or at least less bad,Word 5,5,2
10,Practice makes perfect or at least less bad,Word 6,7,2
10,Practice makes perfect or at least less bad,Word 7,3,0
10,Practice makes perfect or at least less bad,Word 8,7,0
10,Practice makes perfect or at least less bad,Wall 1,7,5
10,Practice makes perfect or at least less bad,Wall 2,3,2
10,Practice makes perfect or at least less bad,Wall 3,7,3
10,Practice makes perfect or at least less bad,Wall 4,4,6
10,Practice makes perfect or at least less bad,Wall 5,4,0
10,Practice makes perfect or at least less bad,Wall 6,7,4
10,Practice makes perfect or at least less bad,Wall 7,3,1
10,Practice makes perfect or at least less bad,Wall 8,4,7
10,Practice makes perfect or at least less bad,Wall 9,6,3
10,Practice makes perfect or at least less bad,Wall 10,2,6
10,Practice makes perfect or at least less bad,Wall 11,7,7
10,Practice makes perfect or at least less bad,Wall 12,0,3
10,Practice makes perfect or at least less bad,Wall 13,3,3
10,Practice makes perfect or at least less bad,Wall 14,7,6
10,Practice makes perfect or at least less bad,Wall 15,5,1
10,Practice makes perfect or at least less bad,Wall 16,6,5
10,Practice makes perfect or at least less bad,Wall 17,0,6
10,Practice makes perfect or at least less bad,Wall 18,2,3
10,Practice makes perfect or at least less bad,Wall 19,2,7
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
For any questions or feedback, please open an issue in the GitHub repository.