Friday Facts #198 - Rail segment visualisation

Regular reports on Factorio development.
SwampD0nkey
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Feb 03, 2017 4:00 am
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by SwampD0nkey »

No reason to over complicate it. Just show indications at intersections where a signal would be relevant. At those intersections have a color coded overlay on which track has priority or if it has none at all. Simple, easy, expandable.

If you got problems, I got solutions; free of charge.

Kevin Ar18
Inserter
Inserter
Posts: 20
Joined: Tue Jul 12, 2016 10:56 pm
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by Kevin Ar18 »

I think the block colors is a great idea to help people understand. However, one thing that helped me a lot in Simutrans was a command to show which blocks are reserved by trains as the trains are moving.

In this screenshot, the red shows which parts of the track are reserved by trains as they move around.

Image
from: http://forum.simutrans.com/index.php?topic=17060.0

Factorio might have this as a debug feature (not sure), but maybe it could be made a first class feature you can use in a normal game.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7351
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by bobingabout »

Kevin Ar18 wrote:I think the block colors is a great idea to help people understand. However, one thing that helped me a lot in Simutrans was a command to show which blocks are reserved by trains as the trains are moving.

In this screenshot, the red shows which parts of the track are reserved by trains as they move around.

Image
from: http://forum.simutrans.com/index.php?topic=17060.0

Factorio might have this as a debug feature (not sure), but maybe it could be made a first class feature you can use in a normal game.
If you hadn't said that was Simutrans, I would have thought it was OpenTTD with a graphics pack installed.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

mrvn
Smart Inserter
Smart Inserter
Posts: 5682
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by mrvn »

Kevin Ar18 wrote:I think the block colors is a great idea to help people understand. However, one thing that helped me a lot in Simutrans was a command to show which blocks are reserved by trains as the trains are moving.

In this screenshot, the red shows which parts of the track are reserved by trains as they move around.

Image
from: http://forum.simutrans.com/index.php?topic=17060.0

Factorio might have this as a debug feature (not sure), but maybe it could be made a first class feature you can use in a normal game.
No debug needed. just place the mouse over the train.

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 950
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by ratchetfreak »

widders wrote:So I had an idea earlier and it solved some problem, I can remember the idea, but I can't remember the problem, anyway.

