I'll try to do a Hnefatafl game with Pico-8.
This is not going to be easy ( because I'm not really good with code), but it's a nice challenge.
The game is one of pure strategy, played on a square board. A king and a small force of defenders occupy the centre of the board. A larger force of attackers, twice as numerous as the defenders, occupy positions around the edge of the board.
What I find interesting it's the asymmetry of this game, and the challenge to do the A.I. for it.
Any help, tips, are welcome , especially for the implementation of the A.I.
You can find more info about the game here
@Impox Take a look to "why to this game", It's the ancestor of Netrunner . My favorite board game!.
I need to figure out how to create the A.I., no idea how to do that with pico-8 and lua. An alpha beta should do the job, but not sure if it's possible :)
- If next to defender piece, attack
- If not, move to the closest one by one square
- In case you can only move one piece per turn (haven't played it), for 2. use the closest one to any of defenders if attack is not possible.
And you got AI.
Anyway, looking forward it, especially if you include two player mode (one player is defender, other is attacker).
Simple AIs to win board games are all about creating board states for possible moves and quietly playing future moves up to a certain length of time, then evaluating those states for their benefit as a possible next move.
The AI will grind through all possible board states after one move, then run some check to see which of those states are more beneficial.
You could have control over how many future states are checked. The more, the longer the computer will make you wait, and the tougher an opponent it'll be.
You could do things like randomly drop a state from the table to simulate the opponent having a poor attention span or something.
I've done it for a connect 4 AI years and years ago. I won my grade 8 science fair with my QBasic AI!
Since arnaud_debock mentioned alpha-beta pruning, they probably understand the basic idea of a tree search AI for a game like this. The problem would be coming up with an appropriate evaluation function. For the defender, you might use something like the shortest path from the king to a goal space. I saw an interesting approach to the game of Hex that used resistor networks to estimate how close a player was to winning. Perhaps something like that would work here.
You might also want a heuristic to order the moves considered. I'm not good enough at the game to have a good guess what that would look like.
@Retsyn @eruonna If you can help me with some code example it can really help.
I understand the concept of alpha pruning, but don't know about resistor networks.
( I'll do some research).
I was actually surprise to don't find any A.I. Implememtation done with pico-8.
Does It's a memory problem?
This game is close to chess, go and checkers.
But the fact It's assymetric, mean it probably need 2 different smart a.i.
@ darkhog thanks for your feedbacks
I have to do some AI for my Hanafuda Koi-Koi game. The beginning for me is to map out the rules and goals (combinations of cards is wrote easy) and then figure out the areas where you can introduce automation and randomness (the AI should not be perfect! )
Chess is imbalanced; I don't think game success is necessarily by merit.
More to the point, the Wikipedia article is talking about different rules than the "Brandub" reconstruction in arnaud_debock's link. Some of the variations the Wikipedia article suggests to make the game more balanced are in the Brandub rules, like 2-man capture of the king and the king having to escape on the corners.
@cheepicus, really? It's been a while since I played or looked into chess, but I thought it was sufficiently complex that it still wasn't a solved problem.
And I notice now that I came across very bluntly, so sorry about that. I just meant that the rules aren't fully known and it's probably best to make a balanced variant than the rules described in that wiki article.
The Brandub thing arnaud linked to is already a variant with some of those rules changes, tho.
I didn't read any ill will in your bluntness. I do disagree, though :) The evolutionary fitness of games is kind of a derail from Hnefatafl, so I'm just trying to be terse. Maybe modern chess is MORE balanced than one version of Hnefatafl that Linnaeus reverse engineered on his visit to Lapland, being unable to speak the local language, but if Wikipedia is talking about that game, it doesn't necessarily relate to the Brandub variant.
This is sure than chess got more depth and emergence than Brandub. But what I like in Brandub, is the fact than behind it's apparent simplicity, it's a very tricky game .
I just released an iOS version of hnefatafl called Viking Chess! I didn't have a CLUE how to tackle AI, so I went multiplayer only.
AI for this game is super tricky. Where as in chess, there are clearly best moves for any situation (I can capture the enemy Queen without risking any of my pieces), things are much muddier with hnefatafl. While your general strategy as a defender is to get your king to a corner, you have to deceive the attacker as to how you plan to get there. Having the AI deceive is tough to differentiate from having it make bad moves (moving a piece towards a corner that is already blockaded).
AI aside, the other thing I had a lot of trouble with was group captures. If you surround a whole group of enemy pieces, they ALL get captured. None of the other iOS versions of tafl had this feature included, so I really wanted to nail it down. I ended up getting it and was extremely satisfied with myself when I did. If you need any pointers with that part, let me know!
Anyway, good luck with this, and I'll be keeping an eye on your progress!
[Please log in to post a comment]