I have implemented A* on a Tile Based Game, my Tile class contains a lot of info like Position, TileType, Items, Characters, etc on it. Right now that class has the Edges references(neighbours), movement cost, etc. Should I create a new Class like Node to just contains the Pathfinding related info?

  • 1
    \$\begingroup\$ This is something we cannot decide for you. There is no right and wrong in this - you simply have to decide this for yourself. Remember; when making games making something that works but is ugly is better than making something that's pretty but doesn't work. \$\endgroup\$
    – Charanor
    Commented Oct 18, 2017 at 17:39
  • 2
    \$\begingroup\$ One way to think about this is to imagine a scenario where you would be glad you had made the extra class. If you can't, then don't add the class. In your case let's imagine you need pathfinding in another part of the game, not on the tiles. Now consider: how much work would it be to make the change after the fact, and how likely the imagined scenario is. If you knew you wanted to use the Node class in a different place later, then you should definitely add the class, if the scenario sounds unlikely, perhaps don't bother. If the change is sufficiently small you can wait until later. \$\endgroup\$
    – Ryan1729
    Commented Oct 18, 2017 at 20:35

1 Answer 1


This may not be a real answer (and I'm still new to stack exchange etc) but I'd still like to share my experience.

Last year I had to implement pathfinding in a small game we had to build in college. At first I was also planning on having the pathfinding details (like movement cost, etc) inside the tiles itself but after consulting with my teacher, I decided to create a node structure on top of the tiles, which would contain all the pathfinding logics.

The main argument for this was that it was prettier if I was able to separate my pathfinding from the game, without completely breaking it. And this is the case if all pathfinding-logics are in the node structure you build on-top of the actual tiles.

Might not be much of an answer but I hope this has helped in a minor way.

  • \$\begingroup\$ Welcome to GDSE. This seems to be a good answer to me. You should probably include something else in it (other reasons why it's good or a counter argument on why it isn't), but it's okay in it's current form. \$\endgroup\$
    – Bálint
    Commented Oct 19, 2017 at 7:19

Not the answer you're looking for? Browse other questions tagged .