Author Topic: When can we get the 64-bit version of C#?  (Read 4121 times)

0 Members and 1 Guest are viewing this topic.

Offline Steve Walmsley

  • Aurora Designer
  • Star Marshal
  • S
  • Posts: 11695
  • Thanked: 20557 times
Re: When can we get the 64-bit version of C#?
« Reply #15 on: February 11, 2021, 05:01:15 AM »
If everything were done using 64 bit integers, the minimum distance could be decreased dramatically!

Assuming everything is signed, 32bit integers can represent up to 2^31. At 10,000km spacing, that gives us a max distance from the center of the coordinate system (presumably the primary) of 2.3 lightyears. It's probably reasonable to want to be able to go at least a lightyear, so no less than 5000 km spacing is appropriate.

With 64bit signed integers, if we want to go 1 lightyear out, we can use a spacing of about 1mm.

Using 64bit integers, a game could theoretically track the exact impact position of every weapon battery based on the direction they were fired and the position of the weapon on the ship. Though, honestly, I might go with floats anyway since my expectation is that computers have more FPUs than integer units and so it would possibly be faster. And 64 bit floats have plenty of precision at reasonable distances. But I haven't tested it in detail.

I'm fairly sure from my explorations of the DB that distance is not limited by the integer size. Coordinates in the DB are stored as floats, and the actual space between ships is not constrained to being a multiple of 10,000 or any other value as far as I know (maybe 1 km). The 10,000 km minimum range is mostly an abstraction for gameplay purposes as well as a small compromise for some degree of realism (as literal 0 km range never occurs).

Yes, the basic coordinate system is in kilometres, but it goes down to 8 or 9 decimal places, so the position of a ship or any other object is known to fractions of a millimeter.
 

Offline Steve Walmsley

  • Aurora Designer
  • Star Marshal
  • S
  • Posts: 11695
  • Thanked: 20557 times
Re: When can we get the 64-bit version of C#?
« Reply #16 on: February 11, 2021, 05:01:52 AM »
It would be interesting to know what is the main thin that slows down the game... my games usually slow down to 4-5 seconds and stay there for a rather long time. I don't think this is an issue or anything just would be interesting to know for future optimisation what is the main thing that slows down the game?

Movement orders is the greatest time-sink.
 
The following users thanked this post: Harold65

Offline Jorgen_CAB

  • Admiral of the Fleet
  • ***********
  • J
  • Posts: 2839
  • Thanked: 674 times
Re: When can we get the 64-bit version of C#?
« Reply #17 on: February 11, 2021, 05:17:15 AM »
It would be interesting to know what is the main thin that slows down the game... my games usually slow down to 4-5 seconds and stay there for a rather long time. I don't think this is an issue or anything just would be interesting to know for future optimisation what is the main thing that slows down the game?

Movement orders is the greatest time-sink.


So I assume that each fleet will individually calculate pathing on each sub pulse as many destinations will change with each sub pulse. This probably then make civilians the main culprit as they always move independently.

So in order to optimise then a slight adjustment to how civilians work could significantly improve late game performance?

Not saying I have a great idea at the moment, but good to know and perhaps there is a better solution that keep it working mainly the way it does.
 

Offline TheTalkingMeowth

  • Captain
  • **********
  • T
  • Posts: 494
  • Thanked: 203 times
  • Gold Supporter Gold Supporter : Support the forums with a Gold subscription
    2021 Supporter 2021 Supporter : Donate for 2021
    2022 Supporter 2022 Supporter : Donate for 2022
Re: When can we get the 64-bit version of C#?
« Reply #18 on: February 11, 2021, 08:25:02 AM »
Yes, the basic coordinate system is in kilometres, but it goes down to 8 or 9 decimal places, so the position of a ship or any other object is known to fractions of a millimeter.

Exact weapon impact tracking when???
 

Offline nuclearslurpee

  • Admiral of the Fleet
  • ***********
  • Posts: 3009
  • Thanked: 2265 times
  • Radioactive frozen beverage.
Re: When can we get the 64-bit version of C#?
« Reply #19 on: February 11, 2021, 11:50:57 AM »
Yes, the basic coordinate system is in kilometres, but it goes down to 8 or 9 decimal places, so the position of a ship or any other object is known to fractions of a millimeter.

Exact weapon impact tracking when???

Coming Soon™ in Newtonian Aurora!  ;)
 

Offline StarshipCactus

  • Lt. Commander
  • ********
  • S
  • Posts: 262
  • Thanked: 87 times
Re: When can we get the 64-bit version of C#?
« Reply #20 on: February 11, 2021, 05:53:51 PM »
If you had an immortal Steve who spent all day pressing random buttons on his keyboard, how long would it take for any given feature to be added?

Alternatively, if you had an arbitrarily high but still finite number of Steve's randomly pressing buttons on his keyboards, how long would it take for one of the Steve's to add any given feature?
 

Offline nuclearslurpee

  • Admiral of the Fleet
  • ***********
  • Posts: 3009
  • Thanked: 2265 times
  • Radioactive frozen beverage.
Re: When can we get the 64-bit version of C#?
« Reply #21 on: February 11, 2021, 05:56:01 PM »
If you had an immortal Steve who spent all day pressing random buttons on his keyboard, how long would it take for any given feature to be added?

Alternatively, if you had an arbitrarily high but still finite number of Steve's randomly pressing buttons on his keyboards, how long would it take for one of the Steve's to add any given feature?

Ironically, in both cases it takes longer on average for a given feature to be implemented, however the number of written accounts of Precursors getting theirs handed to them increases exponentially with the number of Steves. Science is perplexed at this finding.
 

Offline QuakeIV

  • Registered
  • Commodore
  • **********
  • Posts: 759
  • Thanked: 168 times
