KIPR · Botball Explorer
Activity Sections

Unit 4 · Big Idea 4

Keeping Score

Student Lab · A Full Red-Cube Run That Tracks Its Own Points

Unit Guiding Question
How can a machine know where it is and where it is going?
Big Idea
A Program Can Track Its Own Progress
AI Literacy Thread
Intelligent systems track their own and report what they have done.
CS1 Concepts
Accumulating · State · Console Output (f-strings) · Integration
Game Context
Stack the red cubes, then dock the — scoring as you go
What You Need
Explorer robot · your full · red cubes · pallet · dock · this lab sheet
Before you start: type your PIN in the box at the top of the page. Your teacher gave you this number. When you finish, press Submit & Download to turn in your work and save a copy.

Overview

Time to bring it all together. You’ll write a complete red-cube run that drives, squares up, stacks cubes, and docks the pallet — using every major tool in your library. But this run does something new: it keeps its own score. After each point-scoring maneuver, the program adds the points to a running total and prints a report of what it just did and where the score stands. By the end, your robot narrates its own competition run.

Core Insight

A single variable can hold a running total that grows as the program runs. Printing it after each step turns your robot into something that reports its own progress — exactly how real systems keep track of what they’ve accomplished.

By the end of this activity you will be able to:

  • Use a variable to accumulate a running score.
  • Print a status report with an f-string after each maneuver.
  • Combine your whole library into one complete scored run.
  • Read the real Botball point values for the maneuvers you complete.

Phase 1 — Concept: A Variable That Remembers

An accumulating variable holds a running total

You’ve used variables to store fixed values. Now you’ll use one that changes over time — a score that starts at zero and grows. The key line takes the score’s current value, adds points, and stores the result back:

score = 0        # start with no points
score = score + 9    # Add 9. The score is now 9.
score = score + 11   # Add 11. The score is now 20.

Read score = score + 9 as “make score equal to whatever it is now, plus 9.” The variable remembers its total between steps. This is called state — information the program carries as it runs.

Explain what score = score + 9 does. Why does the variable need to “remember” its old value to work?

Phase 2 — Concept: Reporting With print()

Print a message and the current score

You met print() when you printed your ticks_per_inch. Here you’ll use it to report each maneuver. To print a number inside a message, use an f-string: put an f right before the opening quote, then drop the variable inside curly braces { } wherever you want its value to appear:

print(f"Stacked first red cube. Score: {score}")

{score} gets replaced by the current value of score when the line runs. After your robot adds points, a line like this tells you exactly what happened and the new total.

What does the {score} inside an f-string do? Why is printing a report after each maneuver useful during a competition run?

Phase 3 — The Real Point Values

These are the actual Botball points for the maneuvers in your run. Each maneuver’s difficulty maps to a score — harder tasks are worth more.

Your run’s scoring maneuvers
ManeuverDifficultyPoints
Place 1st small red cube on the large red cube59
Place 2nd small red cube on the large red cube611
Place the pallet (with large red cube) on the dock611
Small red cube still on top when docked59

Perfect run total: 9 + 11 + 11 + 9 = 40 points

If your robot completed only the first two stacks but failed to dock, what would the score be? Show your addition.

Phase 4 — Plan the Run

Before coding, map your run as a list of actions and the points each scores. Think through the whole path: find the wall to reset, square up, drive and turn to the cubes, stack them, then move the pallet to the dock. Mark which library does each step.

#What the robot doesLibrary call(s)Points (if any)
1
2
3
4
5
6
7
8

You don’t need to score on every line — driving and turning set up the scoring maneuvers. Mark points only on the lines that actually score.

Phase 5 — Build: The Scored Run

Now write it. Start score at 0. Follow the do → score → report rhythm: run the maneuver with your library functions, add the points, then print the report. The skeleton below shows the structure and the scoring/reporting lines — you fill in the driving, turning, and stacking from your Phase 4 plan.

#!/usr/bin/python3

