doom2day Posted June 23, 2005 In pascal i have an 2 dimensional array for a gameboard and another one for mines. I have the game randomly place an user selected number of mines in the field. you have to get from point a to point b without colliding with an mine. AXXXXXXXX X*XXXXXX* XXX***XXX XXXXXXXXX XXXX*XXXB THE 135,145,436,413,145,145$ QUESTION IS: How can i make sure thatthere is a path from point a to point b that there are no mines on? Diagonals count. I can't figure it out by myself. And also there is buffer space on the outside so i can fill it up with mines if I have to By the way, it resembles an old dos game. Text mode though. 0 Share this post Link to post
insertwackynamehere Posted June 23, 2005 hmm I dont know pascal, but here's how I'd suggest it. Step 1: get the info of where the start tile is Step 2: get info about the tile to the left of it Step 3: if this isnt a mine then get info about the tile to the left of that if it is a mine go back to the previous tile and look at the tile below it and repeat. In otherwords, keep checking for tiles which arent mines from the current position of the check until it reaches a tile which is marked as the exit. In other words, send the computer through the maze, but whenever it hits a mine, it doesnt die but instead goes to the previous tile and checks the next one. 0 Share this post Link to post
Infinite Ammunition Posted June 23, 2005 i'd imagine a* would be useful for this 0 Share this post Link to post
Bucket Posted June 23, 2005 Yeah, I can't think of any way a program can do that besides recursively. Go with what wacky said. 0 Share this post Link to post
Carnevil Posted June 23, 2005 A* is probably the best pathing algorithm you'll find. At each "node" on the grid, both the cost from the starting point, and the estimated cost (guess a rough guess, usually based on distance) of getting to the goal are recorded. Since the algorithm at each node cares about how costly it is to get there, and roughly how costly it is to get to the goal node, you end up getting really efficent paths. There's some really good pages out there that do a good job of explaining A* in detail. If you have any questions, let me know and I'll do the best I can to help. Oh yeah, and stop using Pascal :P 0 Share this post Link to post
Doom-Child Posted June 24, 2005 A* is really efficient, but it's definitely more complicated than a quick and dirty backtracking algorithm. Pascal will work for what you're doing now, but I'd suggest you kick that shit and do it in C. DC 0 Share this post Link to post
doom2day Posted June 24, 2005 Doom-Child said:A* is really efficient, but it's definitely more complicated than a quick and dirty backtracking algorithm. Pascal will work for what you're doing now, but I'd suggest you kick that shit and do it in C. DC 1) I am 15 2) I don't know C yet. 0 Share this post Link to post
Fredrik Posted June 24, 2005 doom2day said:1) I am 15That's not an excuse for using Pascal. Though, you're young enough that you may still have a chance to recover. 0 Share this post Link to post
doom2day Posted June 24, 2005 Would be great if this was C, but some help with pascal please! 0 Share this post Link to post
doom2day Posted June 24, 2005 Pascal and Qbasic are the only languages I know. I prefer pascal. 0 Share this post Link to post
Piezo Posted June 25, 2005 Fredrik said:That's not an excuse for using Pascal. Though, you're young enough that you may still have a chance to recover. Hey, I first used it when I was 17. :P 0 Share this post Link to post
Doom-Child Posted June 26, 2005 Actually, thinking about it, yeah, you may want to stick to Pascal until you get some more grounding in data structures. In particular, this problem is perfect for the application of both a stack and a graph. And until you've got a good grip on those, I don't think you're going to be able to do a great job on something like this. DC 0 Share this post Link to post