![]() |
|
multigraph or other solution? - Printable Version +- iDevGames Forums (http://www.idevgames.com/forums) +-- Forum: Development Zone (/forum-3.html) +--- Forum: Game Programming Fundamentals (/forum-7.html) +--- Thread: multigraph or other solution? (/thread-10267.html) |
multigraph or other solution? - sefiroths - Aug 28, 2012 05:21 AM 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 RE: multigraph or other solution? - backslash - Aug 28, 2012 06:51 AM 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 RE: multigraph or other solution? - sefiroths - Aug 28, 2012 07:32 AM seem a nice solution! thanks |