Skip to content

Commit

Permalink
Add technical details to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonyte committed Sep 14, 2023
1 parent a18fec5 commit c32e36e
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@

This repository contains **The Top-level Walruses** team's submission for the [10th Python Discord Code Jam](https://www.pythondiscord.com/events/code-jams/10/).

## TODO

> Your presentation should cover the following:
> Describe what your project does
> Show it in action, how you use it, what the end result is, any really cool features
> The connection to the theme
> Which data processing/manipulation technology was used and how it was used
## What this is

TODO

## Secret codes

The theme of the code jam was **secret codes**.
Expand Down Expand Up @@ -75,7 +63,7 @@ python -m piet run out.png
```

This command has the same `--input`, `--step-limit` and `--debug` options as the `generate` command.
The additional `--execute` flag will try to execute the content of the image as Python code.
Additionally, the `--execute` flag will try to execute the content of the image as Python code.

### Encrypting with a key

Expand Down Expand Up @@ -126,10 +114,40 @@ python -m piet run out.png --input "key1"

## Technical

We used Pillow for reading and writing images files, and a custom list subclass to store the color data as tuples of RGB values.
We used Pillow for reading and writing image files, and a custom list subclass to store the color data as tuples of RGB values.
We opted not to use numpy arrays because it was more work to resize the arrays dynamically than to use a list.

TODO: add technical details describing the modules (generator, interpreter, runtime, reader)
### Common

This module simply contains common classes and constants used by the other modules, like the `Color` named tuple and the `SelfExpandingList` class.

### Reader

Interpreting an image starts with the reader module.
The `ImageReader` class is responsible for converting an input image into a two-dimensional list of `Color` objects, and analyzing the image to determine information about codels and color blocks.

### Runtime

The runtime module contains the classes that simulate Piet's behavior, including the stack, direction pointer, and codel chooser.
A `PietRuntime` object keeps track of the state of the stack, pointer, and codel chooser, and provides methods to manipulate them.
It also provides the binary input and output interfaces.

### Interpreter

The `PietInterpreter` class contains the logic for executing a Piet program.
It exposes the methods `run` to run the program, and `step` to execute a single step in the execution loop.

### Generator

The `ImageGenerator` class is responsible for generating an image from input data.
It has methods for setting specific locations in the image to specific commands, and setting the next command in the path of the interpreter's execution.
Internally, it uses the interpreter to run the program as it is being generated, to determine the position of the next command.
It also has a method for generating an image recursively up to a specified depth.
Once the generated image is complete, the colors are inserted into an Pillow `Image` object and returned.

### CLI

This module provides a command-line interface for the generator and interpreter.

## Known issues

Expand Down Expand Up @@ -177,6 +195,7 @@ Team contributions:

For those of you who just want to admire the code art a little more, here is a collection of images generated by our program.
Decrypting them is left as an exercise for the reader.
Can you solve the puzzle? 😉

### key.png

Expand Down

0 comments on commit c32e36e

Please sign in to comment.