{"id":28999961,"url":"https://github.com/ripred/minimax","last_synced_at":"2025-09-03T23:43:01.290Z","repository":{"id":281244313,"uuid":"944666815","full_name":"ripred/Minimax","owner":"ripred","description":"Project independent, Minimax implementation with alpha-beta pruning. Fully templated classes allow any embedded process or game to include \"look ahead analysis\". Several great working examples included!","archived":false,"fork":false,"pushed_at":"2025-05-17T04:58:09.000Z","size":59,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-27T18:48:32.599Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ripred.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2025-03-07T18:50:31.000Z","updated_at":"2025-05-17T04:57:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"5ba54489-806d-4a2c-b6bc-4a0524b00c72","html_url":"https://github.com/ripred/Minimax","commit_stats":null,"previous_names":["ripred/minimax"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ripred/Minimax","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FMinimax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FMinimax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FMinimax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FMinimax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ripred","download_url":"https://codeload.github.com/ripred/Minimax/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripred%2FMinimax/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273529344,"owners_count":25121823,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"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":[],"created_at":"2025-06-25T08:41:09.572Z","updated_at":"2025-09-03T23:43:01.268Z","avatar_url":"https://github.com/ripred.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Minimax – Embedded-Friendly Alpha-Beta Library for Arduino \u0026 C++\n\n![Arduino IDE ≥ 1.8](https://img.shields.io/badge/Arduino-1.8%2B-00979D?logo=arduino\u0026logoColor=white)\n![C++17](https://img.shields.io/badge/C%2B%2B-17-blue)\n![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)\n![CI](https://img.shields.io/github/actions/workflow/status/ripred/Minimax/ci.yml?label=build)\n\nA **single-header, STL-free** implementation of classic **Minimax search with α–β pruning**, crafted for 2 KB microcontrollers yet flexible enough for desktop use.\n\n* **Tiny footprint** – ≈ 5 KB flash  \n* **Zero dynamic allocation** – no `new`, no STL containers  \n* **Template-based** – plug in *your* board \u0026 move types  \n* **Five-function API** – override, compile, play  \n* **Playable examples** – Checkers, Connect Four, Gomoku \u0026 Othello\n\n---\n\n## 1 • Why Another Minimax?\n\nMost hobby libraries assume megabytes of RAM and `std::vector`.  \nThis header was born while squeezing an AI into an **ATmega328** (2 KB RAM).\n\n---\n\n## 2 • Getting Started\n\n### 2.1 Install\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eArduino IDE / Arduino-CLI\u003c/b\u003e\u003c/summary\u003e\n\n    \n    # Clone into your libraries folder\n    cd ~/Documents/Arduino/libraries\n    git clone https://github.com/ripred/Minimax.git\n    \n\nRestart the IDE to auto-discover the library.  \n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003ePlatformIO\u003c/b\u003e\u003c/summary\u003e\n\n    \n    lib_deps =\n        ripred/Minimax @ ^1.0.0   ; once published\n    \n\n\u003c/details\u003e\n\n### 2.2 Hello (Tic-Tac-Toe) World\n\n    \n    #include \"Minimax.h\"\n    \n    struct Board   { /* … */ };\n    struct Move    { uint8_t r, c; };\n    \n    class TicTacToeLogic : public Minimax\u003cBoard, Move\u003e::GameLogic {\n    public:\n        int  evaluate(const Board\u0026 s) override { /* +10 / −10 / 0 */ }\n        int  generateMoves(const Board\u0026 s, Move mv[], int max) override { /* … */ }\n        void applyMove(Board\u0026 s, const Move\u0026 m) override { /* … */ }\n        bool isTerminal(const Board\u0026 s) override { /* win / draw */ }\n        bool isMaximizingPlayer(const Board\u0026 s) override { return s.turn == 0; }\n    };\n    \n    TicTacToeLogic logic;\n    Minimax\u003cBoard, Move, 9, 9\u003e ai(logic);\n    \n    void loop() {\n        Board state = /* current board */;\n        Move best   = ai.findBestMove(state);\n        Serial.printf(\"AI chose %d,%d (score %d, nodes %d)\\n\",\n                      best.r, best.c, ai.getBestScore(), ai.getNodesSearched());\n    }\n    \n\nCompile with `-std=gnu++17` (earlier standards also work if your toolchain lacks C++17).\n\n---\n\n## 3 • Library API\n\n| Method | Purpose |\n|--------|---------|\n| `Move findBestMove(const GameState\u0026 s)` | Run α–β search up to `MaxDepth`, returning the best move |\n| `int getBestScore() const` | Score from the last search |\n| `int getNodesSearched() const` | Positions evaluated (profiling) |\n\n### Game Logic Interface\n\nImplement these in a subclass of `Minimax\u003cGameState, Move\u003e::GameLogic`:\n\n1. `evaluate()` – heuristic for the *current* player  \n2. `generateMoves()` – fill an array of legal moves, return count  \n3. `applyMove()` – mutate `GameState` with a move  \n4. `isTerminal()` – true on win/loss/draw  \n5. `isMaximizingPlayer()` – whose turn?  \n\n---\n\n## 4 • Examples\n\n| Sketch | MCU RAM | Notes |\n|--------|---------|-------|\n| Checkers | ~1.7 KB | 8×8 American with kinging \u0026 jumps |\n| Connect-Four | ~1.4 KB | 7×6 board, depth-4 search fits on AVR |\n| Gomoku | ~1.6 KB | 15×15 “Five-in-a-Row” |\n| Othello | ~1.8 KB | 8×8 reversible-disc game |\n\nOpen **File → Examples → Minimax → *(game)*** after installing, or compile on desktop to profile deeper depths.\n\n---\n\n## 5 • Tuning for Your Board\n\n| Knob | Effect | Trade-off |\n|------|--------|-----------|\n| `MaxMoves` | Size of the scratch array | Static RAM cost |\n| `MaxDepth` | Search depth | Flash \u0026 time exponential |\n| Heuristic | Score range | Consider `int16_t` on 8-bit MCUs |\n\nDisable `Serial` prints in examples to save ~2 KB flash.\n\n---\n\n## 6 • Roadmap\n\n* Iterative deepening + time cut-off  \n* Optional transposition table when RAM ≥ 32 KB  \n* Board-symmetry pruning helpers  \n\n---\n\n## 7 • Contributing\n\n1. Fork → create feature branch  \n2. Follow [coding style](CONTRIBUTING.md) (4-space indents, `snake_case`, right-side `const`)  \n3. Submit PR – CI (AVR \u0026 x86) must pass\n\nBug reports and new example ports are **very** welcome!\n\n---\n\n## 8 • License\n\nReleased under the MIT License – see [LICENSE](LICENSE).\n\n\u003csup\u003e© 2025 by \u003cstrong\u003eTrent M. Wyatt\u003c/strong\u003e\u003c/sup\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripred%2Fminimax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fripred%2Fminimax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripred%2Fminimax/lists"}