Skip to main content

Official Stanford Karel library used in CS 106A

Project description

stanford-karel

Python 3.6+ PyPI version GitHub license Downloads

This is a Python implementation of Karel for Stanford's CS 106A. This package is available on PyPI and allows you to run Karel programs without any additional setup!

Huge credits to @nickbowman for rewriting this project from scratch!

StanfordKarel now supports:

  • Pip-installable package means you can run Karel programs from anywhere.
  • Solution code no longer needed to grade assignments. Instead, the output world is compared.
  • Karel in ASCII!
  • Improved autograding, testing, linting, and auto-formatting.

Usage

pip install stanfordkarel

or

git clone https://github.com/tyleryep/stanfordkarel.git

Documentation

Running Karel

First, ensure that Karel is correctly installed using pip. If so, then any .py file can become a Karel program!

from stanfordkarel import *


def main():
    """ Karel code goes here! """
    turnLeft()
    move()
    turnLeft()


if __name__ == "__main__":
    run_karel_program()

To run a specific problem, ensure that the Python file name and the world file name matches exactly.

Folder structure

  • assignment1/
    • worlds/ (additional worlds go here)
      • collect_newspaper_karel.w
      • collect_newspaper_karel_end.w
    • collect_newspaper_karel.py

Creating Worlds

If using the pip-installed version, simply run python -m stanfordkarel.world_editor.

To run the World Editor from the repository, simply run python world_editor.py.

Grading

./autograde runs the available tests using pytest in the tests/ folder and prints out any output differences in the world. The tests use the student's code and the expected world output to determine correctness. If the output is not the same, the test driver will print out an ASCII representation of the differences.

Autograder

Development

Everything important is located in stanfordkarel/.

  • stanfordkarel/ is the exported package, which contains all of the available functions and commands for students to use.
  • karel_application.py is responsible for loading student code and displaying it to the screen.

Contributing

All issues and pull requests are much appreciated! To run all tests and other auto-formatting tools, check out scripts/run-tests.

Future Milestones

In the future, I hope to add:

  • Automatic style checking
  • Ways of determining the student's strategy or approach from observing Karel movements
  • Autograde more worlds, broken down by assignment
  • Allow students to autograde their own work
  • Accessibility for visually-impaired students (using ascii karel)

Minor TODOs

  • Use f2string to convert all f strings to format strings for Python 3.5 compatibility

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stanfordkarel-0.0.7.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stanfordkarel-0.0.7-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file stanfordkarel-0.0.7.tar.gz.

File metadata

  • Download URL: stanfordkarel-0.0.7.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for stanfordkarel-0.0.7.tar.gz
Algorithm Hash digest
SHA256 9946a7950dcae425d53bfff7a59024b2390c3e6b527af12de12e20c1d84f0632
MD5 3779d76e9527325a4761381d9116237e
BLAKE2b-256 2b0ad22d2b6252e1faeba07e21a49c9bb4276de9779c929cb5a9db7f4badbdd9

See more details on using hashes here.

File details

Details for the file stanfordkarel-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: stanfordkarel-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for stanfordkarel-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f411672830ad848991c7ea4a899df6f1bdf887f9b5536727a4ee69d7263c834e
MD5 e94c939e8ca7ef19c0c7388c780b46cf
BLAKE2b-256 5f60ec969cc33d47933a1599a4ee1cd66aa2f9dc7d792c2615038fc1013b0ed8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page