# Unit 4, Big Idea 4: Keeping Score

# Name: _______________________   Date: ___________

import os, sys
sys.path.append("/usr/lib")
import _kipr as k
from yourname import *     # your full library

def main():
    k.enable_servo(0)
    k.enable_servo(1)

    score = 0                          # running total starts at zero
    print(f"Run started. Score: {score}")

    # --- Reset to a known position ---
    back_until_pressed()                   # back into the wall to reset
    square_up()                             # straighten against the line

    # --- Drive/turn to the cubes (your plan) ---
    # Drive(...)  Turn(...)  as needed

    # --- SCORE: first small red cube on the large cube ---
    # move_arm(...) / move_claw(...) to make the stack
    score = score + 9                      # difficulty 5 = 9 points
    print(f"Stacked first red cube. Score: {score}")

    # --- SCORE: second small red cube ---
    # reposition + move_arm / move_claw
    score = score + 11                     # difficulty 6 = 11 points
    print(f"Stacked second red cube. Score: {score}")

    # --- SCORE: dock the pallet ---
    # Drive / Turn the pallet onto the dock
    score = score + 11                     # difficulty 6 = 11 points
    print(f"Pallet on the dock. Score: {score}")

    # --- SCORE: cube still on top when docked ---
    score = score + 9                      # difficulty 5 = 9 points
    print(f"Cube held on top. Final score: {score}")

main()

check

Your finished run must use all six: back_until_pressed, square_up, Drive, Turn, move_arm, and move_claw. Fill the planning blanks with real calls so each one appears.

Phase 6 — Run It and Read the Report

Run your program and watch the console. A perfect run prints a growing score, ending at 40. Here’s what a clean run looks like:

> Run started. Score: 0
> Stacked first red cube. Score: 9
> Stacked second red cube. Score: 20
> Pallet on the dock. Score: 31
> Cube held on top. Final score: 40

Your Run Log

TryWhat the console printed (final score)What worked / what you fixed
1
2
3
4

What final score did your run reach? If it was below 40, which maneuver fell short, and how did the printed report help you find it?

Phase 7 — Connect & Reflect

AI Literacy Thread

Intelligent systems track their own state and report what they have done.

Your robot didn’t just act — it kept track of its own progress and reported it. That’s everywhere in real systems. A delivery robot logs each package dropped; a game tracks your score; a fitness band counts your steps and tells you the total. Keeping a running state and reporting it is how machines stay accountable — to their users and to the people them. The printed log you built is exactly the kind of record engineers rely on to see what a system actually did, step by step.

Complete the reflection on your own.

1. How does an accumulating variable like score “remember” a running total as the program runs?

2. Why is printing a report after each maneuver helpful when something in the run goes wrong?

3. This run used your whole library. Name two functions you called and what each contributed to the run.

4. Complete in 2–3 sentences: “Intelligent systems track their own state and report what they have done. This means a well-built robot can tell you…”

Extension Challenges

Finished early? Try one or more of these.

Extension A — Use the Turn

  • Your Turn returns 1 for success. Only add points if a maneuver’s setup turn succeeded. How would you use the return value to protect your score?

Extension B — A Scoring Function

  • Write a helper like score_points(int current, int add) that adds points and prints the report in one call. Why might that be cleaner than repeating the two lines?

Extension C — Count Maneuvers Too

  • Add a second accumulating variable that counts how many maneuvers you completed. Print both score and count at the end.

Extension D — Time It

  • A real run has a time limit. How could you report points-per-second, or warn if the run is taking too long? Sketch the idea.

Extension E — One Combined Message

  • Right now your score report prints as several separate print lines. Build one combined summary with an f-string — for example, your score and maneuver count in a single sentence — before printing it in one call.
  • What’s one advantage of building one complete string before printing, instead of printing pieces as you go?

When you are finished, press the button to turn in your work and save a copy.

KIPR · Botball Explorer · Unit 4 Big Idea 4 — Student Lab