Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,26 @@ BFS_TIMEOUT_S=0.1 docker compose up

Access the web app on [http://localhost:8080](http://localhost:8080).

By default, the graph will be explored by a breadth-first search (BFS) until the timout. Alternatively, by setting `WITH_DFS=true` as below, it will first explore down a single path, depth-first, using a simple heuristic for the best move in each state. Once no more moves can be made, the BFS is done from every node in the path. Using this heuristic makes it possible to find the winning state, which will be labelled if found.
By default, the graph will be explored by a breadth-first search (BFS) until the timeout. Alternatively, by setting `WITH_DFS=true` as below, it will first explore down a single path, depth-first, using a simple heuristic for the best move in each state. Once no more moves can be made, the BFS is done from every node in the path. Using this heuristic makes it possible to find the winning state, which will be labelled if found.

```bash
WITH_DFS=true BFS_TIMEOUT_S=0.1 docker compose up
```

### Search algorithm

Set `ALGORITHM` to choose how the graph is explored (within the same depth/timeout budget):

- `bfs` (default) — breadth-first search; explores every state level by level.
- `bestfirst` — greedy best-first search ordered by a state heuristic (foundation progress, face-down cards, blocked cards, and free columns), biasing exploration toward promising states.
- `astar` — A\* search ordered by depth plus an admissible foundation-distance heuristic, reaching winning states along shorter paths first.

```bash
ALGORITHM=astar BFS_TIMEOUT_S=0.1 docker compose up
```

`WITH_DFS=true` takes precedence over `ALGORITHM`. All three algorithms build the complete state graph for visualisation; they differ only in which states they expand first when the budget is limited.

## Build locally

Depends on:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
BFS_MAX_DEPTH: "${BFS_MAX_DEPTH:-100}"
BFS_TIMEOUT_S: "${BFS_TIMEOUT_S:-0.05}"
WITH_DFS: "${WITH_DFS:-false}"
ALGORITHM: "${ALGORITHM:-bfs}"
restart: "no"
init: true
healthcheck:
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.graph
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ WORKDIR /app
COPY --from=builder /build/rose ./rose
RUN mkdir -p /app/shared && chmod 755 /app
VOLUME ["/app/shared"]
ENTRYPOINT ["sh", "-c", "if [ \"${WITH_DFS:-false}\" = \"true\" ]; then DFS_FLAG=--with-dfs; else DFS_FLAG=; fi; /app/rose ${DFS_FLAG} --max-depth ${BFS_MAX_DEPTH:-5} --timeout ${BFS_TIMEOUT_S:-0.1} /app/shared && tail -F /dev/null"]
ENTRYPOINT ["sh", "-c", "if [ \"${WITH_DFS:-false}\" = \"true\" ]; then DFS_FLAG=--with-dfs; else DFS_FLAG=; fi; /app/rose ${DFS_FLAG} --algorithm ${ALGORITHM:-bfs} --max-depth ${BFS_MAX_DEPTH:-5} --timeout ${BFS_TIMEOUT_S:-0.1} /app/shared && tail -F /dev/null"]
Loading