Skip navigation

Monthly Archives: September 2016

When I first sat down to implement train path finding on placed tracks I had an overly complicated model in my head of how tracks connected and how one might sniff out a path on the track.  It involved allowing “turning around” at a station that was not the train’s destination – how do you indicate that it’s “OK” to be traveling the same path but now the other direction… Then, in the spirit of MVP and my original “simplify it if you can and the game is still fun” mentality I realized that trains don’t need to be able to turn around at stations.  The rules I put in place for track layout guarantee that a train can get from any hex to any other hex without backtracking on hexes it has already visited.  With that understanding there are no circumstances where turning around at a station nets a shorter path or opens up solutions that wouldn’t have otherwise existed.  It was just me wanting to solve the hardest, juiciest problem.

After throwing out the idea of non-destination station turnarounds the entire problem got way easier.  A simple “bucket fill” path solving algorithm nets all possible solutions and then I just ask for the one that costs the least.  Cost is a combination of distance and type of terrain the solution has to pass though.

Here we see a train following a solved-for path from Charlotte to Donald’s Tree Farm.  Sorry about the gif artifacts, those are not there in the real rendering.

engine

 

Next steps:

  • Box cars
  • Supply/Demand netting from train deliveries
  • Player Goals

Working down the list of MVP requirements I have done a lot of work.

Resources are now labeled on the map. I had to do this so I could show the label in the train’s stop list, so why not add it to the map while I had the information on hand.

Stations can now be placed.  When in station placement mode, hexes that are available for station placement are highlighted in blue.

screenshot1

A station has been placed in “Tulsa” and confirmation is about to take place:

screenshot2

 

A few more stations are placed and the player can now buy a train.  The player selects the type of engine and the different stations a train will visit:

screenshot3

After selecting “Add Stop” (need a better name for “stop”. “Way point”?) the map is available and all hexes with stations on them are highlighted in blue, indicating they are available for selection.  Hexes with a stop already placed on them for this train are highlighted in yellow as a reminder to the player that the train is setup up to stop there already, but these stations can be selected again if the player wants a train to visit any particular station more than once in it’s loop:

screenshot4

The stations are listed in order that the train will visit them.  Ordering and deleting of rows is available:

screenshot5

I have spent the last two and a half weeks working diligently on my MVP for project Cat Phone.  The plan I described in my first MVP post has been paying off.  I have worked on the project casually and have focused on my MVP one item at a time.

I purchased a hex framework a long time ago when I first got interested in re-booting this project and have been sitting on it ever since.   This gave me a very easy way to implement item number 1 on the MPV list: a hex map.  From there, I have added random resource nodes around the map, and most importantly, added path finding and track layout.   I have put into place rules like: Only one branch or resource node per hex tile.  The hex map and these rules allow me to simplify track path finding and layout quite a lot.

If you look closely at the bottom left of these screen captures, you can see the track layout working with branching.  In these pictures, new track to be placed is rendered in a purple color and track that has been placed is rendered in a yellow-brown.  Resources are spheres rendered in a color depicting their type (green for timber, off-white for color, etc.)

Next on the list to tackle is station placement, then train path finding.

screenshot2 screenshot3 screenshot4 screenshot5 screenshot6