{"id":18925943,"url":"https://github.com/ts1/uctoth","last_synced_at":"2026-04-17T12:34:03.693Z","repository":{"id":39556925,"uuid":"163407355","full_name":"ts1/uctoth","owner":"ts1","description":"Self-learning Othello (Reversi) game engine written in CoffeeScript 2","archived":false,"fork":false,"pushed_at":"2023-02-28T09:04:45.000Z","size":29546,"stargazers_count":2,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-28T11:34:36.334Z","etag":null,"topics":["c","coffeescript","coffeescript2","game","game-engine","vue","webassembly"],"latest_commit_sha":null,"homepage":"https://ts1.github.io/uctoth/","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ts1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-12-28T12:20:20.000Z","updated_at":"2025-01-27T05:03:45.000Z","dependencies_parsed_at":"2024-12-31T18:36:54.763Z","dependency_job_id":null,"html_url":"https://github.com/ts1/uctoth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ts1/uctoth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts1%2Fuctoth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts1%2Fuctoth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts1%2Fuctoth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts1%2Fuctoth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ts1","download_url":"https://codeload.github.com/ts1/uctoth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts1%2Fuctoth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31929826,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T10:35:34.458Z","status":"ssl_error","status_checked_at":"2026-04-17T10:35:09.472Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["c","coffeescript","coffeescript2","game","game-engine","vue","webassembly"],"created_at":"2024-11-08T11:13:54.345Z","updated_at":"2026-04-17T12:34:03.671Z","avatar_url":"https://github.com/ts1.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Uctoth\n\nOthello (Reversi) game engine written in CoffeeScript 2.\nDemo page is [here](https://ts1.github.io/uctoth/).\n\n## Experimental\n\nThis code is mostly experimental, not intended for reuse.\nReusing may need some work.\nRead the source if you are interested.\n\n## Features\n\n### CoffeeScript 2\n\nWorks both on Node.js (with ES6+ features) and on [browsers](https://ts1.github.io/uctoth/) (with help from babel and webpack).\n\nNow the most of CPU-intensive parts, endgame solving, game tree search and\nlearning, are also written in C.\nThey work as add-on of Node.js and also as WebAssembly on browsers\n(except learning).\nCoffeeScript implementations still exist and used when add-on/wasm is not\navailable.\n\n### Self learning\n\nStarting from random plays, strengthens itself by loops of self playing and\nmachine learning.\nUses no existing records of games.\n\nIncluded `weights.json` file is a result of learning ~100,000 self-played games.\n\n### Game tree search\n\nEmploys modified *UCT search* with static evaluation.\nSearches 15-25 plies deep maximum on modern JavaScript engines.\nC version searches 30+ plies deep.\nBeats my implementation of minimax with NegaScout by 70-80% winning rate.\n\n### Static evaluation\n\nClassic pattern-based evaluation method as described in publications by Michael Buro.\nHe is the god of computer Othello for me.\n\n### Machine learning\n\nSimple linear regression of ~57,000 sparse features per game position.\nOptionally supports logistic regression, which predicts probability to win instead\nof final score.\nNow using mini-batch with AdaGrad for faster convergence.\nAlso written from scratch in CoffeeScript/C.\n\n## Usage\n\nFirst off run `yarn` to install dependencies and build Node add-on.\n\n```\nyarn\n```\n\nMost scripts expect `weights.json` file existing in this directory.\nCopy from `ref` directory at first (then build your own).\n\n```\ncp ref/weights.json .\n```\n\nTo run scripts written in CoffeeScript 2, you should either install\n`coffeescript` globally, or use `npx coffee` to run.\n\n### Bootstrapping\n\nThis section describes how to train your own `weights.json` from scratch.\n\nFirst off, generate 1,000 randomly played games.\n\n```\nnpx coffee selfplay-rnd -R -n 1000 -w 12 -f 10 -b 1000000 --min_col=0\n```\n\nThey are random but the last 10 moves are perfectly played.\nGenerated games are stored in `book.db` (SQLite3 database).\n\nNext, learn the generated games and make your first `weights.json`.\n\n```\nnpx coffee learn\n```\n\n\u003e If you can't use Node add-on for some reason, use `reg` instead.\n\nNow you can remove `book.db` of random games.\n\n```\nrm book.db*\n```\n\nCopy `auto` script from `samples` directory.\n\n```\ncp samples/auto .\n```\n\nYou may edit `auto` as you like.\nNow you are ready to run automatic self-learning loop.\n\n```\n./auto\n```\n\nIt runs regression and 30-game matches against `ref/weights.json`\nevery 1,000 games generated.\nMatch results are appended to `match.log`.\n\n### Running self-play and learning in parallel\n\nRunning self-play and regression simultaneously can utilize multi-core CPUs,\nthus can speed up the entire self learning process.\n\nSample scripts are in `samples` directory, copy them.\n\n```\ncp samples/selfplay-loop samples/reg-loop samples/match-loop .\n```\n\nEdit the scripts as you need.\nThen run `reg-loop` in one terminal, `selfplay-loop` in another, and `match-loop` in the third.\nThis setup uses 3 CPU threads, but if it isn't enough for your machine,\nyou may run `selfplay-loop` as many as you want.\n\nThe trick is simple.\nAll selfplay scripts watch `weights.json` to change.\nWhen `reg-loop` finished creating a new `weights.json`, selfplay scripts exit\nand invoked again by shell script.\n\n`watch` script is useful for watching to see if everything is working well.\n\n### Automatic tuning of L2 regularization parameter\n\n`learn` (and its CoffeeScript counter part `reg`/`minibatch`) uses\n*L2 regularization* to avoid over-fitting.\nIt's important to give optimal parameters of this to build strong weights.\n\n`l2tune` script is written for this purpose.\nIt uses K-fold cross-validation and optionally actually plays 30-game match to\nfind strongest parameters.\nThe result is written to `l2.json` and `learn` reads values from this file if\navailable.\nThese are very time consuming processes.\nIt's recommended to run `l2tune` without `--match` periodically while learning,\nand use `l2tune --match` for final finish of your `weights.json`.\n\n\u003e If Node add-on is not available, use `l2seach` and `l2opt` instead.\n\n## Acknowledgement\n\nSound created by Nobuyuki Honda.\n\n## License\n\nMIT\n\nCopyright © 2018-2019 by Takeshi Sone\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fts1%2Fuctoth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fts1%2Fuctoth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fts1%2Fuctoth/lists"}