Loading...
Hello, I'm Mrs. Holborow, and welcome to Computing.
I'm so pleased you've decided to join me for the lesson today.
In today's lesson, we're going to be using our knowledge of dictionaries to create a battle boats game.
Welcome to today's lesson from the unit "Dictionaries and data files." This lesson is called "Programming project - dictionaries II." And by the end of today's lesson, you'll be able to implement and evaluate a solution using success criteria.
Shall we make a start? We will be exploring these keywords throughout today's lesson.
Code log, code log, a document that you can use when developing a programme to keep track of your progress throughout the project.
Success criteria, success criteria, specific, measurable, and realistic benchmarks used to determine if a project, task, or outcome has been accomplished successfully.
Evaluation, evaluation, judging how well the programme meets the original success criteria or requirements.
Look out for these keywords throughout today's lesson.
Today's lesson is broken down into two parts.
We'll start by implementing a solution using success criteria.
We'll then move on to evaluate a solution using success criteria.
Let's make a start by implementing a solution using success criteria.
Battle boats is a turn-based strategy game where players eliminate their opponent's fleet of boats by firing at a location on a grid to try and sink them.
The first player to sink all of their opponent's battle boats is declared the winner.
Each player has two eight-by-eight grids.
One grid, which is shown in Figure 1, is used for their own battle boats.
And the other, Figure 2, is used to record any hits or misses from firing at their opponent's battle boats.
At the beginning of the game, players decide where they wish to place their fleet of five battle boats, which can be shown on Figure 1 with the letter Bs.
During gameplay, players take it in turns to fire at a location on their opponent's grid.
They do this by stating the coordinates of their target.
If a player hits their opponent's boat, then this is recorded as a hit.
If they miss, this is recorded as a miss.
So we can see, H2 has been recorded as a hit, and A3 has been recorded as a miss.
The game ends when a player's fleet of boats have been sunk.
The winner is the player with boats remaining at the end of the game.
You have been asked to design a battle boats game where the user plays against the computer to try and sink its fleet of boats.
Time to check your understanding.
The battle boats game should end when, A, a player's boat has been sunk, B, a player's fleet of boats has been sunk, or C, both players' fleets of boats have been sunk.
Pause the video whilst you have a think.
Did you select B? Well done.
The battle boats game should end when a player's fleet of boats have been sunk.
This code displays the grid for the game tic-tac-toe, or you may know it as noughts and crosses.
So you can see we have a subroutine called display_grid.
We then have player_grid, which is set up with question marks because the players haven't played their game yet.
You can see the sample text output from this programme with the lines indicating the grid and the question marks indicating where the player can place their nought or cross.
If the player wanted to place an X in the top left-hand corner of the grid, which element would they need to access? Is it A, grid[1][0], B, grid[0][1], or C, grid[0][0].
Pause the video whilst you have a think.
Did you select C? Well done.
grid[0][0] would be the top left corner of the grid because remember, indexing starts at 0.
A code log is a document that you can use when developing a programme to keep track of your progress throughout the project, decisions that you have made and why, problems that you have come across and how you've solved them, test results that show your programme works correctly.
Here's a sample template of a code log.
So we have space to add screenshots of your code or programme.
We then have some sample questions.
What worked well for you today? What was challenging for you today? And what are your next steps? For task A, I'd like you to use the success criteria you've developed to implement your solution for the battle boats game.
Note, if you don't have any success criteria, then you can use the scenario provided to check your solution meets the requirements, and this is added as an additional material for today's lesson.
For part 2, I'd like you to record your progress in your code log.
Again, a template for this is provided as additional material for today's lesson.
Pause the video here whilst you go and implement your solution.
How did you get on? Did you manage to implement some of your solution and document your progress in your code log? Well done.
Let's have a look at Izzy's sample code log together.
So, Izzy has a screenshot of her subroutine for the menu.
Izzy says, "I found it fairly easy to create the subroutine for the menu." For Izzy's next steps, Izzy says, "My next step is to create the subroutine for the instructions." Did you have something similar in your code log? Remember, if you need to go back and add any detail or any screenshots, you can do that now.
Okay, so we've implemented a solution using success criteria.
We're now going to move on to evaluate a solution using success criteria.
Evaluation happens after the programme has been made and tested.
It's about judging how well the programme meets the original success criteria or requirements.
It answers the question "How successful is my programme?" Izzy says, "Why do I need to evaluate my programme?" Maybe pause the video here whilst you think about Izzy's question.
It's important to evaluate your programme because you can see if your programme solves the problem, you can identify improvements or changes that may need to be made, and you can check how efficient, user-friendly, and reliable your programme is.
Some useful questions or prompts for evaluation are: Does the programme work as expected? Does the programme meet the original success criteria? Is it easy to use? Is it efficient, fast, and not using too much memory? Is the code readable and well structured? Have you used white space, for example? And could it handle unexpected inputs or errors? Izzy has created a quiz programme in Python.
She is using What Went Well, or WWW, and Even Better If, or EBI, to evaluate her programme.
So, Izzy's What Went Well are it asks the user five questions, it keeps the score correctly, and it gives feedback at the end.
Izzy's Even Better If are add error handling for wrong input, randomise the question order, add a timer to challenge the user.
There's some really good development points there, Izzy, well done.
Time to check your understanding.
What is the primary purpose of conducting an evaluation of a computer programme that you have designed? Is it A, to identify and fix syntax errors in the code, B, to ensure the programme meets the original requirements, or C, to compare my programme with other students' work.
Pause the video whilst you have a think.
Did you select B? Well done.
The primary purpose of conducting an evaluation of a computer programme is to ensure the programme meets the original requirements.
Success criteria are the benchmarks that your project will need to meet in order for it to be a success.
The list of success criteria can be used to help you develop the programme.
It can also be used to help you complete the final testing and evaluation of your programme.
Fill in the blanks to complete the sentences.
Are the benchmarks that your project will need to meet in order for it to be a success.
They can also be used to complete the final of your programme.
Pause the video whilst you have a think.
How did you get on? Let's have a look at the sample answer together.
Success criteria are the benchmarks that your project will need to meet in order to be a success.
They can also be used to complete final testing of your programme.
Okay, we're moving on to our final task of today's lesson, and you've done a fantastic job so far, so well done.
We're going to evaluate a solution using success criteria.
So I'd like you to answer the following questions to complete an evaluation of your battle boats programme.
For part 1, does your programme work as expected? 2, does the programme meet the original success criteria? 3, is it easy to use? 4, is it efficient, fast, and not using too much memory? 5, is the code readable and well structured? 6, could it handle unexpected input or errors? Pause the video here whilst you complete your evaluation and answer the questions.
How did you get on? Did you manage to complete your evaluation? Well done.
Let's have a look at a couple of sections of evaluation together as a sample answer.
You were asked whether your programme worked as expected: The game works as expected.
The programme starts by displaying the menu and allows the user to play the game.
When the user selects "play game," they are prompted to enter the coordinates of their boats.
The programme then asks the user to guess the coordinates of one of the computer's boats and returns whether it was a hit or a miss.
The computer then takes a turn, and a hit or miss is recorded.
The player's grid is displayed after each round.
Once a player has hit all of the other player's boats, the game ends.
You were asked whether your programme meets the original success criteria: I think the programme meets the success criteria well.
It allows the player to play the game against the computer and correctly records hits and misses.
The only part where I think the programme does not quite meet the success criteria is when it generates target coordinates for the computer's turn.
The programme does randomly generate target coordinates, but it currently does not keep track of the target coordinates it has generated previously, so can randomly generate the same target coordinates more than once.
You were also asked whether your programme could handle unexpected input or errors: The programme does not handle unexpected input very well.
If the player enters target coordinates that do not exist, it just accepts this as an input and returns a miss.
It would be better if the programme had a function that handled user input for the coordinates and returned an error message if incorrect target coordinates were entered.
This could then prompt the player to enter correct target coordinates.
Did you have some similar responses for your evaluation? Remember, if you need to go back and add any detail to your answers, you can pause the video and do that now.
A sample battle boats programme can be found at oak.
link/battle-boats-solution.
Open and run the programme.
How does it compare to your programme? Could you use this solution to make any improvements to your programme or help to get your programme working? Let's go and have a look at the battle boats solution now together.
So I've opened the battle boats solution code.
Let's quickly have a look through the code, but I'm sure you can spend a bit more time looking through it carefully.
So, at the start, we have some libraries that we've imported, so we have from random import choice and from time import sleep.
We then have our first subroutine.
So we've got def menu, which is going to display the menu to the user.
So they have three options, 1 to start the game, 2 to resume the game, and then 3 for instructions.
We then have the subroutine to display the grid.
And then if we scroll down, we have the next subroutine, which allows the player to add their boats to their fleet grid.
And then we have the play subroutine, which creates a blank player grid.
And then we are adding the boats to the fleet grid and creating the opponent locations.
And then we're actually starting the game, okay? So we are looking at less than five casualties 'cause remember, the players have five boats each.
And we're displaying some text telling the user to enter the coordinates and recording the hit and the misses.
We've then got the part which allows the computer to take a turn.
And again, we record the hit and misses.
And then we've got the section of the programme which displays if the computer wins or you win.
And then we've got the coordinates section down here for the grid.
And we've got the bit that randomly selects the coordinates for the computer's fleet and the computer's target tracker.
We then have the instructions.
And then we're calling the menu at the bottom.
So let's run the programme and just see how it works.
So it starts with displaying the menu.
I'm going to enter 1.
Okay.
And you can see if I just scroll up a little bit, it's shown my player fleet grid, which is currently empty.
And it says to build your fleet by entering the coordinates for each boat.
So I'm going to put in a 1, so you can see the fleet grid has been populated now with a B to signify my boat in A1.
And I'm going to do B2, C3, D4, and E5 just to make it really simple, okay? So you can see if I just scroll up again there, I've got my boats all on my fleet grid.
I've then got my target tracker, okay, which is where I'm going to try and hit the computer's boats.
So I'm going to enter the first coordinates, so I'm gonna go for A1.
Oh, I've got a hit, okay? And now the computer is taking aim.
Oh no, the computer also got a hit, so it's a bit even.
Next one, I'm gonna do A2 this time.
Oh, that was a miss this time.
G8, but the computer misses as well.
And you can see each time either I play or the computer plays that a hit or miss is recorded.
I'm not gonna continue there 'cause it might take some time, but you can see how the programme is working.
Remember, you can always take some time to go and play the game a bit further and compare it to your own programme.
Okay, we've come to the end of today's lesson, "Programming project - dictionaries II." Let's summarise what we've learned together during today's lesson.
A code log is a document that you can use when developing a programme to keep track of your progress throughout the project and any decisions that you've made and why.
Success criteria are the benchmarks that your project will need to meet in order for it to be a success.
They can also be used to complete the final testing of your programme.
Evaluation happens after the programme has been made and tested.
It's about judging how well the programme meets the original success criteria or requirements.
I hope you've enjoyed today's lesson, and I hope you'll join me again soon, bye.