BYU logo Computer Science

To start this assignment, download this zip file.

The following guide pages cover material needed for this assignment:

Project 2 - Bit Problems

Inverting the World

Bit is in a world with a blue picture on a white background:

a large Y made up of white squares, every other square is blue, with bit in the bottom left corner

Invert the entire world. Blue should become white, and white should become blue. Bit should end in the lower right corner. The final world should look like this:

all colors are inverted, now a blue Y on a white background

There is a second world that looks like this:

a blue smiley face on a white background, bit in the bottom left corner

and when Bit is done it should look like this:

all colors inverted, now a white smiley face on a blue background

You can find starter code in invert.py.

Blue S

Move Bit to the right edge of the grid. Along the way, if Bit encounters a green square, draw a blue ā€œSā€. The bends in the ā€œSā€ are marked by blocked squares.

The first world looks like this:

bit starts in the middle row on the left side, in the same row are two green squares. Above and beneath each green square is an "s" shape marked by black squares.

and at the end should look like this:

two "s"s drawn with blue squares, where the green square used to be, bit ends on the right.

The second world looks like this:

bit on the left of the 5th row from the top, four green squares in the same row. Green squares are places to draw an "s", the shape of which is marked with black squares

four blue "s"s drawn where the green square used to be, bit ends on the right.

You can find starter code in blue_s.py.

Escape

Bit is exploring a cave and finds a secret gem that has been hidden for centuries:

Bit is on a colored square on the left, with blue squares behind and a path marked by black squares in front. A green column in front of a black column marks the end

Unfortunately, his enemies have started to flood the cave with water! Help Bit escape by (1) picking up the gem, (2) running through the cave, (3) climbing the moss-covered cliff at the end. The final world should look like this:

Bit is at the top of the cliff, represented with black squares, on the right, the square directly behind bit painted the same color as the starting square, and the path bit took painted blue, except for the green column.

The water has followed Bit as they run, and Bit has put down the gem to examine it.

There is a second world that looks like this:

A similar world, with bit starting on a colored square on the left, a path marked by black squares in front, and a green column in front of a black column marking the end.

and the at the end should look like this:

Bit is at the top of the cliff, represented with black squares, on the right, the square directly behind bit painted the same color as the starting square, and the path bit took painted blue, except for the green column.

Note that the gem may be a ruby (red) or an emerald (green).

You can find starter code in escape.py.

Pools of Gems

When Bit was examining the gem, they discovered a secret ingredient that lets them replicate gems. So Bit goes to their backyard, where there are a bunch of empty holes. Bit picks up a gem, then fills the next pool with copies of that same gem.

Note: There are many different colors of gems. You will need to write generic code that will work with any color.

One of the starting worlds looks like this:

Bit starts on the second row from the top on the left. The row beneath bit has black squares, with some sections having black squares in lower rows, creating empty sections. Colored squares are placed in bit's row before each empty section.

at the end, the world should look like this:

Bit ends on the right, with the colored squares in the same row painted white, and the empty sections beneath painted the color of the square that appeared before it.

The other starting world looks like this:

Bit starts on the second row from the top on the left. The row beneath bit has black squares, with some sections having black squares in lower rows, creating empty sections. Colored squares are placed in bit's row before each empty section.

at the end, the world should look like this:

Bit ends on the right, with the colored squares in the same row painted white, and the empty sections beneath painted the color of the square that appeared before it.

Manual Grading

The Quality Code guide page has good examples that may be useful to you as you decide whether to put code in functions or leave it outside a function as glue code.

Grading will be focused on decomposition of the problems into separate functions. In particular, you should identify repeated actions and use functions to represent those actions. For example, the top and bottom arms of blue_s are the same action.

Intent The intent of this project is for you to break problems into large pieces, write code that solves worlds of any size, and write generic functions that take multiple arguments.

Remember, nested while loops make your functions hard to read. Use additional functions to break the problem into readable, descriptive pieces.

RubricPoints
Whitespace5
Naming5
Decomposition20
Intent20
Total50

Grading

ActivityPoints
Inverting the World25 points
Blue S25 points
Escape25 points
Pools of Gems25 points