Why at all? This lab
introduces map
and gives practice in using HOFs to do interesting analysis. It also lays the groundwork for later strategy computation.
As a side benefit, this lab gives an opportunity to talk about how two very different solutions to the U2 TTT problem are interchangeable here provided they implement the same API, namely providing the board list.
Why here? This unit is about lists, HOFs, and functional programming, all of which are exercised in this lab. In particular, this lab replaces the former one with a page per HOF.
This very short page could possibly be combined with the next, to make a one-page lab, but there's a definite shift in focus between thinking about ties and thinking about wins.
Here is some of the critical teacher feedback (there was some positive feedback, but more like this):
In this lab, you will continue your Tic-Tac-Toe project from Unit 2 to make the program analyze the game board to detect wins and ties.
On this page, you'll prepare by allowing the program to record the moves that are made.
When you first wrote Tic Tac Toe, it was easy to detect illegal moves (moving to a square that's already wearing an X or O costume) because each sprite could test for that without knowing about the rest of the gameboard. But to detect wins and ties, the program needs a way to test the state of the whole gameboard, not just one individual piece. So, we'll use a global variable, , to keep track of whether the square in each position is empty or filled with an X or an O.
You learned about global variables on Unit 2 Lab 1 Page 3: Keeping Score with Global Variables.
Each sprite needs to know its own position on the board so that we can use the item of
block to replace that position with an X or an O. So, we'll create a sprite-local variable, , and each clone will have its own version of this variable.
You learned about script-local variables on Unit 2 Lab 1 Page 1: Developing a Number Guessing Game with Script Variables.
A sprite-local variable is like a global variable in that it doesn't belong to a particular script (as a script-local variable does), but it does belong to a particular sprite.
You learned about initializing variables on Unit 2 Lab 1 Page 1: Developing a Number Guessing Game with Script Variables.
You make a local variable similarly to how you make global variables: