Purposeful Behaviour

Introduction

For this fortnight 2, we had a guest speaker Mark Thomson – the Research Director from the Institute of Backyard Studies, who came into our class with a box of amazing artefacts, including Henry Hoke’s wooden magnet and gave us his book about The Lost Tool of Henry Hoke. I was so excited when we’re given the task to build something using anything available on the table. Somehow our group came up with this “spy” device called Tasmanian Separatist Sentiment Sensor (TSSS) and the story to tell. Fantastic team work! I had so much fun recycling old unused materials and turn them into something different and hopefully can be useful or at least can be displayed as an art/decoration. 

TurtleBot

I was super excited that I get to play with the TurtleBot. Our team (Jake, Chloe, Adrian, Erika and myself) had the role of iterating. We did the split strategy to work out a couple of iterations. The first one didn’t quite work as we expected when we tested it because the move in the actual field wasn’t perfectly squared or 90-degree angle each time the sensors bumped as we predicted in our codes. So we updated the codes for our second iteration and tested it again straight away, and it worked! We made the TurtleBot find the way to the end of the maze yay!

The TurtleBot
TurtleBot Code
Happy TurtleBot

The Process

For this fortnight 2 homework, we were asked to create an agent to play Tic Tac Toe. I tried to make the winning agent by using the if statement and identified the 8 possible winning positions per the engine.py file. The result showed that my agent wins more than losses, so I was pretty happy with the output. But when I tested my code by playing a game against my agent, I won, and my agent lost on the first game. I should be happy, but I was disappointed to see how my agent behaviour was not expected based on the codes that I thought I wrote the strategy correctly. So, I tried to implement a different strategy into my code, and I played the second game against my agent. I was so surprised that my agent can beat me but not only winning the game but also blocking my winning move, so happy days! 

First game:

It’s really interesting to see the difference between what I thought in my mind when I wrote the code with the way of the Tic Tac Toe system actually worked on the plotter machine. On the first game my agent (“X”) lost against me (“O”). My agent made the first move on position 2, follow by me on position 4 and then my agent next move on position 0, so I block it from winning by placing my circle on position 1. Now interestingly, my agent should block me from winning by going to position 7, but instead my agent went to position 6. So, I made my winning move on position 7. I then hit another enter to see if my agent will move to its winning move which should be on position 3, but instead my agent went to position 8 haha… I need to fix the strategy for my agent to take winning move first if possible then follow by blocking the opponent from winning as the next priority.

Second game:

Learning from the first game’s mistakes, I modified my code to see if my agent can beat me this time. Again, my agent made the first move on position 2, follow by me on position 0 and then my agent next move on position 6, so I block it from winning by placing my circle on position 4. Interestingly, my agent now knows how to block me from winning by going to position 8 yay! And to block my agent from winning the game, I place my circle on position 7. Now my agent has two choice, either make the winning move on position 5, or block me from winning by moving to position 1. And my agent moved to position 5 to win the game! So happy to see that the strategy for my agent to take winning move first if possible then follow by blocking the opponent from winning as the next priority is working on this second game.

Note: My agent always making the first move and always playing as “X”. For drawing the circle, the camera is struggling to recognise my circle drawing (most of the times!), so either use a thick marker or colour in the circle to make it recognisable by the camera/sensor.

Algorithm & Pseudocode

In computer science, informal algorithm definition is a set of rules that precisely defines a sequence of operations. The pseudocode is a plain language description of the steps in an algorithm or another system. Pseudocode often uses structural conventions of a standard programming language but is intended for human reading rather than machine reading.

Below are the Algorithms & Pseudocodes that I’ve done for this fortnight 2 homework. For the actual codes that I used, please click the blue link.

3×3 Tic Tac Toe – Kennedy Agent

I selected the “Impress Me” for the stretch task by making the Tic Tac Toe board more interesting. So, I changed the board from 3×3 squares to 4×4 squares instead. This idea was inspired by my son, who likes to play 3×3 Rubik’s cube, and now he’s exploring the 4×4, which he found harder.
To change the board, however, I realised I have to update the engine_impress.py file, and the agent will play the game using the engine.py and interact with the Game Engine. Below is the pseudocode for the Tic Tac Toe game using a 4×4 squares board.

4×4 Tic Tac Toe – Impress Agent

4×4 Tic Tac Toe – Engine Impress

PEAS Table Analysis

As part of this fortnight 2 homework, I did the Performance Measure, Environment, Actuators and Sensors (PEAS ) analysis and comparison between Cyber and Physical Tic Tac Toe Agents, which can be found on the PDF link below.

Reflection

My idea of Tic Tac Toe is a simple game to play but I believe it’s a complicated strategy to code in python. I know the game and the approach to win the game in plain English, but I have no idea how to translate that into python codes. I tried to identify and list the agent, performance measure, environment, actuators and sensors as per the PEAS table. Another method I tried was following the coder’s journey: from idea to code steps which helped me to form my code. Having some discussion with other people also helped me think from other people’s perspective.

There’s similarity between my reflection from last fortnight (week 1-2) and this fortnight (week 3-4). To overcome some of the technical challenges, I mainly collaborate with other people and ask for help after give it a go first. I believe these collaboration approach and positive attitude may inform my skill and capability development in the future. The difference is I know one-fortnight worth of python on the second homework, so more familiar with the concept.

With regards to the reflective practice and learning journey so far, I found it was hard to reflect on what I’ve done or learnt. I often reflect but never put it on writing, just on my thoughts. And after the very busy first fortnight I didn’t have a chance to write down on how did I go and reflect on what I’ve done so far. I had to try harder to remember what I’ve done on that fortnight. It is difficult to make this as a habit but I know I should learn and start to do this from now on as it is a good habit to develop while I’m learning something new and going through this journey of becoming the NBE practitioner in future.

Acknowledgement

Memunat and Matthew who helped us in the class how to consider the logic for our agent codes.

James who explained his logic of listing all the position and possible moves in the index form, this helped me to update my agent code and able to win against me.