{"id":50593145,"url":"https://github.com/andreasabel/tree-rotation","last_synced_at":"2026-06-05T12:01:19.885Z","repository":{"id":362347011,"uuid":"1250611463","full_name":"andreasabel/tree-rotation","owner":"andreasabel","description":"Investigating amortized complexity for tree operations","archived":false,"fork":false,"pushed_at":"2026-06-03T20:52:52.000Z","size":111,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-03T21:10:13.611Z","etag":null,"topics":["amortization","binary-tree","game"],"latest_commit_sha":null,"homepage":"https://andreasabel.github.io/tree-rotation/","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreasabel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-26T20:00:56.000Z","updated_at":"2026-06-03T20:52:56.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/andreasabel/tree-rotation","commit_stats":null,"previous_names":["andreasabel/tree-rotation"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/andreasabel/tree-rotation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasabel%2Ftree-rotation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasabel%2Ftree-rotation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasabel%2Ftree-rotation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasabel%2Ftree-rotation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreasabel","download_url":"https://codeload.github.com/andreasabel/tree-rotation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasabel%2Ftree-rotation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33939227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-05T02:00:06.157Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amortization","binary-tree","game"],"created_at":"2026-06-05T12:01:19.128Z","updated_at":"2026-06-05T12:01:19.880Z","avatar_url":"https://github.com/andreasabel.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"tree-rotation\n=============\n\nSome simple tools to test hypotheses about amortized tree operations.\n\nInitiated by the puzzle at: https://github.com/koengit/puzzle2026\n\nThis repository contains two main components:\n\n1. A [browser playground](play/index.html) for interactively stepping through move sequences and visualizing the resulting tree.\n2. A Haskell program, `tree-rotation`, for exact and approximate high-score (rotations/constructors) search and plotting.\n\nThe project is licensed under the **BSD 3-clause license**; see [LICENSE](LICENSE).\n\n## Web playground\n\nThe interactive page lives at [play/index.html](play/index.html).\n\nIt is a self-contained visualization of the tree-rotation game. The page shows:\n\n- the current counts of concatenation (`C`), tail (`T`), and rotation (`R`) moves and the ratio `R/C`,\n- an SVG rendering of the current tree, omitting leaf nodes,\n- a input field for the move sequence that drives the whole display.\n\n### How to play\n\nOpen `play/index.html` in a browser, then type a move string such as `ccrtt` into the input field.\n\n- `c` appends a leaf on the right, consuming one available concatenation move,\n- `r` performs a tree rotation when the current tree has the right shape,\n- `t` takes the tail when the left subtree of the current tree is a leaf (displayed as absent).\n\nThe displayed tree and score is determined by the moves up to the current cursor position.\nThus, you can step backward and forward through a longer sequence and inspect intermediate states without deleting text.\nIf the move sequence is illegal, the tree pane shows a large red `X`.\n\n## Command-line solver\n\nThe executable **`tree-rotation`** solves the game by exhaustive exploration of the game tree.\n\nBy default it solves the game for the number `N` of concatenation moves, starting at `N = 1`, and keeps running for `N, N+1, N+2, ...` until interrupted. For each solved `N`, it prints the winner, i.e., the move sequence with the most rotations, and appends a CSV row with\n\n```text\nn,score,ratio,iterations,moves\n```\n\nwhere `score` is the number of rotations, `ratio` is `score / n`, `iterations` is the search-specific work counter, and `moves` is the winning move trail.\n\n### Search modes\n\n- **Exact search** (default): hash-map based graph search. (Very memory hungry.)\n- **`--dfs`**: plain depth-first search. (Much slower, but uses little memory.)\n- **`--random[=NNN]`**: best of `NNN`many random playouts, defaulting to `100000`.\n- **`--mcts[=NNN]`**: Monte Carlo Tree Search with random rollouts, defaulting to `500` simulations per real move.\n- **`--full`**: An extended game where a list of trees is maintained and concatenation can be applied to selected trees.\n\n### Command-line options\n\n```text\ntree-rotation [--verbose] [-o|--output FILE] [--start N] [--init MOVES] [--plot] [--full]\n              [--dfs | --random | --random NNN | --mcts | --mcts NNN]\n```\n\n- `--verbose` prints improving leaders during the search; quiet mode is the default.\n- `--output FILE` selects the CSV file to append to, or the CSV file to read when plotting.\n- `--start N` chooses the first `N`; the defaults are `1` for the standard game and `3` with `--full`.\n- `--init MOVES` starts the single-tree search from the position reached by applying the compact move string to the usual initial board; invalid or illegal prefixes are rejected.\n- `--plot` reads the CSV file and prints an SVG plot of `N` versus high-score.\n- `--full` analyses the multi-tree game.\n- `--dfs`, `--random`, and `--mcts` choose alternative search strategies for the standard game.\n\n### Build and run\n\nThis project is a Cabal package named `tree-rotation` and builds with the executable of the same name.\n\n```bash\ncabal build\ncabal run tree-rotation -- --help\n```\n\nTo locate the built executable directly:\n\n```bash\ncabal list-bin tree-rotation\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreasabel%2Ftree-rotation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreasabel%2Ftree-rotation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreasabel%2Ftree-rotation/lists"}