Hey, this week, I want to talk about Assignment 2, which was to design a strategy and a new game state. This assignment is more difficult than Assignment 1.
First, let's talk about Minimax. In assignment 1, we were told to design a random choosing strategy, so we only need to import random and choose a possible move from the list. But Minimax is a strategy such that computer will try to win and if there is a chance to win, it will definitely win. So it is a recursive strategy and I don't think there's other way to implement besides using recursive structure. After figuring out its structure, here comes the most difficult part, writing code. I read the handout very carefully and find the picture interesting. It is basically saying that we need to consider all possible moves and all states can be derived from that move, so it is quite obvious that some of them will end with A win or B win. If A wins, then, the it return 1 to the last state will made the move. So when we reach the node, we will always try to make a decision of which one to choose, given that all of them end up with a winning condition. I was thinking if we need to compute how complex each subtree is and choose the simplest tree, the code becomes very long and tedious. Besides, it may take computer very long time to reach leaves and again compute complexity of every subtree at the very beginning. So I decided to choose first possible move that maybe end up with a winning condition.
Second, that's about TippyGameState. Tippy is a very interesting game, very different from Tic-Tac-Toe. The winning condition is somehow weird but in this way, random strategy and Minimax strategy are more useful. If what we implement is Tic-Tac-Toe, it is pretty likely game end with a tie. The winning condition of Tippy reduces this possibility and makes it more challenge. However, implementation of detection of winning block is not that simple. I worked out an algorithm that using a for loop and for very coordinate that has an 'X' or 'O', I look at its surrounding for specific shape. If there is , return True. Else return False. It is like:
for coord:
if <some condition>:
return True
elif <some condition>:
return True
elif <seom condition>:
return True
return False
I have to say this assignment is interesting and challenging, especially for those worked solo like me. I am thinking of working in partner next time.
没有评论:
发表评论