Homepage

Install
See how to install the software here.
Rules
See the rules here.
Artificial Intelligence
Learn about AI here.
Translate
If you want to add, update, or fix a translation, open an issue and state what you want to do. If it is a minor change, you can just update the code and submit a pull request.
Discord
Join discord here.
Help Me
If you have any issues with the software, open an issue on github.
Donate
Donate here.
Hnefatafl Org by David Lawrence Campbell is licensed under CC BY 4.0
Install

Arch and Derivatives (Linux) @
In your terminal run:
sudo pacman --sync yay
yay --sync hnefatafl-copenhagen
Chocolatey (Windows)
Install Chocolatey.
Then install hnefatafl-copenhagen.
Debian and Derivatives (Linux)
Download hnefatafl.list to /etc/apt/sources.list.d/.
Then, Download packages.hnefatafl.org.asc to /etc/apt/keyrings/.
Then in your terminal run:
sudo apt update && sudo apt install hnefatafl-copenhagen
Flatpak (Linux)
See flathub.org.
F-Droid (Android)
- Go to Google. Scroll down to
Enhanced Safe Browsing for your account. If it is on, turn it off. - Go to F-Droid and download F-Droid.
- Open F-Droid, go to search, and install
Termux: Terminal emulator with packages. - Open Termux, then run the following:
# Only need to run this once per update.
pkg upgrade
termux-change-repo
pkg install rust git x11-repo
pkg install xfce termux-x11-nightly
git clone https://github.com/termux/termux-packages termux-packages-hnefatafl-copenhagen-dest
git clone -b hnefatafl-copenhagen https://github.com/robertkirkman/termux-packages termux-packages-hnefatafl-copenhagen-src
cp -r termux-packages-hnefatafl-copenhagen-src/x11-packages/hnefatafl-copenhagen/ termux-packages-hnefatafl-copenhagen-dest/x11-packages/
cd termux-packages-hnefatafl-copenhagen-dest
scripts/setup-termux.sh
./build-package.sh -I -f hnefatafl-copenhagen
cd output/
apt reinstall ./hnefatafl-copenhagen*.deb
# Repeat this every time you want to run the program.
export LIBGL_ALWAYS_SOFTWARE=1 DISPLAY=:0
termux-x11 -xstartup xfce4-session &
hnefatafl-client --ascii
Then go to Termux:X11 from the main menu. You may need to hold Termux:11 to
go to the Preferences -> Output, then increase the Display scale %.
Redox @
Edit your user config to include:
[packages]
hnefatafl-copenhagen = "source"
You should be at least using the packages supplied via
include = ["desktop.toml"]. Go to games and open Hnefatafl. After logging in
and exiting the application, you’ll have to restart Redox, because the
application is buggy.
There are also at least these bugs:
- There are no CJK fonts.
- On a button press two characters are read in instead of one.
- Backspace does not work.
- I think you have to restart Redox after entering the application, because TcpStream shutdown is not implemented.
Cargo (Linux, macOS, Windows) @
Dependencies (Linux)
ALSA development files are needed to build cpal on Linux (rodio dependency,
hnefatafl-client dependency). These are provided as part of the
alsa-lib package on Arch, libasound2-dev package on Debian and Ubuntu, and
alsa-lib-devel on Fedora.
The package uses the mold linker. This is provided via the mold
package on Arch, Debian, Ubuntu, and Fedora.
Run
In your terminal run the following to run the client with Rust’s cargo:
cargo install hnefatafl-copenhagen
RUST_LOG=hnefatafl_client=info hnefatafl-client
Note
At the moment their may be fairly regular updates. If you run into problems, make sure you are running the latest version.
Hnefatafl Org by David Lawrence Campbell is licensed under CC BY 4.0
Rules
Rules
From Copenhagen Hnefatafl with minor changes.
The Copenhagen rules were outlined 2012 by Aage Nielsen (Denmark), Adam Bartley (Norway) and Tim Millar (UK). English text and diagrams: Adam Bartley (Norway)
Based on the version that was last updated 21.12.2024.
Copyright © 1998-2025 Aage Nielsen, All Rights Reserved;
A: attackera: captured attackerK: kingk: captured kingD: defenderd: captured defenderR: restricted space
1. Starting Board Position

