Nano
Nano

Reputation: 11

Quoridor AI - undirected graph

As a homework, I need to create an AI for the game Quoridor.

normal board

After some analysis on my side, I decided to represent the board of the game as an undirected graph (see below).

undirected graph

The idea is to find the shortest path for each pawn to his objective and it's easier to do with such representation I guess...

The problem is that I really don't understand how to represent such graph in Prolog. I already saw how to create simple undirected graph with like 10 edges but this one's got 81.

Example of a simple undirected graph :

arc(1,2).    
arc(2,1).    
arc(1,4).    
arc(4,1).    
arc(2,3).    
arc(3,2).    
arc(3,5).    
arc(5,3).    
arc(5,6).    
arc(6,5).

After that, I should also be easier to user the MiniMax algorithm on the graph.

Thanks a lot !

Upvotes: 0

Views: 508

Answers (1)

Isabelle Newbie
Isabelle Newbie

Reputation: 9378

If you number your nodes 1, 2, 3, ..., 81 according to the following scheme:

 1  2  3  4  5  6  7  8  9
10 11 12 13 14 15 16 17 18
...

then in your graph you have arcs from 1 to 2, from 2 to 3, not from 3 to 4 but then again from 4 to 5, ... etc. You also have an arc from 4 to 13 but not, for example, from 5 to 14. Right?

In this way you can read off the list of arcs from the diagram to get:

arc(1, 2).
arc(2, 3).
arc(4, 5).
...
arc(4, 15).
...

Upvotes: 1

Related Questions