Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Spanky

Pipes - Short Route

This topic is 6909 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, here's my problem. I have a game in which the user gets to draw cards from a deck. The deck is unlimited so the games can go forever. The object of the game is to get 15 pipes inbetween your fosset and your spout. Its also multiplayer and other players can play "leaky" pipes on your field (with a few circumstances). The winner is the first one to get 15 pipes in the shortest path possible. This would normally be easy but there are T connectors which allow the user to split the pipe into 2 different paths. This can lead to some very complex and disorenting paths. I was wondering if anyone could help me try and get some sort of path finding going through my maze of pipes to figure out if the user has 15 pipes in any one path on their maze. Lets say path2 is 21 pipes and path1 is 14 pipes. They both come back into the same line so basically, they split, path2 puts in a few more pipes than path1 did and they come back into the same line with anotherT. Path 2 is obviously longer than path1 because it goes out and comes back in under path1. Can anyone help me write something that would tell me that path 2 is longer than path1 and how many pipes path2 is???? Thanks for the help. Spankster Edited by - Spanky on 5/18/00 3:24:58 AM

Share this post


Link to post
Share on other sites
Advertisement
Well, it sounds like a path-of-least-distance problem, which is generally solved using something called graphs. I could walk you through it, but your example is a little confusing to me. Could you draw up a picture or something?

Share this post


Link to post
Share on other sites
I like the sounds of this.

Assuming a couple of things, here''s how I might solve it.

The "faucet" is a known starting point. When you lay down a pipe, it has to be attached to a previous pipe. Any "head" of a pipe is a "spout" so there are multiple "spouts" the pipe. Each "spout" is stored in a list. You could then do an AStar pathfinding search from the "faucet" to each of the "spouts". Once the path is actually longer than 15 steps you have a winner. Using pathfinding would let you trace out the winning path as well.

A* pathfinding is based on graphs and stoffel is right. There are some good demos and source code samples on the web for AStar.

Share this post


Link to post
Share on other sites
Thank you so much for your help guys. I am going to start looking around for the AStar stuff once I am done here. I will draw up a little demo of what I mean tonight. And there are multiple paths that the pipe can take but there is only one spout. The lines can be capped of though or they can come back together into one line. I would have been so lost without your help. Thanks again.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!