{"id":17153171,"url":"https://github.com/axect/forger","last_synced_at":"2025-10-12T14:30:47.354Z","repository":{"id":206809185,"uuid":"714315574","full_name":"Axect/Forger","owner":"Axect","description":"Forger: Reinforcement Learning Library in Rust","archived":false,"fork":false,"pushed_at":"2023-11-17T07:01:36.000Z","size":1476,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T17:53:17.200Z","etag":null,"topics":["forger","machine-learning","reinforcement-learning","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Axect.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-11-04T14:52:10.000Z","updated_at":"2024-09-18T10:30:56.000Z","dependencies_parsed_at":"2023-11-14T02:39:06.648Z","dependency_job_id":"b28335b9-b692-4c4e-a5d0-52a3552b3095","html_url":"https://github.com/Axect/Forger","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"baeee6a11baa9d2d776f824532fad26c3db3701e"},"previous_names":["axect/rlai2","axect/forger"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Axect%2FForger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Axect%2FForger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Axect%2FForger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Axect%2FForger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Axect","download_url":"https://codeload.github.com/Axect/Forger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236229978,"owners_count":19115713,"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":["forger","machine-learning","reinforcement-learning","rust"],"created_at":"2024-10-14T21:45:29.509Z","updated_at":"2025-10-12T14:30:41.947Z","avatar_url":"https://github.com/Axect.png","language":"Rust","readme":"# Forger - Reinforcement Learning Library in Rust\n\n\u003cp align=\"center\"\u003e\n   \u003cimg src=\"https://github.com/Axect/Forger/blob/master/forger_logo.png\" width=40%\u003e\n\u003c/p\u003e\n\n## Introduction\n\nForger is a Reinforcement Learning (RL) library in Rust, offering a robust and efficient framework for implementing RL algorithms. It features a modular design with components for agents, environments, policies, and utilities, facilitating easy experimentation and development of RL models.\n\n## Features\n\n- **Modular Components**: Includes agents, environments, and policies as separate modules.\n- **Efficient and Safe**: Built in Rust, ensuring high performance and safety.\n- **Customizable Environments**: Provides a framework to create and manage different RL environments.\n- **Flexible Agent Implementations**: Supports various agent strategies and learning algorithms.\n- **Extensible Policy Framework**: Allows for the implementation of diverse action selection policies.\n\n## Modules\n\n1. **Policy (`policy`)**:\n\n   - Defines the interface for action selection policies.\n   - Includes an implementation of Epsilon Greedy (with Decay) Policy.\n\n2. **Agent (`agent`)**:\n\n   - Outlines the structure for RL agents.\n   - Implements Value Iteration - Every Visit Monte Carlo (`VEveryVisitMC`) and Q-Learning - Every Visit Monte Carlo (`QEveryVisitMC`).\n\n3. **Environment (`env`)**:\n\n   - Provides the `Env` trait to define RL environments.\n   - Contains `LineWorld`, a simple linear world environment for experimentation.\n\n4. **Prelude (`prelude`)**:\n\n   - Exports commonly used items from the `env`, `agent`, and `policy` modules for convenient access.\n\n## Getting Started\n\n### Prerequisites\n\n- Rust Programming Environment\n\n### Installation\n\nIn your project directory, run the following command:\n\n```shell\ncargo add forger\n```\n\n### Basic Usage\n\n```rust\nuse forger::prelude::*;\nuse forger::env::lineworld::{LineWorld, LineWorldAction};\n\npub type S = usize;             // State\npub type A = LineWorldAction;   // Action\npub type P = EGreedyPolicy\u003cA\u003e;  // Policy\npub type E = LineWorld;         // Environment\n\nfn main() {\n    let env = LineWorld::new(\n        5,      // number of states\n        1,      // initial state\n        4,      // goal state\n        vec![0] // terminal states\n    );\n\n    let mut agent = QEveryVisitMC::\u003cS, A, P, E\u003e::new(0.9); // Q-learning (Everyvisit MC, gamma = 0.9)\n    let mut policy = EGreedyPolicy::new(0.5, 0.95);        // Epsilon Greedy Policy (epsilon = 0.5, decay = 0.95)\n\n    for _ in 0 .. 200 {\n        let mut episode = vec![];\n        let mut state = env.get_init_state();\n\n        loop {\n            let action = agent.select_action(\u0026state, \u0026mut policy, \u0026env);\n            let (next_state, reward) = env.transition(\u0026state, \u0026action);\n            episode.push((state, action.unwrap(), reward));\n            match next_state {\n                Some(s) =\u003e state = s,\n                None =\u003e break,\n            }\n        }\n\n        agent.update(\u0026episode);\n        policy.decay_epsilon();\n    }\n}\n```\n\n## Examples\n\n1. [**Monte Carlo with Epsilon Decay in `LineWorld`**](./examples/lineworld_mc_edecay.rs):\n\n   - Demonstrates the use of the Q-Learning Every Visit Monte Carlo (`QEveryVisitMC`) agent with an Epsilon Greedy Policy (with decay) in the `LineWorld` environment.\n   - Illustrates the process of running multiple episodes, selecting actions, updating the agent, and decaying the epsilon value over time.\n   - Updates the agent after each episode.\n\n2. [**TD0 with Epsilon Decay in `GridWorld`**](./examples/gridworld_td0_edecay.rs):\n\n   - Demonstrates the use of the TD0 (`TD0`) agent with an Epsilon Greedy Policy (with decay) in the `GridWorld` environment.\n   - Illustrates the process of running multiple episodes, selecting actions, updating the agent, and decaying the epsilon value over time.\n   - Updates the agent every steps in each episode.\n   - Include test process of trained agent.\n\n## Contributing\n\nContributions to Forger are welcome! If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.\n\n## License\n\nForger is licensed under the MIT License or the Apache 2.0 License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxect%2Fforger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxect%2Fforger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxect%2Fforger/lists"}