Tafl software
Posted: Sat Aug 30, 2025 5:12 pm
I have mentioned elsewhere on this forum that I have developed a Rust crate for working with tafl games, and using that I have implemented a very basic browser-based game where you can play against a (not very good) AI: see here. And I have recently started on what I hope will ultimately be a more featureful client.
Unlike other games like chess there isn't much open source tafl software out there. There is OpenTafl (which as I understand it is not "open source" in the traditional sense because of the restrictions it puts on use), and the tafl TypeScript library which powers https://litafl.com. IMO it would be great to see an ecosystem of open source software emerge for tafl.
In order for different tafl applications (like a client and a server) to be able to "talk" to each other, we would need to agree on a common way to describe game rules, board state and moves. I think (ii) and (iii) are fairly simple and are probably mostly solved.
It seems the most complete publicly available attempt to solve these problems is jslater's OpenTafl notation spec. Board state is represented using a simplified version of Forsyth Edwards Notation, which seems reasonable. Moves are represented in a format like "c3-h3", with certain optional additional information about captures and win conditions. I think that is mostly okay as well, though I don't necessarily agree with certain aspects like the move notation displaying if a move leaves a king vulnerable to capture or with a route to escape.
Game rules seems more difficult as there are so many variants. It's difficult to even exhaustively enumerate the different ways in which rules can differ (strictly speaking it's probably impossible, as anyone can come along and suggest a new variation on the rules, but even for the more popular variants it is difficult). My current attempt can be seen here, though it doesn't yet support berserk rules. Fellhuhn's app, a popular way to play the game on mobile, has a more advanced set of options but it's not open source and doesn't seem to offer a text-based export of rulesets. The OpenTafl notation spec linked above also has a more advanced attempt at describing game rules, and a format for reducing rulesets to a simple string, which might be the best we have. But even it has its limitations. Some combinations of rules that can be expressed on one of these platforms, may not be capable of representation on another.
Trying to create a good AI is another interesting challenge. Most AI I have played against (eg, on Fellhuhn's app, or my own attempt) has not been very strong. Again, OpenTafl seems to be the only "source available" attempt. I would guess most attempts at a Hnefatafl AI would build on what is already available for chess.
As far as I know none of the code that powers this website is open source or available, but Hagbard please correct me if I am wrong.
I would be interested to know if there are others out there trying to solve the same problems for their software and any thoughts or ideas they have. And if there is any other popular (and even better, open source) software out there for playing tafl games.
Unlike other games like chess there isn't much open source tafl software out there. There is OpenTafl (which as I understand it is not "open source" in the traditional sense because of the restrictions it puts on use), and the tafl TypeScript library which powers https://litafl.com. IMO it would be great to see an ecosystem of open source software emerge for tafl.
In order for different tafl applications (like a client and a server) to be able to "talk" to each other, we would need to agree on a common way to describe game rules, board state and moves. I think (ii) and (iii) are fairly simple and are probably mostly solved.
It seems the most complete publicly available attempt to solve these problems is jslater's OpenTafl notation spec. Board state is represented using a simplified version of Forsyth Edwards Notation, which seems reasonable. Moves are represented in a format like "c3-h3", with certain optional additional information about captures and win conditions. I think that is mostly okay as well, though I don't necessarily agree with certain aspects like the move notation displaying if a move leaves a king vulnerable to capture or with a route to escape.
Game rules seems more difficult as there are so many variants. It's difficult to even exhaustively enumerate the different ways in which rules can differ (strictly speaking it's probably impossible, as anyone can come along and suggest a new variation on the rules, but even for the more popular variants it is difficult). My current attempt can be seen here, though it doesn't yet support berserk rules. Fellhuhn's app, a popular way to play the game on mobile, has a more advanced set of options but it's not open source and doesn't seem to offer a text-based export of rulesets. The OpenTafl notation spec linked above also has a more advanced attempt at describing game rules, and a format for reducing rulesets to a simple string, which might be the best we have. But even it has its limitations. Some combinations of rules that can be expressed on one of these platforms, may not be capable of representation on another.
Trying to create a good AI is another interesting challenge. Most AI I have played against (eg, on Fellhuhn's app, or my own attempt) has not been very strong. Again, OpenTafl seems to be the only "source available" attempt. I would guess most attempts at a Hnefatafl AI would build on what is already available for chess.
As far as I know none of the code that powers this website is open source or available, but Hagbard please correct me if I am wrong.
I would be interested to know if there are others out there trying to solve the same problems for their software and any thoughts or ideas they have. And if there is any other popular (and even better, open source) software out there for playing tafl games.