Skip to content

Commit

Permalink
chore(deps): update leafwing-input-manager to v0.15 (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenMian committed Aug 13, 2024
1 parent edc071d commit a00bfb9
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 274 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
/.fleet
/.idea
config.toml
keymap.toml
db.sqlite3
41 changes: 37 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ image = "0.25"
toml = "0.8"

bevy = "0.14"
leafwing-input-manager = "0.14"
leafwing-input-manager = "0.15"
bevy_kira_audio = "0.20"
benimator = "4.1"
winit = "0.30" # The version needs to be consistent with the one used in bevy
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ A sokoban with solver.

<p align="center"><img src="./docs/assets/auto_box_push.gif" width=50%></p>

- **Level management**: Levels and solutions are stored in the database. [More details](docs/level_management.md).
- **Customizing**: Options can be customized via configuration file. [More details](docs/customizing.md).
- **Map viewing**: Supports moving and zooming the map. When switching levels, the zoom will be automatically adjusted to fit the window size.
- **Player character animation**: Player character has smooth movement and animations in different directions.
- **Level management**: Levels and solutions are stored in a database. [More details](docs/level_management.md).
- **Customization**: Options can be customized via a configuration file. [More details](docs/customization.md).
- **Map viewing**: Supports moving and zooming the map. When switching levels, the zoom will automatically adjust to fit the window size.
- **Player character animation**: The player character has smooth movement and animations in different directions.
- **Front-end and back-end separation**: Backend code (such as solvers) is decoupled from the frontend (such as Bevy).

## Acknowledgements

- anian <<[email protected]>>: For providing comprehensive answers to numerous inquiries regarding Sokoban and offering insightful recommendations.
- [@PaperPlaneLSY](https://github.com/PaperPlaneLSY): For testing, improving the skin, and additional support.
- [@PaperPlaneLSY](https://github.com/PaperPlaneLSY): For testing, improving the skin, and providing additional support.

## Keymap

Expand Down Expand Up @@ -76,4 +76,4 @@ A sokoban with solver.
| `X`/`Square` | Toggle instant move[^1] |
| `Y`/`Triangle` | Toggle automatic solution |

[^1]: Turn off character and boxes movement animations.
[^1]: Disables character and box movement animations.
21 changes: 10 additions & 11 deletions docs/auto_move.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,36 @@

<p align="center"><img src="assets/auto_box_push.gif" width=70%></p>

This feature can significantly assist users when playing larger levels.
At the same time, it also maintains the traditional control method.
This feature can significantly assist users when playing larger levels while maintaining the traditional control method.

Clicking on a box will display all the points that the box can reach (without moving other boxes).

Take Microban #155 as an example:

<p align="center"><img src="assets/auto_box_push_1.png" width=70%></p>

Clicking on one of the points will automatically push the selected box to that position.
Clicking on one of these points will automatically push the selected box to that position.

In this case, the user can click on the target, and the character will automatically push the selected box to the target to complete the level.
In this case, the user can click on the target, and the character will automatically push the selected box to that target to complete the level.

Some areas where the boxes are reachable do not display points. This is because pushing the box to those positions will lead to a deadlock and the player will be unable to continue completing the level.
Some areas where the boxes are reachable do not display points. This is because pushing the box to those positions would lead to a deadlock, making it impossible for the player to continue and complete the level.

<p align="center"><img src="assets/auto_box_push_2.png" width=70%></p>

## Auto player move

Click to select the player and display the player's reachable area. Click on a position in the area and the player will automatically move to that position.
Click to select the player and display the player's reachable area. Clicking on a position within this area will make the player automatically move to that position.

<p align="center"><img src="assets/auto_player_move.png" width=70%></p>

User can also directly click on the player's reachable area without selecting the player, and the player will automatically move to that position.
Users can also directly click on the player's reachable area without selecting the player, and the player will automatically move to that position.

## Controversial

This feature is a bit controversial, with some users saying it's akin to cheating.
This feature is somewhat controversial, with some users arguing that it is akin to cheating.

For simple levels, this does significantly reduce the level difficulty. An extreme example is a level with only a single box and target, which means the player can complete it without having to do any reasoning.
For simple levels, it does significantly reduce the difficulty. For example, a level with only a single box and target can be completed without any additional reasoning.

But for challenging levels, the difficulty mainly lies in the intricate pushing relationship between multiple boxes, rather than the pushing of a single box. This feature allows players to focus on more complex reasoning instead of repeating the simple work of pushing a single box.
However, for challenging levels, the difficulty mainly lies in the intricate relationships between multiple boxes, rather than the task of pushing a single box. This feature allows players to focus on more complex reasoning instead of repeatedly performing the simple task of pushing a single box.

In addition, this feature is **optional**. Users can still use the traditional control methods.
Additionally, this feature is **optional**. Users can still use the traditional control methods.
14 changes: 5 additions & 9 deletions docs/customizing.md → docs/customization.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Customizing
# Customization

## Configuration

The user can configure settings by editing `config.toml` in the same directory. If the file does not exist, a default configuration file will be automatically generated when the program is run.

```toml
# Player movement animation speed, seconds per step.
# Player movement animation speed, in seconds per step.
player_move_speed = 0.1
# Make the floor look like a chessboard with alternating light square and dark square.
# Makes the floor look like a chessboard with alternating light and dark squares.
even_square_shades = 0.1
# Audio volume.
volume = 0.5
# Disable player movement animation.
# Disables player movement animation.
instant_move = false
# Enable auto switch to next unsolved level when the current level is solved.
# Enables automatic switching to the next unsolved level when the current level is solved.
auto_switch_to_next_unsolved_level = true

[solver]
Expand All @@ -22,7 +22,3 @@ lower_bound_method = "MinimumMove"
```

For `solver` related configuration options, please refer to [Solver](./solver.md).

## Keymap

The user can configure keymap by editing `keymap.toml` in the same directory. If the file does not exist, a default keymap configuration file will be automatically generated when the program is run.
16 changes: 8 additions & 8 deletions docs/level_management.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
| Box | `$` |
| Box on target | `*` |
| Target | `.` |
| Floor | ` `/`-`/`_` |
| Floor | ``/`-`/`_` |

## Import

Supports importing levels in XSB format (support run-length encoding) from files or system clipboard:
Supports importing levels in XSB format (including run-length encoding) from files or the system clipboard:

- Import from files: The user can drag single or multiple level files in XSB format into the window.
- Import from clipboard: If some levels in XSB format is already in the clipboard, it can be imported using the input action.
- Import from files: Users can drag single or multiple level files in XSB format into the window.
- Import from clipboard: If levels in XSB format are already in the clipboard, they can be imported using the input action.

The levels will first be standardized to prevent repeated import of the same or similar levels. The standardized levels are only used for deduplication, and the final imported levels are not standardized.
Levels are first standardized to prevent repeated imports of the same or similar levels. The standardized levels are used only for deduplication, and the final imported levels are not standardized.

Levels that meet the following conditions are considered similar:
Levels are considered similar if they meet the following conditions:

- The starting positions of the player characters are different, but in the same closed area.
- The starting positions of the player characters are different but within the same closed area.
- After rotation and inversion.
- The difference is only in the decorations that are inaccessible to the character. These decorations can make the level more beautiful, but do not affect the solution of the level.
- The difference is only in decorations that are inaccessible to the character. While these decorations may enhance the appearance of the level, they do not affect the level's solution.

## Export

Expand Down
2 changes: 1 addition & 1 deletion docs/levels.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Levels

The levels included in this sokoban game program are borrowed from various other sokoban games and are the intellectual property of their respective original designers. These levels are utilized within this program solely for the purpose of testing the solver.
The levels included in this Sokoban game program are borrowed from various other Sokoban games and are the intellectual property of their respective original designers. These levels are used in this program solely for the purpose of testing the solver.
We do not claim ownership of these levels, and all rights remain with the original creators.

| File | Author |
Expand Down
20 changes: 10 additions & 10 deletions docs/solver.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ The solver can automatically solve levels of moderate complexity.

## Strategy

- `Fast`: Speed priority.
- `Mixed`: Balanced speed and steps.
- `OptimalMovePush`: Find move optimal solutions with best pushes.
- `OptimalPushMove`: Find push optimal solutions with best moves.
- `Fast`: Prioritizes speed.
- `Mixed`: Balances speed and steps.
- `OptimalMovePush`: Finds optimal move solutions with the fewest pushes.
- `OptimalPushMove`: Finds optimal push solutions with the fewest moves.

## Lower bound calculation method

- `MinimumPush`: Minimum push count to nearest target.
- `MinimumMove`: Minimum move count to nearest target. (This method is slow, especially on maps with many boxes or large areas)
- `ManhattanDistance`: Manhattan distance to nearest target. (This method is fast, suitable for maps with many boxes or large areas)
- `MinimumPush`: Counts the minimum number of pushes to the nearest target.
- `MinimumMove`: Counts the minimum number of moves to the nearest target. (This method is slow, especially on maps with many boxes or large areas)
- `ManhattanDistance`: Uses Manhattan distance to the nearest target. (This method is fast and suitable for maps with many boxes or large areas)

## Optimization

Expand All @@ -38,9 +38,9 @@ Time limit: 10 seconds.

## Visualization

Supports visualizing the automatic solution process. This feature can be used to intuitively view the working status of the solver.
Supports visualizing the automatic solution process. This feature allows you to intuitively view the working status of the solver.

- Display the best state found by the solver.
- Display the lower bounds as a heat map.
- Displays the best state found by the solver.
- Displays lower bounds as a heat map.

<p align="center"><img src="assets/solver_visualization.png" width=70%></p>
Loading

0 comments on commit a00bfb9

Please sign in to comment.