Create—Applications from Ideas: Sample Response A

Print this page
beginning of content:

Note: For information about the points this response earned, please see the Create Commentary (.pdf/66.6KB).

1. Video

Submit one video in .mp4, .wmv, .avi, or .mov format that demonstrates the running of at least one significant feature of your program. Your video must not exceed 1 minute in length and must not exceed 30MB in size.

The video presented is a sample submission from a student and may not contain any audio. User-submitted descriptions are provided below, describing the purpose and functionality of the content depicted in the video.

2. Written Responses

Submit one PDF file in which you respond directly to each prompt. Clearly label your responses 2a–2d in order. Your response to all prompts combined must not exceed 750 words, exclusive of the Program Code.

Program Purpose and Development

2a. Provide a written response or audio narration in your video that:

  • identifies the programming language;
  • identifies the purpose of your program; and
  • explains what the video illustrates.

(Approximately 150 words)

Sample response to 2a:

My program is a choose-your-own adventure game. I wrote this game in Python using the CodeSkulptor development environment to write the code. The purpose of my program is to have the user play a small choose-your-own adventure game in which they can pick several options for their path, which can either end in death, a happy life, or a return to the beginning to start all over again. The video illustrates the mechanics of the game, like the HP system, buttons, and text display. It also outlines the storyline of the game and the many paths that a player may take while playing it. In addition, the video demonstrates smaller features like the randomly selected enemy in the fight path.

2b. Describe the incremental and iterative development process of your program, focusing on two distinct points in that process. Describe the difficulties and/or opportunities you encountered and how they were resolved or incorporated. In your description clearly indicate whether the development described was collaborative or independent. At least one of these points must refer to independent program development.

(Approximately 200 words)

Sample response to 2b:

I encountered several difficulties while writing the code for this program. One of the first difficulties was setting up the code so that I could change the number of buttons and the text on them every time the user made a decision. The SimpleGUI module I used to create my game in Python only allows you to add buttons, not delete them, so to make sure the correct number of buttons is displayed at each step, I had to design the program so that it created a new frame for each separate step, instead of just being able to add or delete problems in the same window. I also had issues making sure that the HP bar updated properly even though the program was set up to check the HP value and change it if necessary every time the draw handler function ran, it didn't always work. As such, I had to create functions for increasing and decreasing the amount of HP instead of simply changing the variables within the other functions to ensure that the correct variables were being changed at the right time and that both the number on the screen and the size of the bar would change when the amount of HP changes.

2c. Capture and paste the program code segment that implements an algorithm (marked with an oval in section 3 below) that is fundamental for your program to achieve its intended purpose. Your code segment must include an algorithm that integrates other algorithms and integrates mathematical and/or logical concepts. Describe how each algorithm within your selected algorithm functions independently, as well as in combination with others, to form a new algorithm that helps to achieve the intended purpose of the program.

(Approximately 200 words)

Sample response to 2c:


def fight_beasts():
  global step4, step5, planb
  step4 = False
  step5 = True
  planb = True
  schrodinger()
  buttons(frame)

I chose this algorithm because it is important as it handles what happens when the player in the adventure game fights beasts. When you fight beasts, first you need to change the variables that update which place you are in the game, by using True and False. Then you have the fight, and then you reset the frame's buttons.

The algorithm schrodinger() shown below is integrated into the above algorithm. The algorithm schrodinger() is called to determine whether the player lives (deathpick == False), with your health points decreased by 25 percent, or dies and then your health points are set to 0 and a corresponding message appears.


def schrodinger():     
global death,deathpick 
    deathpick = random.choice(death) 
    if deathpick == False: 
        hp_percent(False,25) 
        text_set("Return with a ", beastpick +" "+ random.choice(beast_item)+ ".") 
    elif deathpick == True and (hp == 0 or hp <0): text_set(you hp_minus(hp) 
elif true and ! have,died.) (hp deathpick 0 hp ="=">0): 
        hp_minus(hp) 
        text_set("You have","died.") 