2. First Turn
The attackers move first.
3. Movement
You can move to the edge of the board or another piece orthogonally:

4. Capture
All pieces except the king are captured if sandwiched between two enemy pieces, or between an enemy piece and a restricted square. A piece is only captured if the trap is closed by the aggressor’s move, it is therefore permitted to move in between two enemy pieces. The king may take part in captures.
Captures
┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐
11│R.........R│ │R.........R│ │R.........R│ │Rd........R│
10│...........│ │...........│ │...........│ │..↑........│
9│...........│ │...........│ │...........│ │..A........│
8│...........│ │...........│ │...........│ │...........│
7│...........│ │...........│ │...........│ │...........│
6│.....R.....│ │...A.R.....│ │..K..R.....│ │.....R.....│
5│.....d.....│ │...d.......│ │..↓........│ │...........│
4│.A→→→......│ │.Ad.dA.....│ │...........│ │...........│
3│...........│ │...↑.......│ │..a........│ │...........│
2│...........│ │...A.......│ │..D........│ │...........│
1│R.........R│ │R.........R│ │R.........R│ │R.........R│
└───────────┘ └───────────┘ └───────────┘ └───────────┘
ABCDEFGHIJK ABCDEFGHIJK ABCDEFGHIJK ABCDEFGHIJK
Doesn’t Capture
┌───────────┐ ┌───────────┐
11│R.........R│ │R.........R│
10│...........│ │...........│
9│...........│ │...........│
8│...........│ │...........│
7│...........│ │...........│
6│.....K.....│ │.....R.....│
5│.....D.....│ │.D.D.......│
4│.A→→→......│ │..↑........│
3│...........│ │..A........│
2│...........│ │...........│
1│R.........R│ │R.........R│
└───────────┘ └───────────┘
ABCDEFGHIJK ABCDEFGHIJK
Shield Wall
A row of two or more taflmen along the board edge may be captured together, by bracketing the whole group at both ends, as long as every member of the row has an enemy taflman directly in front of him.
A corner square may stand in for one of the bracketing pieces at one end of the row. The king may take part in the capture, either as part of the shield wall or as a bracketing piece. If the king plus one or more defenders are attacked with a shield wall, the attack will capture the defenders but not the king.
┌───────────┐ ┌───────────┐
11│R.........R│ │R.........R│
10│...........│ │...........│
9│...........│ │...........│
8│...........│ │...........│
7│...........│ │...........│
6│.....R.....│ │.....R.....│
5│...........│ │...........│
4│...........│ │...........│
3│..D........│ │...........│
2│..↓DDD.....│ │........AA.│
1│R..aaaD...R│ │R....A→.KdR│
└───────────┘ └───────────┘
ABCDEFGHIJK ABCDEFGHIJK
5. Restricted Squares
Restricted squares may only be occupied by the king. The central restricted square is called the throne. It is allowed for the king to re-enter the throne, and all pieces may pass through the throne when it is empty.
Restricted squares are hostile, which means they can replace one of the two pieces taking part in a capture. The throne is always hostile to the attackers, but only hostile to the defenders when it is empty.
The four corner squares are also restricted and hostile, just like the throne. The board edge is NOT hostile.
┌───────────┐
11│R.........R│
10│...........│
9│...........│
8│...........│
7│...........│
6│.....R.....│
5│...........│
4│...........│
3│...........│
2│...........│
1│R.........R│
└───────────┘
ABCDEFGHIJK
6. King’s Side Win (Defenders)
If the king reaches any corner square, the king has escaped and his side wins.

