Your true colors shine
Through the rolls of your pig dice
Like a code rainbow
This contest is completely optional!
The game UI currently uses Western-style black and white dice:
We've made it possible for you to overwrite those dice with your own programmed graphics.
- Make much more colorful dice
- Play around with different ways to arrange the pips on each die
- Incorporate some piggies in the dice design
- Imitate the designs of dice from other cultures
The contest ends Monday, September 20 at 11:59 PM. Submit your dice before then!
- Download the zip file linked at the top. That contains the Hog files, a submission script, and a new file
- Copy over your final
hog.pyinto the folder.
- Open the
draw_dice function takes a single argument
num (the number rolled) and returns a Python object
representing a vector graphic.
The provided starter code draws a 100x100 rectangle:
def draw_dice(num): graphic = create_graphic(100, 100) draw_rect(graphic, 0, 0, 100, 100, fill="white", stroke="black") return graphic
create_graphic creates a vector graphic with the specified width and height.
draw_rect function adds a rectangle to the provided graphic (the first parameter).
Here are all the functions you can call to draw shapes on the graphic:
||Draws a rectangle at the given
||Draws a circle at the given
||Draws a line that starts [
||Writes the string
stroke parameters are always optional and default to "black". You can specify other colors using color names or hexadecimal notation.
- You need to create a different design for each side, 1 through 6. One way to do that is to design each dice side separately and output the designs using an
ifstatement. However, you wouldn't learn as much about programming that way. Instead, you should use a combination of loops and variables, with the variables tracking things like the spacing between pips, the number of columns needed, etc.
- The shapes are drawn sequentially on top of each other, so pay close attention to the order of the drawing commands.
- If you need inspiration, read about Dice on Wikipedia or search Etsy for dice.
There are two ways that you can check your work as you go along:
- You can re-run
python3 hog_gui.pyto start the game locally and roll the dice. That's a good way to see how the dice all look together.
You can also directly enter a URL in the browser to see the graphic for a particular die:
- Dice 1:
- Dice 2:
- Dice 3:
- Dice 4:
- Dice 5:
- Dice 6:
- Dice 1:
Teams can have one or two people. Each person can only be part of one team.
The course staff will vote on their favorite designs, and will look at both the design and the code.
The top three submissions will earn the following:
- First place gets 3 points of extra credit.
- Second place gets 2 points of extra credit.
- Third place gets 1 point of extra credit.
Submit your designs
Before submission, please ensure that your designs abides by these guidelines:
- Designs should not contain anything discriminatory or offensive.
- Designs should not contain sexual or violent content, or otherwise objectionable content.
- Designs must not contain any personal information.
We reserve the right to hide designs that do not follow these guidelines.
Please also add a caption for your dice by replacing
DICE_CAPTION = "these dice taste good with rice"
Ready to submit? Run:
python3 ok --submit
If you see an SSL error when trying to submit, that's an issue with your local installation of Python 3 on Mac OS X. Navigate to
Applications/Python 3.[Version]and run
Install Certificates.commandby double-clicking it.
Once submitted, you should see your designs show up in the showcase! 🎉 🎲 🎉