## multigraph or other solution?

Member
Posts: 164
Joined: 2010.10
Post: #1
suppose i have a graph with 3 nodes like:

that form a boardgame.
every edge has a color.
a pawn can move from node to node accordingly to a color from a dice roll.

i don't know where to start implementing this, or if there is a easy solution for this problem, perhaps i can add nodes between edges giving weight 0.5 instead of 1, but i didn't like that solution because the added nodes are not playable nodes (but only support to arrive at the legal node)

can someone give me an hint?
thanks
Member
Posts: 245
Joined: 2005.11
Post: #2
Assign each colour a power of 2 number, e.g. red = 1, green = 2, blue = 4.
For each node you can store its connections to each of the other nodes in an eight bit number, e.g.:
Node A : b=5, c=7
Node B : a=5, c=2
Node C : a=7, b=2
Now if you are at node A and you roll green (2) you can say:
2 | 5 = 0 so you can't go to node B
2 | 7 = 2 so you can go to node C
Member
Posts: 164
Joined: 2010.10
Post: #3
seem a nice solution!
thanks