{"id":29275529,"url":"https://github.com/vdutor/tf-rex","last_synced_at":"2025-08-18T13:09:30.313Z","repository":{"id":26445593,"uuid":"83895796","full_name":"vdutor/TF-rex","owner":"vdutor","description":"Play Google Chrome's T-rex game with TensorFlow","archived":false,"fork":false,"pushed_at":"2022-11-22T02:05:30.000Z","size":50813,"stargazers_count":342,"open_issues_count":8,"forks_count":52,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-07-05T06:11:46.763Z","etag":null,"topics":["deep-reinforcement-learning","q-learning","t-rex","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/vdutor.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}},"created_at":"2017-03-04T13:36:25.000Z","updated_at":"2025-03-14T02:55:31.000Z","dependencies_parsed_at":"2022-08-27T12:02:22.487Z","dependency_job_id":null,"html_url":"https://github.com/vdutor/TF-rex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vdutor/TF-rex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdutor%2FTF-rex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdutor%2FTF-rex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdutor%2FTF-rex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdutor%2FTF-rex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vdutor","download_url":"https://codeload.github.com/vdutor/TF-rex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vdutor%2FTF-rex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270997216,"owners_count":24682003,"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-08-18T02:00:08.743Z","response_time":89,"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":["deep-reinforcement-learning","q-learning","t-rex","tensorflow"],"created_at":"2025-07-05T06:11:10.722Z","updated_at":"2025-08-18T13:09:30.288Z","avatar_url":"https://github.com/vdutor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TF-rex\nIn this project we play Google's T-rex game using Reinforcement Learning.\nThe RL algorithm is based on the Deep Q-Learning algorithm [1] and is implemented from scratch in TensorFlow.\n\n===========================================================================\n\nCHECK OUT THE ACCOMPAGNYING [BLOGPOST](https://vdutor.github.io/blog/2018/05/07/TF-rex.html) - it contains a lot more useful information.\n\n===========================================================================\n\n## Dependencies\n - __Python 3.5 or higher__\n - Pillow 4.3.0\n - scipy 0.19.1\n - tensorflow 1.7.0 or higher\n - optional: tensorflow tensorboard\n\n\n## Installation\n\nTested on MacOs, Debian, Ubuntu, and Ubuntu-based distros.\n\nStart by cloning the repository\n```sh\n$ git clone https://github.com/vdutor/TF-rex\n```\n\nWe recommend creating a virtualenv before installing the required packages. See [virtualenv](https://virtualenv.pypa.io/en/stable/) or [virtualenv-wrapper](https://virtualenvwrapper.readthedocs.io/en/latest/) on how to do so.\n\nThe dependencies can be easly installed using pip.\n```sh\n$ optional: open the virtualenv\n$ pip install -r requirements.txt\n```\n\n## Getting started\n\n### Webserver for running the javascript T-rex game\n\nA simple webserver is required to run the T-rex javascript game.\nThe easiest way to achieve this is by using python's Simple HTTP Server module.\nOpen a new terminal and navigate to `TF-Rex/game`, then run the following command\n```sh\n$ cd /path/to/project/TF-Rex/game\n$ python2 -m SimpleHTTPServer 8000\n```\nThe game is now accessable on your localhost `127.0.0.1:8000`.\nThis approach was tested for Chrome and Mozilla Firefox.\n\n### Tf-Rex\n\nFirst, all the commandline arguments can be retrieved with\n```sh\n$ cd /path/to/project/TF-Rex/tf-rex\n$ python main.py --help\n```\nQuickly check if the installation was successful by playing with a pretrained Q-learner.\n```sh\n$ python main.py --notraining --logdir ../trained-model\n```\nThis command will restore the pretrained model, stored in `../trained-model` and play the T-rex game.\n\nIMPORTANT: The browser needs to connect with the python side. Therefore, refresh the browser after firing `python main.py --notraining --logdir ../trained-model`.\n\n![TF-REX](https://i.makeagif.com/media/5-07-2018/L2GeyT.gif)\n\nTraining a new model can be done as follows\n```sh\n$ python main.py --logdir logs\n```\nAgain, the browser needs to be refreshed to start the process. The directory passed as `logdir` argument will be used to store intermediate tensorflow checkpoints and tensorboard information.\n\nWhile training, a different terminal can be opened to launch the tensorboard\n```sh\n$ tensorboard --logdir logs\n```\nThe tensorboards will be visible on `http://127.0.0.1:6006/`.\n\n## References\n[1] [Playing Atari with Deep Reinforcement Learning](https://www.cs.toronto.edu/~vmnih/docs/dqn.pdf)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvdutor%2Ftf-rex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvdutor%2Ftf-rex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvdutor%2Ftf-rex/lists"}