ChatGPT and Hnefatafl

Post Reply
Ailill
Posts: 3
Joined: Tue Aug 15, 2023 4:14 pm

ChatGPT and Hnefatafl

Post by Ailill » Thu May 30, 2024 12:41 am

I decided to play around a bit with ChatGPT to assess its Tafl-playing abilities and see if it could be the basis of a good AI player. It wasn't very successful. I went with Copenhagen Hnefatafl. It seems to know the rules well but very much struggles with "thinking" of the board state and picking valid moves. I set out the interaction below in case anyone finds it interesting. I wonder if more work with detailed prompts could improve its performance.

Me

do you know the rules to Copenhagen Hnefatafl?

ChatGPT

Copenhagen Hnefatafl is a modern variant of the ancient Norse board game Hnefatafl. This variant adds some new rules to enhance balance and gameplay. Here's a summary of the rules for Copenhagen Hnefatafl:
Board and Pieces

Board: The game is played on an 11x11 grid.
Pieces: There are two sides - the attackers and the defenders.
Defenders: 12 warriors and 1 king.
Attackers: 24 warriors.

Objective

Defenders: The goal is to move the king to one of the corner squares (escape points).
Attackers: The goal is to capture the king before he escapes.

Setup

King: Placed in the center square (the throne).
Defenders: Positioned around the king in a cross formation.
Attackers: Placed in four groups, each group centered on the middle of each edge of the board.

Movement

All pieces move like rooks in chess, any number of spaces along a row or column, but cannot jump over other pieces.

Capturing

A piece (either attacker or defender) is captured if it is surrounded on two opposite sides by enemy pieces along a row or column. For example, an enemy piece on the left and right or above and below.
King Capture: The king must be surrounded on all four orthogonal sides to be captured.
If the king is next to the throne, he must be surrounded on the three remaining sides to be captured.
If the king is next to a corner, he must be surrounded on the remaining two sides.

Special Rules

Throne (Center Square): The throne can be occupied only by the king. All other pieces can pass over it but cannot stop on it.
Adjacent to Throne: A piece next to the throne can be captured by being surrounded on three sides (the throne acts as the fourth side).
King's Escape: The king can escape by moving to one of the four corners.
Reinforcement Rule: Introduced to balance the game, making it so that the defenders win if the attackers cannot capture the king within 37 moves.

Win Conditions

Defenders Win: If the king reaches one of the corner squares.
Attackers Win: If the king is captured.

Optional Variants

Some rulesets may introduce variations such as specific limitations on the king's movement or adjustments to the setup and capture rules to balance the game further.

These are the core rules for Copenhagen Hnefatafl. Variations and house rules might exist, but this summary covers the primary gameplay mechanics.

Me

We are going to play a game of Copenhagen Hnefatafl. I will play attacker (black) and you will play defender (white). I will go first. I will give you a move and you will respond with your move. Moves will be described in the form "<column><row>-<column><row>" where each column is given a letter from A-K and each row is given a number from 1-11. For example, I1-I4. When I give you my move, respond ONLY with a valid Copenhagen Hnefatafl move in the format described above, with nothing else.

ChatGPT

H6-H4

Me

G1-G4

ChatGPT

I6-H6

Me

that is not a valid move for white

ChatGPT

E6-E5

Me

That is not a valid move for white as the piece is blocked by other white pieces. Please only send valid moves having regard to the current board state.

ChatGPT

E6-E7

Me

That is not a valid move for white as the piece is blocked by other white pieces. Please only send valid moves having regard to the current board state.

ChatGPT

E5-E4

Me

A5-E5

ChatGPT

F6-F3

Me

Please print the current board state as you see it. Represent each empty tile as `.`, each attacking piece as `A`, each defending piece (other than the king) as `D` and the king as `K`.
ChatGPT

Certainly, here's the current board state after the moves:

H6-H4 (Black)
G1-G4 (Black)
E5-E4 (White)
A5-E5 (Black)
F6-F3 (White)


Code: Select all

A . . . A . . . A . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . A . A . . . . . .
A . . . D . . . . A . .
. . . . . . . . . . . .
. . . . K D D D . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
Now, it's your turn to make a move as the attacker.

Me

Please reset the board to the normal starting position for Copenhagen Hnefatafl and display it again. We will restart the game.

ChatGPT

Certainly! Here is the starting position for Copenhagen Hnefatafl:

Code: Select all

. . . A A A . A A A . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
A . . . . . . . . . . A .
A . . . . . . . . . . A .
A . . . . . . . . . . A .
. . . . . K . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . A A A . A A A . . .
K: King
A: Attacker
D: Defender (Defenders not marked here as all initial defenders are around the king)

Now, you may make your first move as the attacker.

Me

That looks off. Please try again having regard to the rules about initial placement that you described yourself. And please show the defenders.

ChatGPT

I apologize for the confusion. Here is the correct initial board setup for Copenhagen Hnefatafl:

Code: Select all

. . . A A A . A A A . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
A . . . . . . . . . . A .
A . . . . . . . . . . A .
A . . . D D D D D . . A .
. . . . D K D . . . . . .
A . . . D D D D D . . A .
A . . . . . . . . . . A .
A . . . . . . . . . . A .
. . . A A A . A A A . . .
K: King
D: Defender
A: Attacker
.: Empty square

Now, you may make your first move as the attacker.

END

Post Reply