Metadata-Version: 2.4
Name: cege-gopher
Version: 0.3.0
Summary: A Karel-style grid robot for teaching Python, themed as Goldy Gopher. Records and replays, so it works in Colab.
Author-email: Seongjin Choi <chois@umn.edu>
License: MIT License
        
        Copyright (c) 2026 Seongjin Choi
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Keywords: education,karel,robot,colab,cege3101
Classifier: Intended Audience :: Education
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Education
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: matplotlib>=3.5
Dynamic: license-file

# cege_gopher

A Karel-style grid robot for teaching introductory Python, themed as Goldy
Gopher. Written for **CEGE 3101 — Computer Applications I** at the University of
Minnesota.

Ported from the MATLAB robot used in earlier offerings of the course, which was
itself a port of the KAIST CS101 HUBO exercise
([otfried/cs101](https://github.com/otfried/cs101)) — Karel the Robot, at the
root of it.

## Why this exists

The original libraries open a live window and animate each command as it runs.
**Google Colab cannot host one.**

So this version **records, then replays**. Every command appends a frame to a
buffer; nothing is drawn until `show()`, which renders the whole run as an
inline animation:

> write the whole program → run the cell → watch it play back

Students never drive the robot interactively; every program is pre-coded, which
is also how the homework is graded.

## Install

```bash
pip install cege-gopher
```

Or, from the course repository:

```bash
pip install "git+https://github.com/benchoi93/CEGE3101_Computer_Applications.git#subdirectory=packages/cege-gopher"
```

The 13 world files ship **inside the package**, so nothing needs uploading —
`load_world("harvest1.wld")` just works.

## Use

```python
from cege_gopher import *

load_world("harvest1.wld")       # or: create_world(10, 10)
goldy = Gopher()
goldy.set_trace("maroon")

while goldy.front_is_clear():
    if goldy.on_carrot():
        goldy.pick_carrot()
    goldy.move()

show()                           # the animation renders here
```

`list_worlds()` returns the bundled world names.

## API

| | |
|---|---|
| Module | `create_world(avenues, streets)`, `load_world(name)`, `list_worlds()`, `show(fps=)`, `show_final()`, `get_world()` |
| Move | `move()`, `turn_left()`, `turn_right()` |
| Carrots | `pick_carrot()`, `drop_carrot()` |
| Sense | `front_is_clear()`, `left_is_clear()`, `right_is_clear()`, `facing_north()`, `on_carrot()`, `carries_carrots()` |
| Display | `set_trace(color)`, `get_pos()` |

`Robot` is an alias for `Gopher`, and `pick_beeper`/`pick_coin` for
`pick_carrot`, so code written against `cs1robots` or the MATLAB version still
runs.

## A bug fixed in this port

The MATLAB version had `leftIsClear` and `rightIsClear` **swapped** — facing
east it checked south for "left", when `turnLeft` rotates counter-clockwise
(E→N) so left of east is north. This port uses `left = (-dy, dx)`,
`right = (dy, -dx)`.

## License

MIT.
