{"id":31931322,"url":"https://github.com/gdonald/reversi-py","last_synced_at":"2026-07-15T01:06:29.151Z","repository":{"id":313685446,"uuid":"1051831374","full_name":"gdonald/reversi-py","owner":"gdonald","description":"Reversi with reinforcement learning","archived":false,"fork":false,"pushed_at":"2025-09-23T15:51:40.000Z","size":611,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-07T13:53:00.128Z","etag":null,"topics":["ai","machine-learning","othello","reversi"],"latest_commit_sha":null,"homepage":"","language":"Python","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/gdonald.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":"2025-09-06T20:09:58.000Z","updated_at":"2025-09-23T15:50:46.000Z","dependencies_parsed_at":"2025-09-07T21:19:03.829Z","dependency_job_id":"23ce577a-1741-423c-a023-c618354ce3a8","html_url":"https://github.com/gdonald/reversi-py","commit_stats":null,"previous_names":["gdonald/reversi-py"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gdonald/reversi-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdonald%2Freversi-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdonald%2Freversi-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdonald%2Freversi-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdonald%2Freversi-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gdonald","download_url":"https://codeload.github.com/gdonald/reversi-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdonald%2Freversi-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017942,"owners_count":26086213,"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-10-14T02:00:06.444Z","response_time":60,"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":["ai","machine-learning","othello","reversi"],"created_at":"2025-10-14T04:33:38.685Z","updated_at":"2026-07-15T01:06:29.137Z","avatar_url":"https://github.com/gdonald.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# reversi-py\n\nExperiments with Reversi in a deep learning environment.\n\n## Install\n\n```\npython -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n```\n\nPython 3.10+ recommended. Default device is CPU; override with `--device mps|cuda|auto` if you want GPU. MPS is often slower than CPU for this setup.\n\n## Scripts\n\n- Play the classic console game (no RL): `python reversi.py`\n- Play the console game vs the SB3 agent: `python reversi.py --sb3-model checkpoints/sb3/best_model.zip` (add `--device cpu|mps|cuda` to force)\n- Train agent (defaults below): `python train_sb3.py`\n- Evaluate a checkpoint vs bots (get winrate): `python eval_agent_sb3.py --model checkpoints/sb3/best_model.zip --games 50 --opponents heuristic random`\n- Head-to-head in a simple prompt (coords like `d3`/`pass`): `python play_vs_agent.py --model checkpoints/sb3/best_model.zip`\n- Plot eval winrate history from training logs (uses `logs/sb3/eval_history.csv`): `python plot_eval.py --logdir logs/sb3`\n- Baseline bots vs each other: `python eval_bots.py --games 50`\n\n## Training defaults (tweak in `train_sb3.py`)\n\n```\ntotal_timesteps = 10_000_000\nn_envs = 32\nbot_mix_prob = 0.8        # fraction of episodes vs heuristic opponent\neval_freq = 40_000        # timesteps between evals\neval_games = 50\nlearning_rate = 3e-4\nent_coef = 0.03\nclip_range = 0.3\nn_steps = 2048\nbatch_size = 2048\ngamma = 0.99\ngae_lambda = 0.95\nn_epochs = 4\ntarget_kl = 0.02\ncheckpoints = checkpoints/sb3\nlogdir = logs/sb3\n```\n\n Overrides (examples):\n- Auto-resume is on by default (uses `best_model.zip` \u003e `final_model.zip` \u003e newest step checkpoint)\n- Continue from a specific checkpoint: `--load-model checkpoints/sb3/best_model.zip`\n- Change sparring mix: `--bot-mix-prob 0.5`\n- Force single-process vec env (if SubprocVecEnv blocked): `--no-subproc`\n- Adjust device: `--device mps|cuda|cpu|auto` (default is `cpu`)\n\nOutputs:\n- Checkpoints saved every `--save-freq` to `checkpoints/sb3/` (`best_model.zip` from eval; `final_model.zip` at end).\n- Logs and `eval_history.csv` in `logs/sb3/`\n  - Winrate tracking: use `python eval_agent_sb3.py ...` for a one-off, or run `python plot_eval.py --logdir logs/sb3` to graph the eval callback history.\n  - TensorBoard: `tensorboard --logdir logs/sb3` (opens http://localhost:6006) to see PPO losses/entropy/etc.\n\n## Preview\n\n![Reversi](https://raw.githubusercontent.com/gdonald/reversi-py/refs/heads/main/reversi.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdonald%2Freversi-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgdonald%2Freversi-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdonald%2Freversi-py/lists"}