Exit Forts
The defenders also win if the king has contact with the board edge, is able to move, and it is impossible for the attackers to break the fort.
┌───────────┐ ┌───────────┐
11│R.........R│ │R.........R│
10│...........│ │...........│
9│...........│ │...........│
8│...........│ │...........│
7│...........│ │...........│
6│.....R.....│ │.....R.....│
5│...........│ │...........│
4│...........│ │...........│
3│...........│ │....DD.....│
2│....DD.....│ │....D.D....│
1│R..DK.D...R│ │R...DKD...R│
└───────────┘ └───────────┘
ABCDEFGHIJK ABCDEFGHIJK
7. Attackers Win
The attackers win if they can capture the king.
The king is captured when the attackers surround him on all four cardinal points, except when he is next to the throne.
If on a square next to the throne, the attackers must occupy the three remaining squares around him.
The king cannot be captured on the board edge.
The King is Captured
┌───────────┐ ┌───────────┐ ┌───────────┐
11│R.........R│ │R.........R│ │R.........R│
10│...........│ │...........│ │...........│
9│...........│ │...........│ │...........│
8│...........│ │...........│ │...........│
7│.....A.....│ │...........│ │...........│
6│....AkA....│ │.....R.....│ │.....R.....│
5│.....A.....│ │....AkA....│ │...........│
4│...........│ │.....A.....│ │....A......│
3│...........│ │...........│ │...AkA.....│
2│...........│ │...........│ │....A......│
1│R.........R│ │R.........R│ │R.........R│
└───────────┘ └───────────┘ └───────────┘
ABCDEFGHIJK ABCDEFGHIJK ABCDEFGHIJK
If the attackers surround the king and ALL remaining defenders with an unbroken ring, then they win, as they have prevented the king from escaping.

The King is Not Captured
┌───────────┐ ┌───────────┐
11│R.........R│ │R.........R│
10│...........│ │...........│
9│...........│ │...........│
8│...........│ │...........│
7│...........│ │...........│
6│.....R.....│ │.....R.....│
5│...........│ │...........│
4│...........│ │...........│
3│...........│ │...........│
2│....A......│ │.A.........│
1│R..AKA....R│ │RKA.......R│
└───────────┘ └───────────┘
ABCDEFGHIJK ABCDEFGHIJK
8. Perpetual Repetitions
Deleted Rule
Perpetual repetitions are forbidden. Any perpetual repetition results in a loss for the defenders.
Added Rule
If the defender would repeat a board position, the move is not allowed.
9. Automatic Loss
If a player cannot move, he loses the game.
Artificial Intelligence
Artifcial Intelligence
I am working on making a reasonably strong artificial intelligence, but it is
pretty weak at the moment. If you have the source package, You can run it via
cargo run --release --bin hnefatafl-ai. See --help for what options you can
pass it.
You’ll have to create an account for it first on whatever server you will be
running it on. Run the client and log onto the server. Then, Create an account
for your AI, prefixing the username with ai-.
It can also be run as a service for the Arch and Debian installs. Edit the file
/etc/hnefatafl-ai-attacker.conf or /etc/hnefatafl-ai-defender.conf and add
USERNAME=username
PASSWORD=password
Don’t prefix the USERNAME with ai- here.
Then run
sudo systemctl start hnefatafl-ai-attacker
or
sudo systemctl start hnefatafl-ai-defender
If you want to change the settings for the AI further, you can edit
/usr/lib/systemd/system/hnefatafl-ai-attacker.service or
/usr/lib/systemd/system/hnefatafl-ai-defender.service and change the value of
ExecStart.
By default this runs basic AI with a search depth of 4. The AI seems pretty weak if you go below 4. You can increase the depth, but the AI may run very slowly.
Be warned that by default this runs in parallel using all available CPUs. If
you only want to use one CPU, you can pass --sequential.
Hnefatafl Org by David Lawrence Campbell is licensed under CC BY 4.0