{"id":22144358,"url":"https://github.com/masaok/pacman-agent","last_synced_at":"2025-08-26T07:07:28.769Z","repository":{"id":138881628,"uuid":"424096498","full_name":"masaok/pacman-agent","owner":"masaok","description":"Pacman Trainer: Classroom-Ready Deep Learning from Data to Deployment (ASEE Conference 2022 Paper Submission)","archived":false,"fork":false,"pushed_at":"2023-01-05T02:35:20.000Z","size":24143,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T12:15:35.603Z","etag":null,"topics":["python","python3","tk","tkinter"],"latest_commit_sha":null,"homepage":"","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/masaok.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}},"created_at":"2021-11-03T04:56:43.000Z","updated_at":"2023-12-05T18:40:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"51178b0b-d1f5-498f-a12a-203291d550b6","html_url":"https://github.com/masaok/pacman-agent","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/masaok/pacman-agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masaok%2Fpacman-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masaok%2Fpacman-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masaok%2Fpacman-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masaok%2Fpacman-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/masaok","download_url":"https://codeload.github.com/masaok/pacman-agent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masaok%2Fpacman-agent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272186710,"owners_count":24888435,"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-26T02:00:07.904Z","response_time":60,"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":["python","python3","tk","tkinter"],"created_at":"2024-12-01T22:21:20.749Z","updated_at":"2025-08-26T07:07:28.743Z","avatar_url":"https://github.com/masaok.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Pacman Trainer\n\n### The final display with terminal debug output\n\n\u003cimg src=\"https://user-images.githubusercontent.com/1320083/210688412-798b95b4-a958-474a-bbd9-d46a2af7abbf.png\"  width=\"50%\" height=\"50%\"\u003e\n\n## Prerequisites\n\n- Python 3 (so far, it works with Python 3, but if there are problems, try Python 2)\n\n## Environments Tested\n\n### Windows 10 WSL2 Ubuntu (Build 19042.1288)\n\n- Git Bash\n- Python 3.8.10 (Window WSL2 Ubuntu)\n- Python 3.9.8 ([See latest versions](https://www.python.org/downloads/))\n  - Python must be 3.9.x or earlier or [PyTorch will not work](https://pytorch.org/get-started/locally/#windows-python)\n\n```\nsudo apt update\nsudo apt-get install python3-venv python3-tk\nsudo apt-get install python3-tk\n```\n\n### MacOS 11.6 (Build 20G165)\n\n- Python 3.9.4\n\n```\nbrew install python-tk\n```\n\n## Quickstart\n\n```\n$ git clone git@github.com:masaok/pacman-agent.git\n$ cd pacman-agent\n$ python3 -m venv env\n$ source env/Scripts/activate  # Windows Git Bash only\n$ source env/bin/activate      # Mac / Linux only\n$ pip install -r requirements.txt\n$ python3 -u environment.py -h  # Show command-line help\n$ python3 -u environment.py     # Run the app and show the GUI\n```\n\n```\n$ deactivate  # exit virtual environment\n```\n\n#### VcXsrv (X server for Windows to run GUI stuff)\n\nDownload and install VcXsrv from here: https://sourceforge.net/projects/vcxsrv/\n\nWhen running it (it's called XLaunch in Windows), make sure to check this box:\n\n\u003cimg src=\"https://user-images.githubusercontent.com/1320083/144793105-700cf916-2702-4510-9e22-72e578c21e36.png\" width=\"40%\" height=\"40%\"\u003e\n\nAlso, add [**this**](https://stackoverflow.com/a/61110604/10415969) to your `.bash_profile` and `source` it:\n\n```\nexport DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2\u003e/dev/null):0\nexport LIBGL_ALWAYS_INDIRECT=1\n```\n\n**Verify that VcXsrv is running correctly by testing Xcalc:**\n\n\u003cimg src=\"https://user-images.githubusercontent.com/1320083/144791512-15fa20b7-8dff-4e3f-ba2f-55ade96f3276.png\" width=\"40%\" height=\"40%\"\u003e\n\nAlso, make this change in the code whereever `torch.load` is called:\n\nhttps://stackoverflow.com/questions/56369030/runtimeerror-attempting-to-deserialize-object-on-a-cuda-device/62327502#62327502\n\n**Run the real thing:**\n\n`python3 -u environment.py`\n\n\u003cimg src=\"https://user-images.githubusercontent.com/1320083/144791554-3731ce3c-99e2-4877-a766-cbf4664984db.png\" width=\"40%\" height=\"40%\"\u003e\n\n## Components\n\n- **PacmanAgent**: Contains all of the logic for the agent controlling Pacman\n- **PacmanTrainer**: Contains the logic for training Pacman using Pytorch for deep imitation learning.\n- **Environment**: Contains the game logic and is largely structured in the same way as the Wumpus World / Blindbot's environment\n  - A constructor, parameterized by the Pacman Trainer's array-of-strings maze representation, that initializes all of the maze variables, as follows:\n    - The maze structure, where walls are located, and thus what legal moves are available in any position.\n    - The sets and positions of all game actors (beginning with their provided starting positions), including:\n      - Pacman\n      - Ghosts\n      - Pellets\n  - Pacman's score (# of pellets eaten)\n  - Determining game-ending conditions (viz., Pacman getting eaten by a ghost or eating every pellet)\n  - Rendering the maze elements (in their basic array-of-strings format like in the Pacman Trainer) in terms of their graphical equivalents\n  - Actors in the environment take turns acting, so the environment determines what happens on every \"tick\" or turn of a running game:\n    - The PacmanAgent's chooseAction method is called with the current game state, and its action choice is enacted (if it's not a legal action, i.e., one that runs it into a wall, it does nothing that turn).\n      - If Pacman eats a pellet, it is removed from the board and the score is incremented\n      - If Pacman moves onto a ghost's tile, it dies and the game's over\n    - All ghosts make an action choice governed by a coin-flip: 10% of the time, it will choose randomly, and the other 90%, it will take a step that brings it closer to Pacman. You can use / adapt the Pathfinder class I gave in the BlindBot package to help with pathfinding or just do something basic like looking at the Manhattan distance between a ghost and Pacman and then choosing the action that minimizes it.\n- **MazeUI**: Given a Tk \"root window\", draw a Tk Canvas on it and all the blocks, characters, and items that make up a maze\n\n## Exercise\n\nTo view the accompanying exercise binding Pacman Trainer and Agent, see the EXERCISE.md instructions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasaok%2Fpacman-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasaok%2Fpacman-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasaok%2Fpacman-agent/lists"}