Skip to content

Commit 622b0df

Browse files
Updated the readme.
1 parent 7b83d47 commit 622b0df

File tree

2 files changed

+151
-54
lines changed

2 files changed

+151
-54
lines changed

README.md

Lines changed: 151 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,174 @@
1-
# Pacman
1+
# Pacai
22

33
An AI educational project disguised as [Pac-Man](https://en.wikipedia.org/wiki/Pac-Man)!
44

5-
A modified version of the Pacman educational project from the [Berkeley AI Lab](http://ai.berkeley.edu/project_overview.html).
6-
7-
Some improvements from the original project:
8-
- Upgraded to Python 3.
9-
- Organized into packages.
10-
- Brought up to a common style.
11-
- Added logging.
12-
- Added tests.
13-
- Fixed several bugs.
14-
- Generalized and reorganized several project elements.
15-
- Replaced the graphics systems.
16-
- Added the ability to generate gifs from any pacman or capture game.
17-
18-
## FAQ
19-
20-
**Q:** What version of Python does this project support?
21-
**A:** Python >= 3.10.
22-
The original version of this project was written for Python 2, but it has since been updated.
23-
24-
**Q:** What dependencies do I need for this project?
25-
**A:** This project has very limited dependencies.
26-
The pure Python dependencies can be installed via pip and are all listed in the requirements file.
27-
These can be installed via: `pip3 install --user -r requirements.txt`.
28-
To use a GUI, you also need `Tk` installed.
29-
The process for installing Tk differs depending on your OS, instructions can be found [here](https://tkdocs.com/tutorial/install.html).
30-
31-
**Q:** How do I run this project?
32-
**A:** All the binary/executables for this project are located in the `pacai.bin` package.
33-
You can invoke them from this repository's root directory (where this file is located) using a command like:
5+
This project was inspired by and originally based off of the Pacman educational project from the
6+
[Berkeley AI Lab](http://ai.berkeley.edu/project_overview.html).
7+
It has since been completely rewritten.
8+
9+
Some notable changes from the original Berkeley project:
10+
- Upgraded to Python 3.10.
11+
- All code is typed.
12+
- TK/tkinter is now optional.
13+
- The default UI is web/browser based.
14+
- Agents can be isolated from the core game engine to prevent cheating.
15+
- Games can be saved as gifs/webps.
16+
- The graphical engine has been optimized.
17+
- Substantial testing infrastructure has been added.
18+
- Agent speed is now configurable.
19+
20+
## Installation / Requirements
21+
22+
This project requires [Python](https://www.python.org/) >= 3.10.
23+
24+
The project can be installed from PyPi with:
25+
```sh
26+
pip3 install pacai
27+
```
28+
29+
Standard Python requirements are listed in `pyproject.toml`.
30+
The project and Python dependencies can be installed from source with:
31+
```sh
32+
pip3 install .
33+
```
34+
35+
### Tk
36+
37+
*Optional*
38+
39+
If you want to run any Pac-Man code in a system window (instead of a browser window),
40+
then you will need to install a library called [Tk](https://tkdocs.com/tutorial/install.html).
41+
There is a version for pretty much all operating system,
42+
and you should be able to follow the simple [installation instructions](https://tkdocs.com/tutorial/install.html).
43+
44+
You may already have Tk installed,
45+
and can skip this step!
46+
To test, run the following command:
47+
```sh
48+
python3 -c 'import tkinter ; tkinter._test()'
3449
```
35-
python3 -m pacai.bin.pacman
50+
51+
If a window pops up, then you should be all set!
52+
53+
You can now run Pac-Man commands with `--ui tk` to use a Tk window instead of a browser window.
54+
55+
## Using Pacai
56+
57+
Once installed, you can play a game of Pac-Man with:
58+
```sh
59+
python3 -m pacai.pacman
3660
```
3761

38-
**Q:** What's with the `student` package?
39-
**A:** The `student` package is for the files that students will edit to complete assignments.
40-
When an assignment is graded, all files will be placed in the `student` package.
41-
The rest will be supplied by the autograder.
42-
This makes it clear to the student what files they are allowed to change.
62+
To see all the available options, use the `--help` flag:
63+
```sh
64+
python3 -m pacai.pacman --help
65+
```
4366

44-
**Q:** How do I get my own copy of repo to develop on?
45-
**A:** Anyone who will be committing solutions should use this template repository to create a **private repository**.
46-
Directions for that can be found [here](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template).
47-
For anyone else, you can just [fork it](https://help.github.com/en/articles/fork-a-repo) as you normally would.
67+
### Boards
4868

49-
## Pulling Changes from This Repo Into Your Fork
69+
You can change the board that you are playing on with the `--board` option.
70+
Pacai comes with several different boards in the [pacai/resources/boards directory](pacai/resources/boards).
71+
For example:
72+
```sh
73+
python3 -m pacai.pacman --board classic-original
74+
```
5075

51-
Occasionally, you may need to pull changes/fixes from this repository.
52-
Doing so is super easy.
53-
Just go to your default branch and do a `git pull` command with this repository as an argument:
76+
You can also specify a path to a board file if you want to use a custom board:
77+
```sh
78+
python3 -m pacai.pacman --board pacai/resources/boards/classic-small.board
5479
```
55-
git pull https://github.com/linqs/pacman.git
80+
81+
### UIs
82+
83+
You can change the user interface (UI) you are using with the `--ui` option.
84+
The provided UIs are:
85+
- `null` -- Do not show any ui/graphics (best if you want to run fast and just need the result).
86+
- `text` -- Use stdin/stdout from the terminal.
87+
- `tk` -- Use Tk/tkinter (must already be installed) to open a window.
88+
- `web` -- Launch a browser window (default).
89+
90+
For example if you just want to run a game without seeing anything,
91+
you can do:
92+
```sh
93+
python3 -m pacai.pacman --ui null
5694
```
5795

96+
This is the quickest way to run a game,
97+
and can be very useful when testing out agents.
98+
99+
You can also run using TK (if you already have it installed) with:
100+
```sh
101+
python3 -m pacai.pacman --ui tk
102+
```
103+
104+
### Choosing an Agent
105+
106+
In Pac-Man, you can choose which agent you use with the `--agent` option.
107+
The `--help` flag will list all the agent's available by default.
108+
Agents may be specialized and not work on every board.
109+
110+
For example, you can use a random agent with:
111+
```sh
112+
python3 -m pacai.pacman --board classic-small --pacman agent-random
113+
```
114+
115+
You can also use `--agent` to point to any importable module or file/class.
116+
```sh
117+
# Use an importable module name.
118+
python3 -m pacai.pacman --pacman pacai.agents.random.RandomAgent
119+
120+
# Point to an agent class inside of a file.
121+
python3 -m pacai.pacman --pacman pacai/agents/random.py:RandomAgent
122+
```
123+
124+
#### Agent Arguments
125+
126+
Many agents will accept arguments that can be used to tweak that agent's behavior.
127+
These arguments can be passed using the `--agent-arg` options
128+
(which can be specified as many times as you wish).
129+
The argument to `--agent-arg` is formatted as: `<agent index>::<option name>=<option value>`.
130+
131+
For example, by default the `agent-search-problem` agent uses a random search to solve its search problems.
132+
It should be able to eventually solve the maze, but with a suboptimal path:
133+
```sh
134+
python3 -m pacai.pacman --board maze-tiny --pacman agent-search-problem
135+
```
136+
137+
We can pass this agent (which has an index of 0)
138+
an argument telling it to use a search specialized for this board instead of a random search:
139+
```sh
140+
python3 -m pacai.pacman --board maze-tiny --pacman agent-search-problem --agent-arg 0::solver=search-solver-maze-tiny
141+
```
142+
143+
Note that the agent now finds the optimal path much faster.
144+
145+
## For Students
146+
147+
Students who are working on this project as part of a class should note a few things:
148+
1. Never share your solutions or implemented code.
149+
In many courses, this would be considered cheating.
150+
2. Make sure that your version of this repo is private.
151+
Having a public repo may be indirectly sharing code.
152+
You can follow GitHub's directions on
153+
[creating a repo from a template](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template).
154+
Pay close attention to make the repository private.
155+
3. All or most of the code you will implement will be in the [pacai/student directory](pacai/student).
156+
58157
## Acknowledgements
59158

60159
This project has been built up from the work of many people.
61160
Here are just a few that we know about:
62-
- The Berkley AI Lab for starting this project. Primarily John Denero and Dan Klein.
161+
- The Berkeley AI Lab for starting this project.
162+
Primarily John Denero and Dan Klein.
63163
- Barak Michener for providing the original graphics and debugging help.
64164
- Ed Karuna for providing the original graphics and debugging help.
65165
- Jeremy Cowles for implementing an initial tournament infrastructure.
66166
- LiveWires for providing some code from a Pacman implementation (used / modified with permission).
67-
- The LINQS lab from UCSC.
68-
- Graduates of the CMPS 140 class who have helped pave the way for future classes (their identities are immortalized in the git history).
167+
- The LINQS lab from UCSC for updating the code to Python 3 and various other improvements.
168+
- Connor Pryor for various development and design efforts.
169+
- Eriq Augustine and EduLinq for rewriting the project from scratch.
170+
- TAs, grader, and graduates of UCSC's CMPS/CSE 140 class who have helped pave the way for future classes
171+
(their identities are immortalized in the git history).
69172

70173
## Licensing
71174

docs/development.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)