Re: When can we get the 64-bit version of C#?
« Reply #22 on: February 11, 2021, 09:12:18 PM »
It would be interesting to know what is the main thin that slows down the game... my games usually slow down to 4-5 seconds and stay there for a rather long time. I don't think this is an issue or anything just would be interesting to know for future optimisation what is the main thing that slows down the game?

Movement orders is the greatest time-sink.

I'd like to take a crack at mentioning a possible solution, this will be completely bastardized since I have no familiarity with your code whatsoever.  And by possible solution, I mean a relatively vague example of threading described in terms of movement orders.

This assumes that movement orders aren't inter-dependent to eachother, which as far as I know is true.

You could concievably set up worker threads that look at a thread-safe queue of movement order tasks (objects describing the movement order and maybe including a pointer to where to write the results of the calculation) and give the threads the ability to insert the results of their calculation into the appropriate destination (hard to say what that would look like exactly).  Thread safe task queueing is a relatively common multithreading technique.  You don't really need to worry about the timing of the threads since the game is turn based so you can just wait for all of the threads to finish before going to the next queue item.

In this case 'worker thread' would be a function (threadProc in this example) that takes a pointer to the task queue as a parameter as well as pointers to any other info it would need access to in order to do the calculation (pointers to variables containing info about the world for instance).  Most C# objects support concurrent reading, so generally (emphasis on generally) you would only need a thread-safe task queue for the threads to pull jobs out of until they see that the queue is empty.  This also assumes that the final destination of the calculation results is not going to be getting hit by multiple threads, which is usually reasonable when you are doing a bunch of serial calculations (normally they aren't overwriting eachothers results).

Even if you don't use this for anything, I rather suggest playing around with threads in general, because while you are right that generally threading is pretty dangerous, this might be an exception.  Usually threads are particularly problematic when they are running continuously and are directly interacting with eachother in a manner where timing is important and whatnot.  In the turn-based context, you can usually just wait for all of the threads to finish working (in this case you could loop over the list of active threads and call .join() on all of them, which is a blocking call, so doing that will in effect wait until each thread is finished before the code moves on).

By the way I am just trying to share some information, I am actually a software developer so I am not blowing smoke up your ass here, I just wanted to mention the above since it seems like you might be overestimating the difficulty of threading in this case (but also maybe not depending on how the code works/how much you already know).

Apologies if you already knew all of this, or of the movement orders themselves are inter-dependent (which would also throw a huge wrench in this).
« Last Edit: February 11, 2021, 09:43:44 PM by QuakeIV »
 

Offline nuclearslurpee

  • Admiral of the Fleet
  • ***********
  • Posts: 3009
  • Thanked: 2265 times
  • Radioactive frozen beverage.
Re: When can we get the 64-bit version of C#?
« Reply #23 on: February 11, 2021, 10:23:42 PM »
This assumes that movement orders aren't inter-dependent to eachother, which as far as I know is true.

This actually isn't true. There are a number of cases where movement orders do interact with each other, including (but by no means limited to):
  • A fleet needs to move to the location of another fleet. Easily the most common case. A particular sub-case is missile tracking of course.
  • Related to the above, a fleet needs to move in relation to another fleet, e.g. when using escort formation orders.
  • A fleet needs to move relative to planetary or other body motion. This may be handled differently in the code, though, I'm not sure how body motion is done.
  • Two fleets moving independently are near enough that spotting happens (actually I believe this occurs generally when fleets of different races are in the same system). This may or may not be handled by just checking after a sub-pulse before moving on to the next step in the game loop, but I wouldn't be surprised if there's some weird interactions in the code because of this and other mechanics.

All that said, I suspect that when Steve says "movement orders" he doesn't just mean the raw calculation of trajectories but also the NPR logic that goes into deciding what orders to make. Of course it's better to let the man himself clarify his meaning for certain.
 

Offline QuakeIV

  • Registered
  • Commodore
  • **********
  • Posts: 759
  • Thanked: 168 times
Re: When can we get the 64-bit version of C#?
« Reply #24 on: February 11, 2021, 10:26:03 PM »
If movement orders calculate intercepts by looking at the result of each-others movement calculations (rather than just extrapolating from the last ticks movement and picking that as a destination) then that would indeed probably rule out threading.  It would require that the list of movement orders be topologically sorted so that they have non-nonsense results to work off of.

Conversely, it would explain why when you tell two fleets to join eachother then they tend to horribly spaz out.  Maybe thats actually how it works.

e:  That would actually also explain the 'initiative' system.
« Last Edit: February 11, 2021, 10:28:58 PM by QuakeIV »
 

Offline TheTalkingMeowth

  • Captain
  • **********
  • T
  • Posts: 494
  • Thanked: 203 times
  • Gold Supporter Gold Supporter : Support the forums with a Gold subscription
    2021 Supporter 2021 Supporter : Donate for 2021
    2022 Supporter 2022 Supporter : Donate for 2022
Re: When can we get the 64-bit version of C#?
« Reply #25 on: February 12, 2021, 08:52:38 AM »
There is one place movement orders don't interact: different star systems. If you precalculate the first opportunity for someone to transit into or out of the system, you are then free to execute movement in parallel until you reach that point in time. Though this CAN interact with intercept orders that cross system boundaries. A rule change might be necessary to make this implementable (if ships don't recalculate their choice of jump point to enter the system based on target location, intercept orders would no longer have any interaction).
 
The following users thanked this post: Droll

Offline QuakeIV

  • Registered
  • Commodore
  • **********
  • Posts: 759
  • Thanked: 168 times
Re: When can we get the 64-bit version of C#?
« Reply #26 on: February 12, 2021, 01:55:47 PM »
Notably that might up the complexity if he needs to formulate different task lists for the worker threads for each system.