{"id":25768150,"url":"https://github.com/pixelcaliber/q-learning","last_synced_at":"2026-04-16T11:01:30.972Z","repository":{"id":278796890,"uuid":"936806897","full_name":"pixelcaliber/q-learning","owner":"pixelcaliber","description":"Q-learning agent: a type of reinforcement learning algorithm where an agent learns to take actions in an environment by maximizing a cumulative reward.","archived":false,"fork":false,"pushed_at":"2025-02-23T18:06:34.000Z","size":57,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-30T00:36:55.476Z","etag":null,"topics":["gametheory","machine-learning","python","qlearning-algorithm","reinforcement-learning"],"latest_commit_sha":null,"homepage":"https://t3-ai.vercel.app/","language":"Python","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/pixelcaliber.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-21T18:10:29.000Z","updated_at":"2025-02-23T18:06:37.000Z","dependencies_parsed_at":"2025-06-30T06:36:16.769Z","dependency_job_id":"7ad2c903-966e-4167-9982-2ee9b21a1bc3","html_url":"https://github.com/pixelcaliber/q-learning","commit_stats":null,"previous_names":["pixelcaliber/q-learning"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pixelcaliber/q-learning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelcaliber%2Fq-learning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelcaliber%2Fq-learning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelcaliber%2Fq-learning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelcaliber%2Fq-learning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pixelcaliber","download_url":"https://codeload.github.com/pixelcaliber/q-learning/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelcaliber%2Fq-learning/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31882886,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T09:23:21.276Z","status":"ssl_error","status_checked_at":"2026-04-16T09:23:15.028Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["gametheory","machine-learning","python","qlearning-algorithm","reinforcement-learning"],"created_at":"2025-02-27T00:50:28.113Z","updated_at":"2026-04-16T11:01:30.924Z","avatar_url":"https://github.com/pixelcaliber.png","language":"Python","readme":"## Q-Learning Agent\n\n### Concept and Theory\n\nQ-learning is a type of reinforcement learning algorithm where an agent learns to take actions in an environment by maximizing a cumulative reward. Key concepts include:\n\n- **State:**  \n  The current configuration of the Tic Tac Toe board.\n- **Action:**  \n  A move (placing an 'X' or 'O') in an available cell.\n- **Reward:**  \n  Feedback received after each move (e.g., winning gives a positive reward, losing gives a negative reward).\n- **Q-Value:**  \n  The expected future reward for taking a certain action from a given state. The agent updates these Q-values over time based on its experience.\n- **Exploration vs. Exploitation:**  \n  The agent uses an epsilon-greedy strategy to balance between exploring new moves and exploiting known moves with high Q-values.\n\n### Agent Training and Decision Making\n\n1. **Initialization:**  \n   The agent loads a pre-saved model (if available) at the start of each request.\n2. **Choosing an Action:**  \n   The agent examines the board state, evaluates available moves, and selects a move by balancing between exploration (random moves) and exploitation (best-known move).\n3. **Learning from Experience:**  \n   After each game, the game logger stores the moves and results. The agent uses this log to update its Q-values through the learning process.\n4. **Model Persistence:**  \n   The updated model is saved to disk so that the agent can retain its learning across sessions.\n\n## API Endpoints\n\n- **GET /health:**  \n  Checks the health of the application.\n- **GET /game?session_id=YOUR_SESSION_ID:**  \n  Returns the current game state, including the board, result, and scoreboard.\n- **POST /move:**  \n  Submits a move. Requires a JSON payload with `move` and `session_id`.\n- **GET /reset?session_id=YOUR_SESSION_ID:**  \n  Resets the game board (preserving the scoreboard).\n- **GET /delete_session?session_id=YOUR_SESSION_ID:**  \n  Deletes the session data when the user closes the tab.\n\n\u003e **Rate Limiting:**  \n\u003e All endpoints are rate-limited using Flask-Limiter to prevent abuse. For example, the `/move` endpoint is limited to 60 requests per minute.\n\n## Running the Project\n\n- **Backend Setup:**\n - Install dependencies: `pip install -r requirements.txt`\n - Set up configuration (e.g., `Config.RATE_LIMIT_STORAGE_URL`, `MODEL_SAVE_PATH`).\n - Run the Flask app: `flask run`\n- **Frontend**: https://github.com/pixelcaliber/t3-ai/blob/master/README.md\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelcaliber%2Fq-learning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpixelcaliber%2Fq-learning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelcaliber%2Fq-learning/lists"}