multigraph or other solution?

Member
Posts: 162
Joined: 2010.10
Post: #1
suppose i have a graph with 3 nodes like:
[Image: Multigraph_1000.gif]
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
Quote this message in a reply
Member
Posts: 244
Joined: 2005.11
Post: #2
How about this:
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
Quote this message in a reply
Member
Posts: 162
Joined: 2010.10
Post: #3
seem a nice solution!
thanks
Quote this message in a reply
Post Reply