Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
2c87b85
Added class defintions for course and req. Req is incomplete.
sokuno222 Oct 19, 2017
24678e7
Added import script
iblancett Oct 19, 2017
a168e80
Added ideation and source folders
iblancett Oct 19, 2017
42abeb2
progress on algos -- nothing working yet
iblancett Oct 19, 2017
8730859
Updating graphics window script. Added incomplete mouse pressed event
sokuno222 Oct 20, 2017
d959455
Courses can now be made
iblancett Oct 20, 2017
f4556da
Commiting to resolve pull errors. Added mouse_pressed event to graphi…
sokuno222 Oct 20, 2017
dba8016
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
sokuno222 Oct 20, 2017
8976520
Made course icons
leoliuuu Oct 20, 2017
5118db2
started game control
iblancett Oct 20, 2017
2d2ea2d
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
iblancett Oct 20, 2017
c15d2ea
Started setting up background function for graphics.py to call. Need …
sokuno222 Oct 20, 2017
4933c21
Made some level icons
leoliuuu Oct 21, 2017
e4c2e94
Changed files to incorperate icon images and mouseOver function. Stil…
sokuno222 Oct 21, 2017
afea157
Algo implemented for game control
iblancett Oct 22, 2017
a786ea4
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
iblancett Oct 22, 2017
d0b42b6
Something didn't push
iblancett Oct 22, 2017
96e4cd4
Deleted unused scripts
iblancett Oct 22, 2017
b133a20
Added some doctests to Gameplay and debugged
iblancett Oct 23, 2017
03ad23a
Debugged some more, added ending verdict and more doctests
iblancett Oct 23, 2017
459d704
added communication between gameplay and main
iblancett Oct 23, 2017
f273cc2
Rearranged environment images
iblancett Oct 23, 2017
31a7cdb
Setup portfolio class
iblancett Oct 23, 2017
163590c
changed file paths to work on Mac
iblancett Oct 23, 2017
5b05cd1
Moved rendered text to setUpE. Course Image loading not working
sokuno222 Oct 24, 2017
30641b9
Fixed rendering error in setUpE
sokuno222 Oct 24, 2017
2c3120d
Readded rendering font to mouseover function
sokuno222 Oct 24, 2017
07ab946
Fixing text overwriting problem
sokuno222 Oct 24, 2017
bd1937a
Fixed text writing over itself and size
sokuno222 Oct 24, 2017
e183459
Moved text rendering to setUpE, Made setUpE run only once.
sokuno222 Oct 26, 2017
47cb257
Unpushed changes
iblancett Oct 27, 2017
d216f76
Changed some lines to incorporate seperate mouseClicked function
sokuno222 Oct 27, 2017
cf87127
Started integration
iblancett Oct 27, 2017
df10443
Updated graphics
iblancett Oct 27, 2017
a870d23
Put graphics loop in main
iblancett Oct 28, 2017
3dac77b
Added userdefined events for pushing buttons to mouseClicked()
sokuno222 Oct 28, 2017
2435bc3
Added req to mouseClicks for button to not have been pressed before. …
sokuno222 Oct 28, 2017
e82a305
Added button events
iblancett Oct 28, 2017
8155d51
Debug
iblancett Oct 28, 2017
231df00
Fixed bugs, game is now functional, but algo needs to be optimized
iblancett Oct 29, 2017
90fad98
Added the reflection
leoliuuu Oct 29, 2017
2efaecc
Made changes to updating images
leoliuuu Oct 30, 2017
231e65f
Added b&w course icons to show button was pressed
sokuno222 Oct 30, 2017
a7ed21a
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
sokuno222 Oct 30, 2017
453689c
fixed level algo
iblancett Oct 30, 2017
bc190ca
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
iblancett Oct 30, 2017
a8d39f8
Added b&w icons to mouseClicks so clicked icon is greyed out.
sokuno222 Oct 30, 2017
59af4e5
rearranged code to be more modular
iblancett Oct 30, 2017
7d216f1
created calls to ending function
iblancett Oct 30, 2017
6894572
Added headers
iblancett Oct 30, 2017
4130462
Added course descriptions
sokuno222 Oct 30, 2017
5863d32
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
sokuno222 Oct 30, 2017
f63593d
revised project reflection
iblancett Oct 30, 2017
8f2efc1
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
iblancett Oct 30, 2017
646e64c
update on the portfolio image
leoliuuu Oct 30, 2017
8bfb444
Changing color
sokuno222 Oct 30, 2017
6f88e50
Fixed portfolio function
iblancett Oct 30, 2017
62e75c2
Update on README
leoliuuu Oct 30, 2017
4b50ce2
Created ending.py to make text ending
sokuno222 Oct 30, 2017
9dcf674
Added ending files.
sokuno222 Oct 30, 2017
245d255
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
sokuno222 Oct 30, 2017
340cbe8
Added call to ending function
iblancett Oct 30, 2017
b96b29e
Fixed ending
iblancett Oct 30, 2017
4549dc2
Got endings working, window no longer quits
sokuno222 Oct 30, 2017
e773ac0
Fixed typo
sokuno222 Oct 30, 2017
e6a9e17
Fixed icon descriptions to match the correct icons
sokuno222 Oct 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Ending_pics/grad_hat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Course_Icons/BeeKeeping.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Course_Icons/ENM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Course_Icons/FOCS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Course_Icons/Fun Robo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Course_Icons/Mat Sci.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Course_Icons/Mecho Proto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/BK1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/BK2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/BK3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/ENM1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/ENM2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/FOC1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/FOC2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/FOC3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/MP1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/MP2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/MP3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/MP4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/MP5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/MS1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ideation/Level_Icons/MS2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 94 additions & 0 deletions Project Write-up and Reflection.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Project Overview"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We created game that allows people to build their own Olin portforlio whose advances depend on a series of Olin courses chosen by the user. \n",
"This concept is inspired by the Grow Series games, specifically Grow Island (http://www.eyezmaze.com/grow/island/)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Results [~2-3 paragraphs + figures/examples]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Present what you accomplished. This will be different for each project, but screenshots are likely to be helpful"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Implementation [~2-3 paragraphs + UML diagram]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Describe your implementation at a system architecture level. Include a UML class diagram, and talk about the major components, algorithms, data structures and how they fit together. You should also discuss at least one design decision where you had to choose between multiple alternatives, and explain why you made the choice you did."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Reflection [~2 paragraphs]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Overall, working on this project was a great learning experience on how to build an interactive graphic with pygame and how code collaboratively. The project was divided into two parts: control algorithms and graphics. Each side of the project proved challenging and engaging to their owners. However, obvisouly, with three members in the team, the separation of the responsibilities was not as clear as it would have been with two member teams. The third member of our team often needed to complete sub-tasks for both algorithm and graphics, which presented challenges, such as Git merge errors and overload of code to examine. Our team has memebers from two different colleges, which resulted in different schedules and difficulty of meeting up in one setting. Despite these obstacles, our team still met more than four times in the span of two weeks, not including class time, and keep an active group chat to update each other on our progress.\n",
"\n",
"The most challanging part of the game development process was integration. Basically, both algorithms and and graphics had to meet each other halfway in a 'main' script to communicate to each other through passing of events and decisions. This time-consuming task forced all three members to teach each other the workings of their code. This process could have been optimized by creating a more in-depth model of our code prior to implementation. For the upcoming final project, some lessons we will all take with us is to emphasize initial code design, increase frequency of updates to team members, and clearly define individual tasks for each member."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# InteractiveProgramming
# Interactive Programming

