{"id":17739045,"url":"https://github.com/paulhendricks/gym-r","last_synced_at":"2025-05-08T19:37:06.527Z","repository":{"id":43623282,"uuid":"71490465","full_name":"paulhendricks/gym-R","owner":"paulhendricks","description":"An R package providing access to the OpenAI Gym API","archived":false,"fork":false,"pushed_at":"2017-07-01T19:46:17.000Z","size":62,"stargazers_count":21,"open_issues_count":5,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-03T23:35:07.413Z","etag":null,"topics":["openai-gym","openai-universe","r","reinforcement-learning"],"latest_commit_sha":null,"homepage":"","language":"R","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/paulhendricks.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":"2016-10-20T18:06:46.000Z","updated_at":"2022-09-07T19:59:32.000Z","dependencies_parsed_at":"2022-09-11T09:02:04.809Z","dependency_job_id":null,"html_url":"https://github.com/paulhendricks/gym-R","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulhendricks%2Fgym-R","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulhendricks%2Fgym-R/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulhendricks%2Fgym-R/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulhendricks%2Fgym-R/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulhendricks","download_url":"https://codeload.github.com/paulhendricks/gym-R/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222703811,"owners_count":17025840,"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":["openai-gym","openai-universe","r","reinforcement-learning"],"created_at":"2024-10-26T02:07:12.585Z","updated_at":"2024-11-02T11:05:25.022Z","avatar_url":"https://github.com/paulhendricks.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\ngym\n===\n\n[![CRAN\\_Status\\_Badge](http://www.r-pkg.org/badges/version/gym)](http://cran.r-project.org/package=gym) [![Downloads from the RStudio CRAN mirror](http://cranlogs.r-pkg.org/badges/gym)](http://cran.rstudio.com/package=gym) [![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/0.1.0/active.svg)](http://www.repostatus.org/#active)\n\n[OpenAI Gym](https://github.com/openai/gym) is a open-source Python toolkit for developing and comparing reinforcement learning algorithms. This R package is a wrapper for the [OpenAI Gym API](https://github.com/openai/gym-http-api), and enables access to an ever-growing variety of environments.\n\nInstallation\n------------\n\nYou can install the latest development version from CRAN:\n\n``` r\ninstall.packages(\"gym\")\n```\n\nOr from GitHub with:\n\n``` r\nif (packageVersion(\"devtools\") \u003c 1.6) {\n  install.packages(\"devtools\")\n}\ndevtools::install_github(\"paulhendricks/gym-R\", subdir = \"R\")\n```\n\nIf you encounter a clear bug, please file a [minimal reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on [GitHub](https://github.com/paulhendricks/gym/issues).\n\nGetting started\n---------------\n\n### Setting up the server\n\nTo download the code and install the requirements, you can run the following shell commands:\n\n``` bash\ngit clone https://github.com/openai/gym-http-api\ncd gym-http-api\npip install -r requirements.txt\n```\n\nThis code is intended to be run locally by a single user. The server runs in python.\n\nTo start the server from the command line, run this:\n\n``` bash\npython gym_http_server.py\n```\n\nFor more details, please see here: \u003chttps://github.com/openai/gym-http-api\u003e.\n\n### Running an example in R\n\nIn a separate R terminal, you can then try running the example agent and see what happens:\n\n``` r\nlibrary(gym)\n\nremote_base \u003c- \"http://127.0.0.1:5000\"\nclient \u003c- create_GymClient(remote_base)\nprint(client)\n\n# Create environment\nenv_id \u003c- \"CartPole-v0\"\ninstance_id \u003c- env_create(client, env_id)\nprint(instance_id)\n\n# List all environments\nall_envs \u003c- env_list_all(client)\nprint(all_envs)\n\n# Set up agent\naction_space_info \u003c- env_action_space_info(client, instance_id)\nprint(action_space_info)\nagent \u003c- random_discrete_agent(action_space_info[[\"n\"]])\n\n# Run experiment, with monitor\noutdir \u003c- \"/tmp/random-agent-results\"\nenv_monitor_start(client, instance_id, outdir, force = TRUE, resume = FALSE)\n\nepisode_count \u003c- 100\nmax_steps \u003c- 200\nreward \u003c- 0\ndone \u003c- FALSE\n\nfor (i in 1:episode_count) {\n  ob \u003c- env_reset(client, instance_id)\n  for (i in 1:max_steps) {\n    action \u003c- env_action_space_sample(client, instance_id)\n    results \u003c- env_step(client, instance_id, action, render = TRUE)\n    if (results[[\"done\"]]) break\n  }\n}\n\n# Dump result info to disk\nenv_monitor_close(client, instance_id)\n```\n\nCitation\n--------\n\nTo cite package ‘gym’ in publications use:\n\n    Paul Hendricks (2016). gym: Provides Access to the OpenAI Gym API. R package version 0.1.0. https://CRAN.R-project.org/package=gym\n\nA BibTeX entry for LaTeX users is\n\n    @Manual{,\n      title = {gym: Provides Access to the OpenAI Gym API},\n      author = {Paul Hendricks},\n      year = {2016},\n      note = {R package version 0.1.0},\n      url = {https://CRAN.R-project.org/package=gym},\n    }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulhendricks%2Fgym-r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulhendricks%2Fgym-r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulhendricks%2Fgym-r/lists"}