[UI] Your first script versus the English Alphabet

The Galaxy Lives On! Distant Worlds, the critically acclaimed 4X space strategy game is back with a brand new 64-bit engine, 3D graphics and a polished interface to begin an epic new Distant Worlds series with Distant Worlds 2. Distant Worlds 2 is a vast, pausable real-time 4X space strategy game. Experience the full depth and detail of turn-based strategy, but with the simplicity and ease of real-time, and on the scale of a massively-multiplayer online game.

Moderator: MOD_DW2

Post Reply
StormingKiwi
Posts: 256
Joined: Thu Feb 11, 2021 6:35 am

[UI] Your first script versus the English Alphabet

Post by StormingKiwi »

In DW2, items sorted by name are sorted for a machine instead of the human using the software. This was also the case in DW: U.
Sorting algorithms should sort alphanumeric strings in the order that users would expect, especially as software becomes increasingly used by non-technical people. Besides, it's the 21st Century; software engineers can do better than this.


Examples provided:


Incorrect:
Implemented Sorting (DW)
Implemented Sorting (DW)
DW Sorting.png (27.92 KiB) Viewed 264 times

Correct:
Natural Sorting (Windows)
Natural Sorting (Windows)
Natural Sorting.png (2.15 KiB) Viewed 264 times


How to implement the solution (with working links to algorithms in a variety of languages):
https://web.archive.org/web/20210207124 ... hanum.html
AKicebear
Posts: 517
Joined: Sat Jul 26, 2014 2:11 pm

Re: [UI] Your first script versus the English Alphabet

Post by AKicebear »

Faster solution - Fleet 001, etc.

My own approach is
A-01
D-01
I-01
R-01

As starting points for attack, defense, invasion and raiding fleets. Works well for me, but does require manual renaming at formation.
StormingKiwi
Posts: 256
Joined: Thu Feb 11, 2021 6:35 am

Re: [UI] Your first script versus the English Alphabet

Post by StormingKiwi »

AKicebear wrote: Thu Jan 26, 2023 9:28 am Faster solution - Fleet 001, etc.

My own approach is
A-01
D-01
I-01
R-01

As starting points for attack, defense, invasion and raiding fleets. Works well for me, but does require manual renaming at formation.
This is primarily feedback for the devs.

Expecting users to compensate for sloppy programming practice is unrealistic and lazy. It's simple to sort alphabetically instead of by ASCII.
AKicebear
Posts: 517
Joined: Sat Jul 26, 2014 2:11 pm

Re: [UI] Your first script versus the English Alphabet

Post by AKicebear »

No disagreement there - it would be nice if it sorted the way you've described.
User avatar
Radamanthe
Posts: 54
Joined: Tue Mar 01, 2022 12:40 pm
Location: FRANCE

Re: [UI] Your first script versus the English Alphabet

Post by Radamanthe »

StormingKiwi wrote: Thu Jan 26, 2023 11:06 am This is primarily feedback for the devs.

Expecting users to compensate for sloppy programming practice is unrealistic and lazy. It's simple to sort alphabetically instead of by ASCII.
Before talking about "sloppy" or "lazy" programming, one should consider what making games is all about. There are many sorting algorithms, all being inherently slow, and the natural sort is probably one of the slower of them all because before comparison, it must split the strings, and with many operations.

Thus, it's not just about choosing this sort because it's the best human experience, but also keeping a good framerate because it's also the best human experience. This is especially true when you do sort at every frame (which is not the case of a list of file names in an explorer window of the OS) like it seems to be the case of every sort in the main left window of DW2 (even when paused, BTW).

So yes, game devs can optimize. There are some ways to do it here: cache the sort or the splitted strings (memory cost), not doing it every frame but only a few frames appart (the lazy optimize, making these frames longer to process and potentially altering the steadiness of FPS), or only one time when the list appears + with messaging event based triggers when any change is detected from the many places it can happen in the engine (probably the less CPU costly, and that's even what OS do nowadays with explorer's file names), etc.

This is planning, work... time ;)
StormingKiwi
Posts: 256
Joined: Thu Feb 11, 2021 6:35 am

Re: [UI] Your first script versus the English Alphabet

Post by StormingKiwi »

Radamanthe wrote: Sat Jan 28, 2023 12:22 am
StormingKiwi wrote: Thu Jan 26, 2023 11:06 am This is primarily feedback for the devs.

Expecting users to compensate for sloppy programming practice is unrealistic and lazy. It's simple to sort alphabetically instead of by ASCII.
Before talking about "sloppy" or "lazy" programming, one should consider what making games is all about. There are many sorting algorithms, all being inherently slow, and the natural sort is probably one of the slower of them all because before comparison, it must split the strings, and with many operations.

Thus, it's not just about choosing this sort because it's the best human experience, but also keeping a good framerate because it's also the best human experience. This is especially true when you do sort at every frame (which is not the case of a list of file names in an explorer window of the OS) like it seems to be the case of every sort in the main left window of DW2 (even when paused, BTW).

So yes, game devs can optimize. There are some ways to do it here: cache the sort or the splitted strings (memory cost), not doing it every frame but only a few frames appart (the lazy optimize, making these frames longer to process and potentially altering the steadiness of FPS), or only one time when the list appears + with messaging event based triggers when any change is detected from the many places it can happen in the engine (probably the less CPU costly, and that's even what OS do nowadays with explorer's file names), etc.