This is the base repo for the interactive programming project for Software Design at Olin College.
Software Design MP4
----
We created game that allows people to build their own Olin portfolio whose advances depend on a series of Olin courses chosen by the user. This concept is inspired by the Grow Series games, specifically Grow Island (http://www.eyezmaze.com/grow/island/).

## Getting Started:
First, install required package: pip install pygame

## Usage
To run the game, run main.py in the Source folder with python 3

## Links:
[Project Reflection](https://docs.google.com/document/d/17OtSFGBJM4z2rdNP-eROhAGwgEVZCMOTp_JZXipS9jc/edit?ts=59f699c3#heading=h.dhufdrd1c1qm)
Binary file added Source/Course_Icons/bees.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Source/Course_Icons/bees_clicked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Source/Course_Icons/elec.png
Binary file added Source/Course_Icons/elec_clicked.png
Binary file added Source/Course_Icons/focs.png
Binary file added Source/Course_Icons/focs_clicked.png
Binary file added Source/Course_Icons/mats.png
Binary file added Source/Course_Icons/mats_clicked.png
Binary file added Source/Course_Icons/mech.png
Binary file added Source/Course_Icons/mech_clicked.png
Binary file added Source/Course_Icons/robo.png
Binary file added Source/Course_Icons/robo_clicked.png
Binary file added Source/Level_Icons/bees1.png
Binary file added Source/Level_Icons/bees2.png
Binary file added Source/Level_Icons/bees3.png
Binary file added Source/Level_Icons/elec1.png
Binary file added Source/Level_Icons/elec2.png
Binary file added Source/Level_Icons/focs1.png
Binary file added Source/Level_Icons/focs2.png
Binary file added Source/Level_Icons/focs3.png
Binary file added Source/Level_Icons/mats1.png
Binary file added Source/Level_Icons/mats2.png
Binary file added Source/Level_Icons/mech1.png
Binary file added Source/Level_Icons/mech2.png
Binary file added Source/Level_Icons/mech3.png
Binary file added Source/Level_Icons/mech4.png
Binary file added Source/Level_Icons/mech5.png
Binary file added Source/Level_Icons/robo1.png
7 changes: 7 additions & 0 deletions Source/courses.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
label,course,description,max,dependencies,xrange
mech,Mechanical Prototyping,Learn techniques for mechanical design... and how to not kill your teammates,5,3bees1 4focs3 4elec2 5mats1,841
bees,Sustainable Beekeeping,Beekeeping. Good for the environment. Ben Linder. Good for the soul.,3,2focs1 3mats2,51
focs,Fundamentals of Computer Science,Step one:FOCS. Step two:Offical Hacker d00d. Step 3:Rule the world.,3,3elec1,367
elec,Electricity and Magnetism,Does anyone know how electricity and magnetism work?,2,0,209
mats,Material Science,Material science. Explore materials. Self-explanatory...right?,2,0,683
robo,Fundamentals of Robotics,Death by Dave but in a project-based-learning way.,1,2mech5 2bees3 2focs3 2elec2 2mats2,525
75 changes: 75 additions & 0 deletions Source/courses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Author: Isa Blancett
# Project: Interactive Programming
# Date: 10.30.2017
# Description: Class for reading in a csv file containing course information and
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job with the header comments on the files!

# creating and instance for each course
# Acknowledgements: Script structure is modeled after Transcriptase's Game
# repository on Git

import csv

class Courses(object):
""" class for the different course options the user can choose from

contains:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job explaining what all of these are. An extra step you could do is specifically write what type these will end up being (ie: string, int, etc..). It's not necessary for this project, but it's good practice when you're making data structures like these.

label - 4 letter id
course - full title
description - in-depth summary of course
max - total number of levels
reqs - dependencies, '%s%s%s' % (effected level, needed course, needed level)
lvl - current level
order - order picked by user
"""

def setup(self, config):

self.config = config
self.label = config['label']
self.name = config['course']
self.description = config['description']
self.max = config['max']
self.reqs = config['dependencies']
self.range = config['xrange']
self.lvl = 0
self.order = 0



def create_course(config):
""" creates a single instance of a course given a config dictionary

returns: single course instance
"""

new_course = Courses()
new_course.setup(config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider changing Courses.setup to Courses.__init__, and changing these two lines to new_course == Courses(config).

The principles are:

  • Code that requires the client to perform a sequence of calls in order is fragile.
  • Reduce the amount of time that an object is in an unusable state. It doesn't make sense to use new_course after Course() and before new_course.setup(…), so shrink the period during which the class is exposed in this state.
  • Make it impossible (or harder) for the client of a class or module to mis-use it.

This principles all come to the same thing here; I'm listing them as separate principles because they're all good design principles, and they don't always apply to the same situations.

In this case, replacing Courses.setup by Courses.__init__ allows you to remove create_course entirely, and replace calls to create_course(config) by Courses(config).

return(new_course)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return is a statement, not a function; the parentheses aren't necessary (or idiomatic).


def populate():
""" sets up item objects by creating a config dictionary for each one

Sample config dictionary (can be copied for each new item):
config = {
'label':'LABEL'
'course':'COURSE TITLE',
'description':'DESCRIPTION',
'max': NUMBER OF LEVELS,
'dependencies': 'LVL' + 'NEEDEDCOURSE' + 'NEEDEDLEVEL',
'xrange': 'MIN MAX'
}

returns: dictionary of all course instances
"""
all_courses = {}

f = open('Source/courses.csv', 'r')
reader = csv.DictReader(f)

for row in reader:
if row != '0':
row['dependencies'] = row['dependencies'].split()
else:
row['dependencies'] = []
new_course = (create_course(row))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outer parens aren't necessary

all_courses[new_course.label] = new_course
return all_courses
96 changes: 96 additions & 0 deletions Source/ending.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Author: Siena Okuno
# Project: Interactive Programming
# Date: 10.30.2017
# Description: Determines endings

import pygame
import sys

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if these functions could be put into the GamePlay class. They seem to be important parts of it. Rather than importing into the file, adding them to the class makes more sense

def screenScroll(screen, color):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python convention is screen_scroll.

'''Turns screen a color by filling in with rectangles.'''
for i in range(700):
pygame.draw.rect(screen, color, (0,i,1000,i+1))
i+=1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The i+=1 line doesn't do anything, since the next time through the loop resets i

pygame.display.flip()


def ending(victory, levels, screen):
'''Creates basic, text-only ending'''
font50 = pygame.font.Font(None, 50)
font20 = pygame.font.Font(None, 20)
if victory == 0 or victory == 2:
screenScroll(screen, (0,0,0))
screen.blit(font50.render("Looks like your portfolio", 1, (255,255,255)), (300, 250))
screen.blit(font50.render("could use some improvement", 1, (255,255,255)), (280, 350))
Done = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention for variables is lowercase.

while not Done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
Done = True
for i in range(len(levels)):
screen.blit(font20.render(levels[i], 1, (200,200,200)), (100, 450+i*25))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also use:

for i, level in enumerate(levels):
    screen.blit(font20.render(level, 1, (200,200,200)), (100, 450+i*25))

pygame.display.flip()
if victory == 1:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like victory is used a boolean? If so, prefer the boolean type: True/False, instead of 1/0. This is clearer in intent.

screenScroll(screen, (255,255,255))
Done = False
while not Done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
Done = True
screen.blit(font50.render("Good job!", 1, (0,0,0)), (450, 250))
screen.blit(font50.render("You're the ultimate Oliner!'", 1, (0,0,0)), (300, 350))
screen.blit(font20.render('All course levels maxed. :)', 1, (0,0,0)), (450, 500))
pygame.display.flip()
pygame.event.pump()

#not implemented yet
def graduation():
'''Shows graphics for graduating. Used in all endings'''
screenScroll(screen, (255,255,255))
font100 = pygame.font.Font(None, 100)
screen.blit(font100.render("Congratulations,", 1, (0,0,0)), (200, 175))
screen.blit(font100.render("Olin Grad!", 1, (0,0,0)), (325, 325))
grad_hat = pygame.transform.scale(pygame.image.load('Ending_pics/grad_hat.png'), (250, 200))
screen.blit(grad_hat,(350,400))
pygame.display.flip()
pygame.time.delay(2000)
screenScroll(screen, (255,255,255))
font50 = pygame.font.Font(None, 50)
screen.blit(font100.render("You got your degree...", 1, (0,0,0)), (150, 300))
pygame.display.flip()
pygame.time.delay(2000)
screenScroll(screen, (0,0,0))
screen.blit(font100.render("But how will you fair", 1, (255,255,255)), (150, 300))
screen.blit(font100.render("in the real world?", 1, (255,255,255)), (170, 400))
pygame.display.flip()
pygame.time.delay(2000)


def badEnding():
'''Shows graphics for bad ending. Called when average is below ___.
You tried? Desk jobs are all the rage these days.'''



def middleEnding():
'''Shows graphics for middle ending. Called when average is above ___ but levels are not maxed.
You are a leading engineer at your own startup'''



def goodEnding():
'''Shows graphics for good ending. Called when levels are all maxed.
You are the next Steve Jobs.'''


def determine(victory, levels):
'''Determines ending.
Victory is value 0, 1, or 2. 0 is bad, 2 is perfect.
Levels is a list of strings. Print out with for loop'''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For code that documents itself without as many explicit docstrings and comments, consider:

BAD_OUTCOME = 'bad'
MIDDLE_OUTCOME = 'middle'
PERFECT_OUTCOME = 'perfect'if victory == MIDDLE_OUTCOME:
       …

This has the advantages that it's easy to see the intent each place the value is used, without having to find the nearest comment that describes it; that you don't need to repeat comments in each function that generates or uses these values (admittedly, not that many places in this example); that printing out victory is more helpful even if you've forgotten what represents what; and that you're better protected against a certain class of errors, for example using 4 as a victory value.

graduation()
if victory == 0:
badEnding()
if victory == 2:
middleEnding()
if victory == 1:
goodEnding
Loading