
Pathfinding for Tower Defense - ingve
https://www.redblobgames.com/pathfinding/tower-defense/
======
benjaminjackman
Just an FYI: The Dijkstra map algorithms mentioned in the article can be used
for a lot more than just pathfinding.

I’ve used them in a hobby game I’ve been developing with a lot of insight from
[http://www.roguebasin.com/index.php?title=Dijkstra_Maps_Visu...](http://www.roguebasin.com/index.php?title=Dijkstra_Maps_Visualized)
To implement things like determining if resources are connected to an in game
road network. I’ve also used them extensively for the game’s AI for all sorts
of different purposes.

Truly a handy tool to have in a game maker’s belt.

~~~
Waterluvian
This kind of thing gets me eager to play around with game systems but the art
gets in my way. I need to find a kit of generic assets that I can use to
experiment with game systems development. Maybe that's why roguelikes are so
attractive for this kind of thing?

~~~
blackbrokkoli
Try Unity3D! The Asset store has more art than you will ever need, especially
if graphical consistency is no priority

~~~
tokyodude
agreed

I've been to several game jams where I see amazing prototypes come up in 24-48
hours where people use free or really cheap $5-$40 asset store assets

[https://www.google.com/search?q=unity+assets+for+prototyping](https://www.google.com/search?q=unity+assets+for+prototyping)

It's arguably one reason why there are a glut of games. Not only do engines
like Unity and Unreal make it easy to get started but their asset stores have
starter kits for almost any type of game. FPS, 3rd person platformer, racing,
tower defense game, 2D platformer, etc there's a kit that you download and
just start skinning.

[https://assetstore.unity.com/search?q=category%3A90&sc=templ...](https://assetstore.unity.com/search?q=category%3A90&sc=templates/packs)

------
Dzugaru
I’ve always wanted to find a blog post somewhere about SC2-style swarm
pathfinding. Dijkstra part is simple and there are many resources about it,
whats hard is avoidance - units shouldn’t walk through each other. Achieving
that smooth and correct wave-like motion of zerglings isn’t easy - I’ve tried
but the results were ugly.

~~~
MaulingMonkey
[https://www.gamedev.net/forums/topic/597457-pathfinding-
in-a...](https://www.gamedev.net/forums/topic/597457-pathfinding-in-a-space-
based-rts-game/) discusses some of the stuff StarCraft 2 uses,
[http://www.gameaipro.com/](http://www.gameaipro.com/) has some stuff
including for the other SC2, Supreme Commander 2 (
[http://www.gameaipro.com/GameAIPro/GameAIPro_Chapter23_Crowd...](http://www.gameaipro.com/GameAIPro/GameAIPro_Chapter23_Crowd_Pathfinding_and_Steering_Using_Flow_Field_Tiles.pdf)
) that solves similar issues.

------
sowbug
I don't know why I love tower-defense games so much, but I think it might be
because playing feels like programming. Nearly every TD game I've played is
deterministic; in fact, I think random gameplay elements would ruin the
appeal. That means the challenge of the game is not being lucky or twitchy,
but rather figuring out the rules and how to optimally apply them. That's also
what I like about programming.

~~~
loosetypes
Kind of depends on at what level your thinking about though.

In most games some towers can have a random aspects in deciding where/ what to
attack. This can lead to variation of outcomes when replaying a given wave but
amortized over an entire game the results are more-or-less static on a
percentage basis.

Which is amusingly similar to probabilistic algorithms, so maybe that just
reinforces your point.

------
minimaxir
A common tactic in the build-your-own-path TD genre is yo-yoing; that is,
blocking a path to force the creeps to go the long way, then sell the created
block and immediately block the long way, forcing them to go _back_ the long
way. Rinse and repeat.

It always feels like cheating the system, although harder game difficulties
are typically balanced around that mechanic.

~~~
toxik
Most tds I play don’t allow changing your maze during rounds

------
awirth
This reminds me of the documentation for how the game Liquid War did their
pathfinding. The interesting relevance is that it does not use a uniform grid
when calculating the gradients, but instead coalesces squares into power-of-
two squares to "cheat"

[https://ufoot.org/liquidwar/v5/techinfo/algorithm](https://ufoot.org/liquidwar/v5/techinfo/algorithm)

~~~
Cyphase
Oh man, Liquid War. That brings back memories. I'll have to give Liquid War 6
a try. Thanks for the nostalgia.

~~~
tonetheman
I looked that game up Liquid Wars 6 is a GNU game. Who knew.

[https://www.gnu.org/software/liquidwar6/manual/liquidwar6.ht...](https://www.gnu.org/software/liquidwar6/manual/liquidwar6.html#In-
a-nutshell)

It is funny... the manual tells you a lot about the game ... just not how to
actually play. Sigh.

~~~
kbenson
> It is funny... the manual tells you a lot about the game ... just not how to
> actually play.

That feels fitting for a GNU project. Copious amounts of information, little
of it immediately useful for your current question.

------
pouta
I love tower defense games but I could never find one that is either complete
or not filled with ads/paytowin

~~~
meroes
Honestly the best tower defense games are still Warcraft 3 custom maps, which
is getting a refresh with Reforged. I'd recommend YouTD personally.

~~~
imtringued
There are custom game modes for Dota 2 and some of those are pretty good tower
defense games.

~~~
samstave
How can I find these?

~~~
ddorian43
Install free dota2 and goto arcade on the menu.

------
billfruit
I do like how the enemy swarms move in Dungeon Warfare, some randomness is
present so that all of the minions don't follow the same beeline, rather moves
organically like a crowd moving through a corridor.

~~~
hopfog
Dungeon Warfare is a really refreshing take on Tower Defense. I can highly
recommend it. Works good on mobile as well.

------
kibwen
Upvoting before I even read the article, and if you browse the other articles
on the site you'll see why. Red Blob Games is a fantastic resource, check it
out.

------
onychomys
The article is from 2014. We should put that year in the title.

~~~
dkersten
Why does the year matter? Its not time-sensitive news or information.

~~~
lainga
It's just an HN custom

------
wycy
This would’ve been a handy article to have read before/during Advent of Code
2018. There were multiple path finding problems I struggled through.

~~~
teacpde
Oh man, day 15 is almost a party pooper to me, not because of the algorithm,
but the edge cases. Took me ages to debug. It gives me perspectives to game
development.

~~~
masklinn
I don't know that it's quite similar though: advent's day 15 is about
replicating exactly the algorithm used by the system designer, except using a
somewhat hand-wavy description. Because of the testing methodology/system, it
adds a lot of complexity to the task of aggro/pathfinding.

~~~
teacpde
Yeah, you are right, it just happens to remind me day 15. The description is
surely not the best, but I don’t think it’s hand wavy, it went great length to
explain what happens which I appreciate. What frustrates me is it does not
help me to discover certain edge cases. But it reflects reality, there are
bugs you can never imagine until you run into.

------
Ecolog
It's crazy how often this website gets posted on HN for it's pathfinding
tutorials.

------
foxhop
Woah very cool post. I've been planning to learn enough graph theory and the
astar algorithm for pathfinding to make the non-player agents in my game have
enough intelligence to find a target, whether that is a point on the map or
the player itself.

Here is a link to a blog post about my game.

[https://russell.ballestrini.net/yuletide-trains-and-
homegrow...](https://russell.ballestrini.net/yuletide-trains-and-homegrown-
video-games/)

~~~
aisofteng
A* is very simple.

------
Const-me
I did the same a decade ago: [http://const.me/articles/robocalypse-
pathfinding/](http://const.me/articles/robocalypse-pathfinding/)

Source code is available but I'm not sure it'll work with modern compilers.
Unlike that article, I did not use dynamic memory while updating the vector
field.

------
diziet
If this interests you, check out
[https://www.pathery.com/](https://www.pathery.com/), a long standing project
where the goal is to use a limited number of blocks to make the longest path
possible.

------
redcodenl
Given the maze on the website, what is the highest number you can get on a
square when creating a maze?

This is a fun puzzle, I got up to 124:

[https://imgur.com/a/L3OcJpA](https://imgur.com/a/L3OcJpA)

~~~
redcodenl
Ah, just now noticed this:
[https://news.ycombinator.com/item?id=18802763](https://news.ycombinator.com/item?id=18802763)

