4

The game that I am trying to prove computability for is Dots and Boxes.

However, instead of using theorems I am trying to do so by creating an AI that is supposed to have 100% winrate in that game for either player 1 or player 2. If creating an 100% winrate AI is impossible, then my goal is to create one that's at least better than all the other AI's. As of right now I am writing everything in PHP because I am competing against another AI's that are written in scripting language as well.

This whole thing is recursive and the basic logic is: Compute the ENTIRE TREE of ALL possible moves If it is my AI's turn, then pick the route with maximum number of points for AI player. If it is opponent's AI's turn, then pick the route with minimum number of points for my AI. Aka compute number of guaranteed points at each node.

After computing the entire tree, pick the route with the highest number of guaranteed points. On Even points, pick randomly.

This whole computation process will take roughly forever to compute on 15x15 board, however for now all i am going for is computing it on 3x3 matrix. I will store best possible moves for first 6-8 moves in a database in order to now have to re-compute them again, this changing the complexity of each computation from 24! to 18!.

Is this whole thing doable? And Is there a problem with the way I compute my moves? Is there a better way to do this?

Adam Stelmaszczyk
  • 19,665
  • 4
  • 70
  • 110
Dimitri
  • 453
  • 3
  • 11

2 Answers2

7

The problem has a very large search space, for a 4x4 grid, we have something like 40 edges and so 2^40 states in the search space. For this reason is completely impossible to solve the entire game for a larger map.

What are the solutions? First you can take a look to the work Solving Dots-And-Boxes of Barker and Korf. It is the state of the art for this kind of problem (in 2012 and maybe also now, I'm not sure). They used a combination of the classic Alpha-Beta pruning algorithm with a bunch of problem specific solutions.

You can also try to apply Monte Carlo Tree Search to the problem. I'm not aware of works in this directions but Monte Carlo has been proven successful for the Go game (that is similar to your problem in some sense).

Davide Aversa
  • 5,628
  • 6
  • 28
  • 40
  • Oh, God. I'm too tired for today! :D I've fixed the link. Check if it works! – Davide Aversa Feb 06 '15 at 18:52
  • Note that 5x5 dots-and-boxes was solved in 2014. It is a 13-12 win for the first player according to this post in the littlegolem forum: https://www.littlegolem.net/jsp/forum/topic2.jsp?forum=110&topic=148 – Rémi Sep 20 '20 at 17:00
5

Machine learning should drop computation time a good bit by eliminating a lot of the branches with bad outcomes initially. It will probably take more time for it to solve small problems such as a 3x3 board, but when you start testing your algorithm on bigger boards it will (I can't say with certainty without writing out both algorithms and trying them) be faster, as it should be some varient of a t=log(n) function.

For example, using Reinforcement Learning it will basically do what you suggest, compute a massive decision tree. However, it will learn that some moves (such as the ones that give the opposition a box) are bad and it will not waste as much time computing moves succeeding those.

Is it doable? Depends on how much free processing time you have. Use a small grid until you have a decent AI algorithm written and you can then run a machine and watch it learn on its own. There is nothing more satisfying than watching your creation learn something. It's like having a baby... one that can beat you at Dots and Boxes.