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 block Y

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

There is a second world that looks like this:

a large block Y

and when Bit is done it should look like this:

a large block Y

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:

places to make two "s"s

and at the end should look like this:

two "s"s

The second world looks like this:

places to make four "s"s

four "s"s

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 standing by a gem, with a cave passageway in front and water behind

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 standing at the top of the cliff, with the gem behind them

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:

Bit is standing by a gem, with a cave passageway in front and water behind

and the at the end should look like this:

Bit is standing at the top of the cliff, with the gem behind them

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 is at the start of a path, with gems and empty pools in front of them

at the end, the world should look like this:

Bit is at the end of a path, with pools all filled with gems

The other starting world looks like this:

Bit is at the start of a path, with gems and empty pools in front of them

at the end, the world should look like this:

Bit is at the end of a path, with pools all filled with gems

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