This is planning, work... time ;)
Do you realise the initial discussion was talking about the result of the sort, right, and not the algorithm used to effect that sort?

As I see it, you made these points in your paragraphs:

Algorithmic efficiency:
Algorithmic Efficiency
Algorithmic Efficiency
Sorting Algorithms Table.png (79.55 KiB) Viewed 121 times
Quora Post
Quora Post
Quora Post.png (86.84 KiB) Viewed 121 times
I hope those two attachments make the algorithmic efficiency point clear to you.

Choice of algorithm and optimisation:
This is a fantastic post where you identify a problem, circle the correct solution with the provision of specific examples of a correct and a wrong solution, conclude with the correct solution, and somehow imply that the correct solution should not have already been implemented on 10 March 2022 because of resource constraints.

The name of the fleets is a list. The list is unsorted. You're saying the algorithm runs on every frame from 1 to infinity.

If the list is already sorted by frame 2, it does not need to be sorted frame 2. It only needs to be sorted frame 2 if it is unsorted. Once sorted, there are only limited ways that a (list of fleets sorted by names) can become unsorted. All are changes to the precedent data.
Does the Excel fx=Sort() function automatically re-calculate when no change is made to the precedent data?

In DW2, according to you, the sort algorithm runs on every frame: If true, astoundingly sloppy programming.

When I said sloppy programming, I was talking about the fairly difficult and rare skill for programmers of "designing a human-machine interface for the convenience of the human", not the basic skill of "designing a computer program to avoid wasting computational resources on calculations it does not need to do."
User avatar
Radamanthe
Posts: 54
Joined: Tue Mar 01, 2022 12:40 pm
Location: FRANCE

Re: [UI] Your first script versus the English Alphabet

Post by Radamanthe »

StormingKiwi wrote: Sat Jan 28, 2023 5:21 am Do you realise the initial discussion was talking about the result of the sort, right, and not the algorithm used to effect that sort?
Do you realise that I did not talk about any specific algorithm and that YOU did? I realised that you proposed a solution:
StormingKiwi wrote: Thu Jan 26, 2023 7:21 am How to implement the solution (with working links to algorithms in a variety of languages):
https://web.archive.org/web/20210207124 ... hanum.html
Natural sort is not a sort algorithm per se. It’s something more you do, whatever the main sort algorithm. And you do it for all elements.
As I see it, you made these points in your paragraphs:

Algorithmic efficiency:

Sorting Algorithms Table.png

Quora Post.png

I hope those two attachments make the algorithmic efficiency point clear to you.
In fact, again, YOU made these points, not me. And this time with algorithmic efficiency of many known sort algorithms which, again, has nothing to do with those more things you have to do with each elements, whatever the used sort algorithm.

And quite frankly, no need to be a monster programmer to know for a fact that sorting an almost already sorted list is quite inefficient with quick sort algorithm. Not even only considering the approach, nodes or so called buckets.
The name of the fleets is a list. The list is unsorted. You're saying the algorithm runs on every frame from 1 to infinity.
No, I supposed that. I said “it seems”. Please don’t reword my sentences. This is based on obvious behaviours than even you have probably noticed… or maybe not? More below.
In DW2, according to you, the sort algorithm runs on every frame: If true, astoundingly sloppy programming.
You’ll have then to explain how it’s not very rare to see some of these lists update themselves from time to time, in a quite ecstatic way, some elements moving a little back and forth rapidly, and not just deleted/added/modified elements during the course of simulation. I wish I had captured a video of this.

And more importantly, the fact that it happens even when the game is paused (and the latency delay of the pause largely passed… another behaviour you probably noticed too, but I prefer you not to argue it is certainly due to that and the list updating a little due to simulation still running for a few seconds). Looks like some inherent rounding errors in some values considered during the sort. Depending on what exactly? Distances may be a good guess… talking about big floats numbers, but who knows? Not open source, you see. Anyway, what could modify the order, even a little then, and so rapidly, back and forth, besides another sort invocation? Explain. Maybe we’ll have fun both of us.

And you know what? Even this is not that sloppy, to me. I mean, when the simulation runs… more of a programming time compromise, something that can be dealt with later. I can understand that, I can pardon that, which looks like to be a heresy to you. Now, during the pause is another story… Many games do stuff they don’t need during pause. DW2 is not an exception, and my fan keeping steadily crazy for long pauses is the main proof. Man, when I want to pause for long periods, doing something else without saving and quitting the game, I took the habit to bring up the research screen, where I noticed the engine is a lot more machine cycles friendly, as this is the only place where I noticed the fan slowing down after a while. No need to bring up the task manager or any performance analysis tool, I keep it for my own engine code where I can make real use of the results of these tools.
When I said sloppy programming, I was talking about the fairly difficult and rare skill for programmers of "designing a human-machine interface for the convenience of the human", not the basic skill of "designing a computer program to avoid wasting computational resources on calculations it does not need to do."
You just took it wrong. Your post, your main point is of interest. I never implied it was unwelcome. The sloppy and lazy thing in the later post was a bit too much to me. And I can see some sloppy and lazy things in other more obvious areas. That's quite common in game industry, and not only independent studios, far from it.
Post Reply

Return to “Distant Worlds 2”