The algorithm buttons(frame) shown below is another integrated algorithm that resets the frame buttons using the buttons() function, which determines how many buttons the game should have next, what they should say, and what function each button should call based on the current state of the game. Both of these algorithms (schrodinger() and buttons(frame)) are noteworthy algorithms that are integrated in the main algorithm in order to make fighting beasts possible in the adventure game.


def buttons(frame):
  if step1 == True:
     button1 = frame.add_button("Start your journey", startpage, 50)
  if step2 == True:
     new_2_button(frame,"Take the left path", left_1,"Take the right path",right_1)
  if step3 == True and planb == False and left == False:
     new_2_button(frame,"Follow a tiny trail.",trail,"Follow a unicorn.",wiz)
  if step3 == True and planb == False and left == True:
     new_1_button(frame,"Stay for a few days.",camp)
  if step3 == True and planb == True and left == True:
     new_2_button(frame,"Explore the depths.", entercave,"Find a campsite.",camp)
  if step4 == True and planb == False and left == True:
     new_1_button(frame,"Continue on.",wiz)
  if step4 == True and planb == True and left == True:
     new_2_button(frame,"Fight the " + beastpick + ".", fight_beasts,
	 "Escape in fear.",camp)
  if step4 == True and planb == False and left == False:
     new_2_button(frame,"Join the fairies in the forest.",fairies,"Return home at your 
	 normal size.",goback)
  if step5 == True and planb == True and deathpick == False and left == True:
     new_1_button(frame,"Return to the village with your spoils.", goback)
  if (step5 == True and planb == True and deathpick == True and left == True and hp == 0)
  or hp == 0:
     new_1_button(frame,"Start over", restart)
  if step5 == True and planb == True and deathpick == True and left == True and hp != 0:
     new_1_button(frame,"Escape",camp)
  if step6 == True and planb == True and left == False:
     new_2_button(frame,"Become the wizard's disciple.",disciple ,"Return with little 
	 knowledge of magic.", goback)
  if step7 == True and planb == True and left == False:
     new_1_button(frame,"Return to spread magical knowledge.",goback) 
  if end == True:
     no_button(frame)

2d. Capture and paste the program code segment that contains an abstraction you developed (marked with a rectangle in section 3 below). Your abstraction should integrate mathematical and logical concepts. Explain how your abstraction helped manage the complexity of your program.

(Approximately 200 words)

Sample response to 2d:


def new_1_button(frame,text,function): 
    frame.stop() 
    frame = simplegui.create_frame('CYOA', FRAMEWIDTH,FRAMEHEIGHT) 
    hp_color() 
    frame.set_draw_handler(draw_handler) 
    frame.set_canvas_background('white') 
    frame.start() 
    frame.add_button(text, function) 
def new_2_button(frame,text_1,func_1,text_2,func_2): 
    frame.stop()     
hp_color() 
    frame = simplegui.create_frame('CYOA', FRAMEWIDTH,FRAMEHEIGHT) 
    frame.set_draw_handler(draw_handler) 
    frame.set_canvas_background('white') 
    frame.start() 
    frame.add_button(text_1,func_1) 
    frame.add_label("              ") 
    frame.add_button(text_2,func_2) 
def no_button(frame): 
    frame.stop() 
    frame = simplegui.create_frame('CYOA', FRAMEWIDTH,FRAMEHEIGHT) 
    hp_color() 
    frame.set_draw_handler(draw_handler) 
    frame.set_canvas_background('white') 
    frame.start() 
 
def buttons(frame): 
    if step1 == True: 
        button1 = frame.add_button("Start your journey", startpage, 50) 
    if step2 == True: 
        new_2_button(frame,"Take the left path", left_1,"Take the right path",right_1) 
    if step3 == True and planb == False and left == False: 
        new_2_button(frame,"Follow a tiny trail.",trail,"Follow a unicorn.",wiz) 
    if step3 == True and planb == False and left == True: 
        new_1_button(frame,"Stay for a few days.",camp) 
    if step3 == True and planb == True and left == True: 
        new_2_button(frame,"Explore the depths.", entercave,"Find a campsite.",camp) 
    if step4 == True and planb == False and left == True: 
        new_1_button(frame,"Continue on.",wiz)  
    if step4 == True and planb == True and left == True: 
        new_2_button(frame,"Fight the " + beastpick + ".", fight_beasts,"Escape in fear.",
		camp) 
    if step4 == True and planb == False and left == False: 
        new_2_button(frame,"Join the fairies in the forest.",fairies,"Return home at your 
		normal size.",goback) 
    if step5 == True and planb == True and deathpick == False and left == True: 
        new_1_button(frame,"Return to the village with your spoils.", goback) 
    if (step5 == True and planb == True and deathpick == True and left == True and hp == 0) 
	or hp == 0: 
        new_1_button(frame,"Start over", restart) 
    if step5 == True and planb == True and deathpick == True and left == True and hp != 0: 
        new_1_button(frame,"Escape",camp) 
    if step6 == True and planb == True and left == False: 
        new_2_button(frame,"Become the wizard's disciple.",disciple ,"Return with little 
		knowledge of magic.", goback) 
    if step7 == True and planb == True and left == False: 
        new_1_button(frame,"Return to spread magical knowledge.",goback)     
if end == True: 
        no_button(frame) 

This code implements a large amount of abstraction because it condenses code pieces that are essential to the program into single functions and then calls those with the function buttons. All of the buttons in this program are set by functions called new_1_button, new_2_button, or no_button that contain all of the code required to start a new frame with that number of buttons. For each of these functions, it takes 69 lines of code to reset the frame, set its initial conditions properly, and add the new buttons with the required text. This code manages complexity well because it makes it easier to edit the code used to create the buttons because it does not need to be edited for every single condition of the buttons function. The buttons function is also an abstraction because it condenses all of the logic necessary to determine the current stage of the game into one function that can be called to check all possible cases at any point in the game where it is necessary, in addition to containing instances of abstractions. Again, this significantly condenses the program code and made it easier to create a large function because all the code to run it only needed to be edited in one place.

3. Program Code

Capture and paste your entire program code in this section.

  • Mark with an oval the segment of program code that implements the algorithm you created for your program that integrates other algorithms and integrates mathematical and /or logical concepts.
  • Mark with a rectangle the segment of program code that represents an abstraction you developed.
  • Include comments or citations for program code that has been written by someone else.

Sample response to 3:

import simplegui | import random | FRAMEWIDTH = 500 | FRAMEHEIGHT = 300 |  | frame = simplegui.create_frame('CYOA', FRAMEWIDTH,FRAMEHEIGHT) | hp=100 | hp_topleft = (FRAMEWIDTH 105,5) | hp_bottomleft = (FRAMEWIDTH 105,25) | hp_br = ((FRAMEWIDTH 105)+ | hp,25) | hp_tr = ((FRAMEWIDTH 105) | + hp,5) | hp_num = 'HP: ' + str(hp) | step1 = True | step2 = False | step3= False | step4 = False | step5 = False | step6 = False | step7 = False | planb = False | left = False | end = False | death = [False,True] | text1 = 'Welcome to Choose' | text2 = 'Your own Adventure.' | beast_list = ['dragon', 'beast', 'monster'] | beast_item = ['egg', 'scale', 'horn'] | beastpick = random.choice(beast_list) | deathpick = False | barcolor = 'green' |  | def hp_add(number): |   global hp, hp_num |   if (hp + number < 100): |       hp +=number |   else: |       hp = 100 |   hp_num = 'HP: ' + str(hp) |  | def hp_minus(number): |   global hp, hp_num |   if (hp number>0): |       hp = number |   else: |       hp = 0 |   hp_num = 'HP: ' + str(hp) | def hp_percent(boolean,num): |   if boolean == True: |       hp_add(int(hp*(.01*num))) |   elif boolean == False: |       hp_minus(int(hp*(.01*num))) |  | def hp_color(): |   global hp, barcolor, hp_br, hp_tr |   if hp >=75 and hp <=100: |      barcolor = 'green' |      hp_br = ((FRAMEWIDTH - 105) + hp,25) |      hp_tr = ((FRAMEWIDTH - 105) + hp,5) |   elif hp <75 and hp >=50: |      barcolor = 'lime' |      hp_br = ((FRAMEWIDTH - 105) + hp,25) |      hp_tr = ((FRAMEWIDTH - 105) + hp,5) |   elif hp <50 and hp >=25: |      hp_br = ((FRAMEWIDTH - 105) + hp,25) |      hp_tr = ((FRAMEWIDTH - 105) + hp,5) |      barcolor = 'gold' |   elif hp <25 and hp >=0: |      barcolor = 'red' |      hp_br = ((FRAMEWIDTH - 105) + hp,25) |      hp_tr = ((FRAMEWIDTH - 105) + hp,5) |   elif hp >100: |      while hp >100: |        hp_minus(1) |      hp_br = ((FRAMEWIDTH - 105) + hp,25) |      hp_tr = ((FRAMEWIDTH - 105) + hp,5) |      hp_color() |   elif hp <0: |      while hp <0: |        hp_add(1) |      hp_br = ((FRAMEWIDTH - 105) + hp,25) |      hp_tr = ((FRAMEWIDTH - 105) + hp,5) |      hp_color() | def text_set (line1,line2): |   global text1,text2 |   text1= line1 |   text2= line2 |  | def startpage(): |   global step1,step2 |   step1 = False |   step2 = True |   buttons(frame) |   text_set('You start in','the Village.') |  | def left_1(): |   global step2,step3, planb, left |   hp_minus(1) |   step2 = False |   step3 = True |   planb=True |   left = True |   buttons(frame) |   text_set('You stumble','upon a cave.') | def right_1(): |   global step2,step3,left |   hp_minus(25) |   step2 = False |   step3 = True |   left = False |   buttons(frame) |   text_set('You enter a','majestic forest.') |  | def camp(): |   global step3, step4,planb |   hp_percent(True,3) |   step3 = False |   step4 = True |   planb = False |   buttons(frame) |   text_set('Camp in a clearing','for four days.') |  | def entercave(): |   global step3, step4, planb |   step3 = False |   step4 = True |   planb = True |   hp_percent(False,27) |   buttons(frame) |   text_set('You are approached', 'by a vicious ' + beastpick + '.') | def trail(): |   global step3, step4, planb |   step3 = False |   step4 = True |   planb = False |   hp_percent(False,12) |   buttons(frame) |   text_set('You encounter a','town of fairies. ') | def schrodinger(): |   global death,deathpick |   deathpick = random.choice(death) |   if deathpick == False: |      hp_percent(False,25) |      text_set('Return with a ', beastpick +' '+ random.choice(beast_item)+ '.') |   elif deathpick == True and (hp == 0 or hp <0): |      hp_minus(hp) |      text_set('You have','died.') |   elif deathpick == True and (hp != 0 and hp >0): |     hp_minus(hp) |     text_set('You have','died.') |  | def fight_beasts(): |   global step4, step5, planb |   step4 = False |   step5 = True |   planb = True |   schrodinger() |   buttons(frame) | def wiz(): |   global step5,step6,planb,left |   step5 = False |   step6 = True |   planb = True |   left = False |   hp_percent(True, 90) |   buttons(frame) |   text_set('You meet a','wise old wizard.') | def disciple(): |   global step6,step7,planb |   step6 = False |   step7 = True |   planb = True |   buttons(frame) |   text_set('You gain extensive', 'magical knowledge.') | def fairies(): |   global end, step4 |   step4 = False |   end = True |   buttons(frame) |   text_set('Have','fun!') | def restart(): |   global step1,step2,step3,step4,step5,step6,step7,planb,deathpick,hp,beastpick,end,stay |   hp_add(101) |   step1 = False |   step2 = True |   step3 = False |   step4 = False |   step5 = False |   step6 = False |   step7 = False |   planb = False |   deathpick = False |   left = False |   end = False |   stay = False |   beastpick = random.choice(beast_list) |   text_set('You start in','the Village.') |   buttons(frame) | def goback(): |   global step1,step2,step3,step4,step5,step6,step7,planb,deathpick,hp,beastpick,end,stay |   step1 = False |   step2 = True |   step3 = False |   step4 = False |   step5 = False |   step6 = False |   step7 = False |   planb = False |   deathpick = False |   left = False |   end = False |   stay = False |   beastpick = random.choice(beast_list) |   text_set('You start in','the Village.') | def new_1_button(frame ,text,function): |   frame.stop() |   frame = simplegui.create_frame('CYOA', FRAMEWIDTH,FRAMEHEIGHT) |   hp_color() |   frame.set_draw_handler(draw_handler) |   frame.set_canvas_background('white') |   frame.start() |   frame.add_button(text, function) | def new_2_button(frame,text_1,func_1,text_2,func_2): |   frame.stop() |   hp_color() |   frame = simplegui.create_frame('CYOA', FRAMEWIDTH,FRAMEHEIGHT) |   frame.set_draw_handler(draw_handler) |   frame.set_canvas_background('white') |   frame.start() |   frame.add_button(text_1,func_1) |   frame.add_label(' ') |   frame.add_button(text_2,func_2)  | def no_button(frame): |   frame.stop() |   frame = simplegui.create_frame('CYOA', FRAMEWIDTH,FRAMEHEIGHT) |   hp_color() |   frame.set_draw_handler(draw_handler) |   frame.set_canvas_background('white') |   frame.start() | def cyoa(canvas): |   hp_color() |   canvas.draw_text(text1,(FRAMEWIDTH/4,FRAMEHEIGHT/2),30,'black') |   canvas.draw_text(text2,((FRAMEWIDTH/4),(FRAMEHEIGHT/2)+40),30,'black') | def death1(): |   global hp |   if hp == 0: |      text_set('You have','died.') |  | def buttons(frame): |   if step1  == True: |      button1 = frame.add_button('Start your journey', startpage, 50) |   if step2 == True: |      new_2_button(frame,'Take the left path', left_1,'Take the right path',right_1) |   if step3 == True and planb == False and left == False: |      new_2_button(frame,'Follow a tiny trail.',trail,'Follow a unicorn.',wiz) |   if step3 == True and planb == False and left == True: |      new_1_button(frame,'Stay for a few days.',camp) |   if step3 == True and planb == True and left == True: |      new_2_button(frame,'Explore the depths.', entercave,'Find a campsite.',camp) |   if step4 == True and planb == False and left == True: |      new_1_button(frame,'Continue on.',wiz) |   if step4 == True and planb == True and left == True: |      new_2_button(frame,'Fight the ' + beastpick + '.', fight_beasts,'Escape in fear.', |    camp) |   if step4 == True and planb == False and left == False: |      new_2_button(frame,'Join the fairies in the forest.',fairies,'Return home at  |           your normal size.',goback) |   if step5 == True and planb == True and deathpick == False and left == True: |      new_1_button(frame,'Return to the village with your spoils.', goback) |   if (step5 == True and planb == True and deathpick == True and left == True and hp == 0) |   or hp == 0: |      new_1_button(frame,'Start over', restart) |   if step5 == True and planb == True and deathpick == True and left == True and hp != 0: |      new_1_button(frame,'Escape',camp) |   if step6 == True and planb == True and left == False: |      new_2_button(frame,'Become the wizard's disciple.',disciple ,'Return with little  |  knowledge of magic.', goback) |   if step7 == True and planb == True and left == False: |      new_1_button(frame,'Return to spread magical knowledge.',goback)  |   if end == True: |      no_button(frame) |  | buttons(frame) |  | def draw_handler(canvas): |   global barcolor,hp_br,hp_tr |   canvas.draw_polygon([hp_topleft, hp_bottomleft, hp_br, hp_tr], 3, barcolor, barcolor) |   canvas.draw_text(hp_num,(FRAMEWIDTH150,20),12, barcolor) |   cyoa(canvas) |   death1() | frame.set_draw_handler(draw_handler) |  | frame.start() | frame.set_canvas_background('white')