Why not integrate the item stack into the item class? An item after all is a stack of 1. Possibly it's too late in development to implement such a change but 99% of items in a game are non-dynamic so there's no need to track them (who cares which iron plate from the 5000 you've made gets used?) and the dynamic items I can't think of any which stack above 1. Things like ammo and science which have a usage bar get combined when you combine two stacks anyway so that should be simple to track as only the "top" item has a damage attribute associated with it.

Still can't remember what the problem that solved was but from what I can see you've got a memory object for each item in a stack plus the stack, this way would mean only one (if slightly larger) memory object per stack regardless of the number of items.

Possibly this could even combine with the belt optimizations as that one object stores how many items there are which in turn represents a length on the belt.
Because you want the ItemStack class to be fixed size so they can be stored by value in inventories otherwise you have to use a pointer anyway.

Currently the field to store all the items in it for inventories is something like

Code: Select all

std::vector<ItemStack> inventory;
If you put the Stack count into the Item that has to become:

Code: Select all

std::vector<std::shared_ptr<Item>> inventory; //or unique_ptr depending on surrounding code.
That means it's still an indirection to get to the actual data of the item. Its now even worse because you have to follow the indirection to even get the stack count and you can't singleton stateless Items. That lat bit means a lot of extra allocations when factorio does factorio things.

My suggestion of adding a union as a small value optimization will also help when the amount of state to keep is small:

Code: Select all

struct ItemStack
{
  ItemCountType count;
  ItemID id;
  union{
    float damage; // for progress bars like ammo, armor, damaged buildings, ...
    Item* item; // dynamically allocated classed based on the item type
  }
};

Kevin Ar18
Inserter
Inserter
Posts: 20
Joined: Tue Jul 12, 2016 10:56 pm
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by Kevin Ar18 »

mrvn wrote:No debug needed. just place the mouse over the train.
Oh good catch; except it is very hard to follow the train so you can watch the signalling on a large scale. Maybe add a button in the trains menu that you can toggle on/off ... so you can see reserved blocks for all trains simultaneously?
bobingabout wrote:If you hadn't said that was Simutrans, I would have thought it was OpenTTD with a graphics pack installed.
If you like TTDX, then try Simutrans (Regular+pak128 or Experimental+pakBritain). I gather that it has more complex signaling options and more complex passenger and freight.

ben04
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Mar 25, 2016 6:04 pm
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by ben04 »

Perhaps color the rail sprites instead of drawing a line on top of them. Drawing it with a shifted hue should suffice.

Engimage
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Jun 29, 2016 10:02 am
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by Engimage »

Rails have multi-layer textures and the topmost one is a top rail bar surface. Maybe it is a good idea to use tint color on that one to visualize segment colors.
The only problem here is to visualize block margins if you will opt to use signal colors on rails (red,yellow,green) as I wrote above opposed to multicolor current debug style.

User avatar
Nondre
Burner Inserter
Burner Inserter
Posts: 16
Joined: Sun Nov 16, 2014 6:12 am
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by Nondre »

The arrows that are already present can be added at the beginning and ending of each block, facing the direction(s) traffic needs to go, in a color that separates them from the other rail blocks.
You might also just align the debug whisker plot looking lines to the signals themselves, parallel to the rails, rather than on top of them, to so traffic blocks for each direction of traffic can go on either side.

thelordodin
Fast Inserter
Fast Inserter
Posts: 148
Joined: Fri Jan 06, 2017 1:54 am
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by thelordodin »

You cat just use a continious frame around each block of rails instead of colors.
It can be only shown if a user hovers mouse over any signal. Also section used to activate red signal can be highlighted this way - see attachment (of course its not final design proposial :D )
Attachments
Visualisation.png
Visualisation.png (813.33 KiB) Viewed 7660 times

mOoEyThEcOw
Inserter
Inserter
Posts: 22
Joined: Fri Mar 17, 2017 11:27 pm
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by mOoEyThEcOw »

ratchetfreak wrote:

Code: Select all

struct ItemStack
{
  ItemCountType count;
  ItemID id;
  union{
    float damage; // for progress bars like ammo, armor, damaged buildings, ...
    Item* item; // dynamically allocated classed based on the item type
  }
};
I second that, that is quite efficient. Probably even better because Item probably uses a bunch of virtual methods to get that information, so that's probably two indirections saved (one for the object pointer, one for the vtable lookup) in the vast majority of cases.

esotericist
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Jan 15, 2016 6:45 am
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by esotericist »

So, I seem to be missing something, since I can't understand what the rail visualization is showing.

What rail tutorial is being discussed in the FFF? I just went and updated factorio from stable to experimental to try to find it, and I can't seem to do so. I've never understood rails in factorio, so I've always avoided doing anything interesting with them.

Patashu
Fast Inserter
Fast Inserter
Posts: 130
Joined: Mon May 08, 2017 11:57 pm
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by Patashu »

esotericist wrote:So, I seem to be missing something, since I can't understand what the rail visualization is showing.

What rail tutorial is being discussed in the FFF? I just went and updated factorio from stable to experimental to try to find it, and I can't seem to do so. I've never understood rails in factorio, so I've always avoided doing anything interesting with them.
Start or load a game, and click on the 'university hat' icon in the top right corner, it's part of a row of six buttons

User avatar
fechnert
Inserter
Inserter
Posts: 32
Joined: Fri Jun 30, 2017 12:48 pm
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by fechnert »

IronCartographer wrote:Here's an idea: "Less is more" AKA "What do current signals/rail see, and why?"
Definitely, this looks awesome! :o
Image[url=steam://friends/add/'.76561198066150999.']Image[/url]

Julissa Doe
Burner Inserter
Burner Inserter
Posts: 12
Joined: Thu Jul 06, 2017 9:48 pm
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by Julissa Doe »

Will color indicators be sufficient to describe all the information? I have never quite understand how rails work in this game, and I don't know if visualization helps in any way. I'd assume it helps if you have some understanding to the underlying system.

Jan11
Long Handed Inserter
Long Handed Inserter
Posts: 82
Joined: Mon Sep 12, 2016 5:03 pm
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by Jan11 »

It`s a good idea but I´m more interested in the new HD Landscape. ( For me the landscape is the biggest problem in this game) It`s not nice at all. It`s only a big plane surface. No hills, no space problem etc etc

JohnyDL
Filter Inserter
Filter Inserter
Posts: 533
Joined: Fri May 16, 2014 3:44 pm
Contact:

Re: Friday Facts #198 - Rail segment visualisation

Post by JohnyDL »

I've been thinking about this for a bit and maybe this Is one of those places for Alt-mode to be a factor but I've also got a few other thoughts

First off Combine the positions of cars and the arrow directions, there's no need for both the yellow arrows and multiple train cars to both be shown why not make the front train car a triangle indicating an engine and direction rather than just another space

Make Rail signals part of the track rather than snapping to the sides, I'm kind of thinking of this the same way red and green wires become part of chests and poles and inserters and belts when they're used, they have no independent use to them by making them a part of the track there's no ambiguity about where they can be placed and no need for the snap grid, with the line and bar method of displaying blocks new signals can only be placed on lines not between bars (excluding making a signal bidirectional)

Someone did mention the four colorability of planar graphs (basically what an all above ground train network would be) in this thread and working this out could be it's own thread independent of the normal tick process as it's not crucial to play so those colours could be worked out in the background while a player isn't working on parts of the rail network. While the player is working however, this colouring could be preserved for any unaltered blocks with new blocks getting their colours assigned from a predefined list that as best as possible are distinct and are hopefully only being used once on the map at a time, this lets the player see what they're working on and what is unaffected. It would also be a superficial way of saying the section of track is now integrated with the wider train network because when the user isn't looking the work in progress colours could all be removed and the standard 4 colours of the train network reshuffled to work, I say superficially because it was always part of the network as far as the trains are concerned but the colours homogenising would I think be satisfying. If the colours chosen for the 4 colour mode are say red, green, blue and black you also end up leaving white available as a highlight colour for blocks you're directly working with, the block ahead of the signal you're adding or removing getting a white line and bar while the the block behind being filled up with the train symbol which is already in white.

Finally the alt mode could let people see this more detailed view or the classic view (and they could choose which is which with options)

Yes I'll work on a few pictures to show what I mean but I'm not at the right computer for such things right now :(

Post Reply

Return to “News”