? enemy AI which would go through a maze and find the player (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
This website has been moved, please see this post

enemy AI which would go through a maze and find the player

1 2 3
  • #1 ✎ 178 ChaseCZ Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Yeah i probably said everything in the title... I have an idea of how it should work but no idea of how to code it lol. Any help super appreciated Posted Edited by ChaseCZ
  • #2 ✎ 157 Vakore What you are referencing to is a path finder. While I've never successfully made one myself, I do know some articles that can explain the process. Like this one [url= http://www.cokeandcode.com/main/tutorials/path-finding/] [url]http://www.cokeandcode.com/main/tutorials/path-finding/ It is much easier if you are using a grid, but if you aren't, then you are in for a long ride. Posted
  • #3 ✎ 178 ChaseCZ Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself
    What you are referencing to is a path finder. While I've never successfully made one myself, I do know some articles that can explain the process. Like this one [url= http://www.cokeandcode.com/main/tutorials/path-finding/] [url]http://www.cokeandcode.com/main/tutorials/path-finding/ It is much easier if you are using a grid, but if you aren't, then you are in for a long ride.
    Yes, that's a good explanation, now i know how it basically works, but to make it work in Smilebasic, i'll need to start up my brain lmao Thanks
    Posted
  • #4 ✎ 178 ChaseCZ Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Also how would i take wall collision into consideration? Posted
  • #5 ✎ 157 Vakore For the pathfinder or the player? Posted
  • #6 ✎ 178 ChaseCZ Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself For the pathfinder, so it doesn't bump into walls and actually finds at least some logical path to the player Posted
  • #7 ✎ 157 Vakore Are you using a grid? If so, then you would detect if the space is empty or not. If it is empty, advance, else, find somewhere else. Posted
  • #8 ✎ 178 ChaseCZ Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself What do you mean by grid? Lol Posted
  • #9 ✎ 157 Vakore Like this: @grid Data "11111" Data "10101" Data "10101" Data "10001" Data "11111" [/copde] Posted
  • #10 ✎ 178 ChaseCZ Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Oooh you mean a data map. Yeah, i won't be using that. Posted
  • #11 ✎ 157 Vakore What are you using then? An open area? Streets? Posted
  • #12 ✎ 178 ChaseCZ Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself I'm thinking about a top down (not with tile movement though) or a 2d map. Haven't made my mind yet but i think i'll be going with a 2d "room-to-room" game where (as the name suggests) you're gonna go from room to room, from door to door and i want the enemy to find a path and go through the doors too. I think it's actually gonna be easier than the top down game, which would be similar but with bigger rooms. I don't really wanna spoil anything yet. Posted Edited by ChaseCZ
  • #13 ✎ 157 Vakore I'm not sure how to help you. Time-based maps pretty much the easiest(and least expensive to ram) to do. Posted
  • #14 ✎ 1547 rando Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Avatar Taboo I didn't change my avatar for 180 days Website I don't understand what you are trying to mean. Do you have a map top down where you can see the maze around the player and walk around in it? How will this maze work? Posted
  • #15 ✎ 157 Vakore If you post a picture, we can better understand what you are asking Posted
  • #16 ✎ 1547 rando Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Avatar Taboo I didn't change my avatar for 180 days Website
    If you post a picture, we can better understand what you are asking
    yes that's a good idea
    Posted
  • #17 ✎ 212 seggiepants It sounds like you want to investigate the A Star or A* algorithm. It works well on a grid but is really more of a graph traversal algorithm. Moving from point to point has a cost so you can make going up a hill more expensive than a flat area. If you want impassable areas don't mark a position as a traversable node on the graph. It starts out like Djikstra's search where you recursively evaluate nodes until you find a path to the target. However in A Star you have a heuristic function, so that you explore nodes that are better possibilities first. Once you find the target you backtrack your path. If your heuristic never overestimates you should have an optimal path. With a junk heuristic you devolve into Djikstras search performance. This isn't a cheap operation so you should only really run it sparingly, not every frame. As for being followed from room to room, you may just want to put the enemy on a timer and fake it. Only doing another search when the time says they should reach the room the user is in. Posted
  • #18 ✎ 178 ChaseCZ Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself
    It sounds like you want to investigate the A Star or A* algorithm. It works well on a grid but is really more of a graph traversal algorithm. Moving from point to point has a cost so you can make going up a hill more expensive than a flat area. If you want impassable areas don't mark a position as a traversable node on the graph. It starts out like Djikstra's search where you recursively evaluate nodes until you find a path to the target. However in A Star you have a heuristic function, so that you explore nodes that are better possibilities first. Once you find the target you backtrack your path. If your heuristic never overestimates you should have an optimal path. With a junk heuristic you devolve into Djikstras search performance. This isn't a cheap operation so you should only really run it sparingly, not every frame. As for being followed from room to room, you may just want to put the enemy on a timer and fake it. Only doing another search when the time says they should reach the room the user is in.
    Yes, the timer would be a good solution... But not the best, because what if there are multiple doors in the room where the player is, how would it determine at which door it would appear?
    If you post a picture, we can better understand what you are asking
    yes that's a good idea
    And as for the pictures, i have prepared some poorly-made paintings on my phone but my mobile data are slow af and it won't upload, so i'll send it here as soon as i connect to wifi somewhere
    Posted
  • #19 ✎ 157 Vakore Store the door in a variable. Posted
  • #20 ✎ 212 seggiepants I would calculate the door to enter from with the Pythagorean Theorem. For a right triangle with sides a, and b and hypotenuse c it states that a^2 + b^2 = c^2. Let x1, y1 be the location the monster was (globally) at when you left them. Then for each door in the current room let x2, y2 be the (global) location of the door. dx = x2 - x1, and dy = y2 - y1 so calculate dx*dx + dy*dy and use the door that has the smallest resulting c^2 value. All that being said, having a monster chasing you from room to room is pretty non-standard game behavior. I can't think of many games that do it, as it is pretty brutal. So I would of course use it very sparingly. Posted
1 2 3