Challenge 5 - Grey Wolves - Nested Loops & Conditions

Loops Inside Loops

A nested loop is a loop inside a loop.

The "inner loop" will be executed one time for each iteration of the "outer loop"

What shape of wall will this build?

 A square with four sides of nine blocks.

The agent will build nine blocks, stepping one block forward each time, then turn right,

then it will build 9 more blocks in a row and turn right

then it will build 9 more blocks in a row and turn right

then it will build 9 more blocks in a row and turn right.

End.


Keep the Wolves away from the sheep.

You must work with a partner or in a three for this lesson. 

Activity 1: Secure the Chicken Coup

You will need to use more than 64 blocks of Wire to secure the chicken coup. So, if you look in the first repeat, there is a 'constant' re-fill of the wire into the Agent's inventory.

Solution

Activity 2: Moving the Sheep

Moving the sheep from one pasture to the other.

How are you going to move the sheep? What code do you need? What are the steps you need to take?

2.1 You must work with a partner on this mission. You need to talk the steps through to complete this.

2.2. You will need a board, pen and eraser to draw the steps though to compare the code to mine.

2.3. Look at my code. I think there is a mistake in the code. Once you have written you code and tested it, is it the same as mine or is it different?

Solution

Activity 3: Hazing

What is hazing?

Hazing is moving around the area to keep the wolves away from the sheep. It also means making noises to startle the wolves so that they move away when the bell goes off. 

3.1. How will you make the bells go off when a wolf goes near it? Can you use something to make the bell go off?

3.2. How does my code look? Are there any mistakes in it? Is your code neater or better?

Activity 4: Clearing the area

Wolves are sneaky.

Wolves will try to sneak up on the sheep to eat them.

You need to code the agent to remove the foliage around the area so that there is less of a chance of the sheep been eaten by the sneaky wolves.

4.1. There are a few ways to do this. You can check my code here to see if there is a better way of completing this task. 

Use a board, pen and eraser to draw out the plan and code it. Is yours better?

Learning Intention:

Can I solve problems with code?

Success Criteria

I can use conditions in my code

I can use loops in side loops (nested loops)

I can test and debug

I can Block-program in Microsoft MakeCode.

I can solve problems through coding.

I can share and support my classmates

Teacher Resources

Educator Guide