117 lines
6 KiB
HTML
Executable file
117 lines
6 KiB
HTML
Executable file
<!-- prettier-ignore -->
|
||
{% extends "base.html" %}
|
||
|
||
{% block content %}
|
||
<h2>
|
||
Tak
|
||
</h2>
|
||
<p>
|
||
One of my favourite fantasy book series is the Kingkiller Chronicles by Patrick Rothfuss.
|
||
In the second book The Wise Man’s Fear there is a board game that they play that sounded fascinating.
|
||
I have always like abstract strategy games and this was his worlds “Chess”; the game that had been around forever, simple rules but deep strategy etc.
|
||
</p>
|
||
<p>
|
||
I was so excited when I found out that it was being made into a full game by <a href="https://cheapass.com/tak/">Cheapass Games</a>.
|
||
The rules are available for free on their website.
|
||
I bought myself a copy and it is a lot of fun.
|
||
They did an amazing job getting the feel of the game right and it is now for sale on <a href="https://worldbuildersmarket.com/collections/tak-a-beautiful-game">WorldBuilders Market</a>.
|
||
Proceeds from WorldBuilders go to charity so if you try out the game and enjoy it please consider buying a copy.
|
||
</p>
|
||
<p>
|
||
As a project I made a digital copy of the game.
|
||
Source code <a href="https://github.com/OrthogonalStar/Tak-BoardGame">here</a>.
|
||
It is written in python 3 and the only extra library it needs to run is pygame.
|
||
If you want to run the tests you will need pytest as well.
|
||
</p>
|
||
<p>
|
||
Here is the program interface.
|
||
</p>
|
||
<figure>
|
||
<img src="/assets/images/TakProgram.png" alt="Home Board" />
|
||
<figcaption>Tak Program</figcaption>
|
||
</figure>
|
||
<p>
|
||
The game was a very interesting challenge to implement for a few reasons.
|
||
</p>
|
||
<p>
|
||
The board size is flexible.
|
||
It ranges from 3×3 to 8×8 (skipping 7×7 but I am not quite sure why).
|
||
The rules for victory are the same regardless of board size but the number of pieces each player has access to changes.
|
||
The board had to be housed in a flexible object that would also dictate the number of pieces.
|
||
</p>
|
||
<p>
|
||
While there are only two types of pieces (regular and capstones), the standard pieces can be played in 2 different orientations.
|
||
Flat placement is the default.
|
||
It contributes to win conditions and can make stacks.
|
||
Placing a normal piece as a wall blocks other pieces but does not contribute to your win condition and can only be at the top of a stack.
|
||
The capstone has the best characteristics of both and can squish walls to flat if it lands on them alone.
|
||
</p>
|
||
<figure>
|
||
<img src="/assets/images/TakPieces.png" alt="Pieces" />
|
||
<figcaption>Tak pieces (left to right: flat, wall, capstone)</figcaption>
|
||
</figure>
|
||
<p>
|
||
Rather than make an object for each piece I built the piece specific rules into the move action.
|
||
The move is the same at its core for each piece and the only difference is the interaction when one piece lands on top of another.
|
||
Storing the pieces as integers in a 2d array makes this far simpler.
|
||
As the interactions depend on both pieces, using an integer makes that comparison very easy.
|
||
</p>
|
||
<p>
|
||
The game has an interesting 3 dimensional component.
|
||
The pieces can be stacked on top of one another and a stack can move as far as the stack is high (in a straight line controlled by the player whose piece is at the top) dropping one piece at a minimum on each square along the way.
|
||
This means that each square in the 2d array needs to contain a stack where new pieces are added to the top.
|
||
When pieces are lifted off a stack your hand acts like a second stack.
|
||
Pieces are popped off the top of the square and added to the stack in your hand.
|
||
Then they are dropped from the “bottom” of this inverted stack as you move.
|
||
</p>
|
||
<figure>
|
||
<img src="/assets/images/CurrentMove-2.png" alt="Move view" />
|
||
<img src="/assets/images/CurrentDrop-2.png" alt="Drop view" />
|
||
</figure>
|
||
<p>
|
||
The comparison needs to be done from the “bottom” of the inverted stack in your hand to the top of the stack that the piece will land on.
|
||
</p>
|
||
<p>
|
||
That is the main challenge of the game play.
|
||
The victory conditions were also challenging.
|
||
The game has 3 different ways that it can end and 2 possible ways to calculate who won.
|
||
|
||
</p>
|
||
<p>
|
||
The game ends when one player builds a connected line of pieces from one of the sides of the board to the opposite side.
|
||
The line does not need to be straight but squares do not connect on the diagonal.
|
||
The victor in this case is the player who has the “road”.
|
||
If a move creates a road for both players the active player wins.
|
||
</p>
|
||
<figure>
|
||
<img src="/assets/images/Victory.png" alt="Victory" />
|
||
<figcaption>Victory!</figcaption>
|
||
</figure>
|
||
<p>
|
||
The game also ends if either player runs out of pieces or there are no more open spaces on the board.
|
||
In that case the winner is the player with the control of the most squares of the board.
|
||
</p>
|
||
<p>
|
||
Both of these need to be checked after each turn and when a winner is found the points are calculated based on the size of the board and the number of pieces left.
|
||
</p>
|
||
<p>
|
||
Compared to Chess or Go, Tak is a little bit more complicated.
|
||
This is not through having a significantly large number of rules but the systems intertwine more and are more flexible.
|
||
This does not mean that it is a better game just different, but it has a similar feeling of depth and timelessness.
|
||
</p>
|
||
<p>
|
||
The board being stored as an array of integers means that it takes very little memory.
|
||
That made it simple to store past boards in a stack and implement an undo function.
|
||
Both to take back moves and even go back to a previous game from the same session.
|
||
</p>
|
||
<p>
|
||
I am pleased with how the game turned out.
|
||
I am working on other things at the moment but in the future I would like to do two more things with this game.
|
||
I want to implement it online so that I can play with friends over the internet.
|
||
I would also like to try and develop an A.I.
|
||
agent to play the game.
|
||
I had this in mind when I was writing it so made sure that the GUI was disconnected from the actual mechanics behind the game.
|
||
This will hopefully make it easier to connect to an agent for training.
|
||
</p>
|
||
{% endblock %}
|