{"id":22669086,"url":"https://github.com/stjohnjohnson/scrabbler-bot","last_synced_at":"2025-03-29T10:44:13.838Z","repository":{"id":1969698,"uuid":"2900792","full_name":"stjohnjohnson/scrabbler-bot","owner":"stjohnjohnson","description":"Basic Bot designed to play Scrabbler (written in PHP)","archived":false,"fork":false,"pushed_at":"2011-12-20T18:06:38.000Z","size":132,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T18:49:35.555Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","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/stjohnjohnson.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}},"created_at":"2011-12-02T19:12:53.000Z","updated_at":"2023-08-22T18:00:33.000Z","dependencies_parsed_at":"2022-09-05T16:51:40.794Z","dependency_job_id":null,"html_url":"https://github.com/stjohnjohnson/scrabbler-bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stjohnjohnson%2Fscrabbler-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stjohnjohnson%2Fscrabbler-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stjohnjohnson%2Fscrabbler-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stjohnjohnson%2Fscrabbler-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stjohnjohnson","download_url":"https://codeload.github.com/stjohnjohnson/scrabbler-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246174469,"owners_count":20735410,"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","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":"2024-12-09T15:18:27.397Z","updated_at":"2025-03-29T10:44:13.814Z","avatar_url":"https://github.com/stjohnjohnson.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Scrabbler Bot (PHP)\n===================\n\nThis is a sample PHP bot for the Scrabbler project.  It was designed so that\nit can easily be modified for different bot algorithms.\n\nIt is based on the paper [\"The World’s Fastest Scrabble Program\"](http://gtoal.com/wordgames/jacobson+appel/aj.pdf)\nby Andrew W. Appel and Guy J. Jacobson.\n\nFollows Input/Output Specifications as described at [Scrabbler Wiki](https://github.com/stjohnjohnson/Scrabbler/wiki/Bot-Specifications)\n\n\nUsage\n-----\n\nTo run the bot:\n\n```bash\n$ scrabbler path/to/wordlist.txt [BotAlgorithm]\n```\n\nThe Scrabble Bot has build in support for seven (7) different simple algorithms:\n\n* `HighestScore` (default) - Plays the highest scoring word\n* `LowestScore` - Plays the lowest scoring word (not skipping)\n* `MostWords` - Plays the word that creates the most words\n* `MostLetters` - Plays the word that uses the most letters/tiles\n* `LeastLetters` - Plays the word that uses the least letters/tiles\n* `LongestWord` - Plays the longest word (including existing titles)\n* `ShortestWord` - Plays the shortest word (including existing titles)\n\n\nExtending\n---------\n\nTo build your own PHP bot, simply extend the `Scrabbler\\Game` class, create your\nown `chooseAction` method, and don't forget to instantiate an instance of the class.\n\nHere is a simple bot that will trade 1 letter 50% of the time and play a random\nmove the other 50%.\n\n```php\n\u003c?php\nnamespace Scrabbler;\n/** Scrabbler Game */\nrequire_once 'src/game.php';\n\nclass DummyBot extends Game {\n  public function chooseAction(array $moves) {\n    // 50% chance of trading 1 letter (or if there are no moves)\n    if (empty($moves) || mt_rand(0, 1) === 1) {\n      return Move::fromTrade(reset($this-\u003erack));\n    } else {\n      return reset($moves);\n    }\n  }\n}\n$foo = new DummyBot(array(\n    'log' =\u003e Game::LOG_INFO,\n'lexicon' =\u003e $argv[1]\n));\n$foo-\u003eexecute();\n```\n\nSimulations\n-----------\n\nOnce you made your own bot, it's best to test out it's ability against other\nbots before submitting it to Scrabbler.  Luckily, it's quite easy to do so.\n\nSimply call the `simulate` method with another `Scrabbler\\Game` object passed\nin.  The play-by-play of the game will be output to the screen as type `Game::LOG_INFO`\n\nIn this example, we assume we have the bot from above.  Here we'll test the `DummyBot`\nagainst the built in `HighestScore` Player bot.\n\n```php\n\u003c?php\n/** Scrabbler Player */\nrequire_once 'src/player.php';\n\n$foo = new DummyBot(array(\n    'log' =\u003e Game::LOG_INFO,\n'lexicon' =\u003e $argv[1]\n));\n$foo-\u003esimulate(new Player(array(\n    'lexicon' =\u003e $foo-\u003elexicon,\n     'method' =\u003e 'HighestScore'\n)));\n```\n\n### Sample Output:\n```\n 6.14 INFO: Game Starting\n 6.23 INFO: Me\tM --                \t0   \tMPUNNOO\n 6.33 INFO: Opp\tFURZE H4            \t42  \tZNEUFVR\n 8.03 INFO: Me\teN G4               \t4   \tPUNNOO?\n 8.12 INFO: Opp\tGON(Z)O 7E          \t59  \tNVGOTOG\n 8.29 INFO: Me\tFO(G) E5            \t16  \tPUNOOTF\n... 28 Lines Removed ...\n14.29 INFO: Me\t(TAJ)Es B2          \t93  \tYUEEII?\n14.46 INFO: Opp\tRIELS A5            \t437 \tRSLREII\n14.58 INFO: Me\tY --                \t93  \tYUEIIKP\n14.68 INFO: Opp\t(MAX)I K5           \t450 \tRINI\n14.79 INFO: Me\tE(T) E12            \t99  \tUEIIKP\n14.90 INFO: Opp\t(E)RN I1            \t458 \tRNIY\n15.00 INFO: Me\tI(C)K G12           \t115 \tUIIKP\n15.09 INFO: Opp\t(K)I 14G            \t464 \tIY\n15.19 INFO: Me\tU --                \t115 \tUIP\n15.28 INFO: Opp\t--                  \t464 \tY\n15.38 INFO: Me\tP(ICK) G11          \t139 \tIP\n15.47 INFO: Opp\t--                  \t464 \tY\n15.56 INFO: Me\tI --                \t139 \tIU\n15.66 INFO: Opp\t--                  \t464 \tY\n15.78 INFO: Me\t--                  \t139 \tU\n15.87 INFO: Opp\t--                  \t464 \tY\n15.97 INFO: Me\t--                  \t139 \tU\n15.97 INFO: Game Ending: No More Moves\n15.97 INFO: __\tScore\tRack\n15.97 INFO: Me\t143\tU\n15.97 INFO: Opp\t460\tY\n15.97 INFO:\n    _ A __ B __ C __ D __ E __ F __ G __ H __ I __ J __ K __ L __ M __ N __ O _\n1 : [   ][   ][   ][ G ][   ][ O ][ G ][ L ][ E ][ D ][   ][   ][   ][   ][   ]\n2 : [   ][ T ][ O ][ R ][ A ][ H ][   ][   ][ R ][ A ][ P ][ E ][ R ][ S ][   ]\n3 : [   ][ A ][ N ][ A ][ L ][   ][   ][   ][ N ][   ][   ][ Q ][   ][ T ][   ]\n4 : [   ][ J ][   ][ V ][   ][   ][ e ][ F ][   ][   ][   ][ U ][   ][ O ][   ]\n5 : [ R ][ E ][   ][ E ][ F ][   ][ N ][ U ][   ][   ][ M ][ A ][   ][ U ][   ]\n6 : [ I ][ s ][   ][ D ][ O ][ M ][   ][ R ][ I ][ V ][ A ][ L ][   ][ T ][   ]\n7 : [ E ][   ][   ][   ][ G ][ O ][ N ][ Z ][ O ][   ][ X ][ I ][   ][ E ][   ]\n8 : [ L ][   ][   ][   ][   ][ W ][ E ][ E ][ N ][   ][ I ][ T ][   ][ S ][   ]\n9 : [ S ][   ][ C ][   ][ A ][ E ][   ][   ][   ][   ][   ][ Y ][   ][ T ][   ]\n10: [   ][ B ][ O ][ W ][ E ][ D ][   ][   ][   ][   ][   ][   ][   ][   ][   ]\n11: [   ][ O ][ B ][ A ][   ][   ][ P ][   ][   ][   ][   ][   ][   ][   ][   ]\n12: [   ][ R ][ I ][ D ][ E ][   ][ I ][   ][   ][   ][   ][   ][   ][   ][   ]\n13: [   ][ N ][ A ][ S ][ T ][ I ][ C ][   ][   ][   ][   ][   ][   ][   ][   ]\n14: [ H ][ E ][   ][   ][   ][   ][ K ][ I ][   ][   ][   ][   ][   ][   ][   ]\n15: [   ][   ][   ][   ][   ][   ][   ][   ][   ][   ][   ][   ][   ][   ][   ]\n```\n\n\nTesting\n-------\n\nIf you want to modify the core code, you're more than welcome to.  There is a\ndecent series of PHPUnit tests you can run to check that everything is working:\n\n```bash\n$ phpunit --coverage-html=.coverage/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstjohnjohnson%2Fscrabbler-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstjohnjohnson%2Fscrabbler-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstjohnjohnson%2Fscrabbler-bot/lists"}