121
Programming / Re: Pathfinding implementation not working the way I want it to.
« on: March 25, 2010, 06:35:41 AM »
So then why would my program be giving such a weird result?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
################################################################################
################################################################################
################################################################################
################################################################################
####.###########################################################################
#####.##########################################################################
######.#########################################################################
#######.########################################################################
########.#######################################################################
#########.######################################################################
##########.########################.############################################
###########.######################.#############################################
############.##################...##############################################
#############.##############...#################################################
##############.########.....####################################################
###############.##.....#########################################################
################..##############################################################
################################################################################
################################################################################
################################################################################
####.......#####################################################################
###########.......##############################################################
##################.....#########################################################
#######################.....####################################################
############################...#################################################
###############################...##############################################
##################################.#############################################
###################################.############################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
float GCostFuncs_Flat(u16 y1, u16 x1, u16 y2, u16 x2)
{
return(BASE_COST);
}
float HCostFuncs_Euclidean(u16 y1, u16 x1, u16 y2, u16 x2)
{
double ydist(y2), xdist(x2);
ydist -= y1;
xdist -= x1;
return(floor(sqrt(ydist*ydist + xdist*xdist))*BASE_COST);
}
First up, choose a language you are comfortable with and familiar with using it. If you plan on learning a language by coding a roguelike, I would suggest starting on a small roguelike attempt first. Trying to achieve a large goal in a new language is difficult at best. As for which is more popular... download a few roguelikes and see...
On map/level generation... there are plenty of articles about this, the pitfalls and solutions. Path finding can be as simple or as complex as you choose to make it. And lets define slow... You are typically working with a small map (lets say 80x20), which even if you have to visit EVERY location four times you are only looking at 6400 visits to each location. Now this may have been a problem pre-1995, but I am fairly sure a dual-quad-core running the latest Radeon ANSI-8192 GPU will have no problems performing this task before you can blink.
My suggestion - go write some simple tests... see how the code works... this will help understand what makes things slow or fast.
How can one make a good level generator that generates levels without having tunnels remove the walls from rooms
There are many ways to prevent that. Start from placing rooms so that they don't have walls next to each other, or if they have the walls are removed or a special corridor is made between them to connect them.
When you make corridors it's good not to make them travel over another rooms (this may be prevented with pathfinding or connecting rooms that are close).
Pathfinding is probably the tool you need to solve problem situations.