![]() ![]() ![]() It shows a graphical version of the board on the micro:bit's LED display. This is a version for the BBC micro:bit which you can play using the serial console in the online Python Editor It's not very imaginative, there's no random element and if there are multiple squares with the same high weigting score, it will always pick the first square suggested by the algorithm. It also prints out its scoring array and thinking about threats and possible winning squares, so you can follow how it has made its choice. The program then picks the square with the highest weighting number for its move. Squares in an otherwise empty line where the human has placed a O get an extra weighting of 1.Potential losing squares, in which the human could win, get an extra weight of 5.Potential winning squares get an extra weight of 6.Squares already played get a weight of 0.The computer scans each row, column and diagonal and assigns a weighting score to each square:.You can choose who plays first, human or computer.Ox3.py uses something closer to Zaks' algorithm: ![]() Ox2.py is a game you play against the computer, but the human always goes first and the computer just picks the first free square, so it's super easy to beat. ![]() Ox.py is just a game for 2 human players, so I could set up a simple user interface that spots when a player has won or if it's a draw. ![]()
0 Comments
Leave a Reply. |