Recent Posts

Pages: [1] 2 3 ... 10
1
I don't want to turn this thread into a programming debate, which is one of the reasons that I rarely post code ;)

I hope that none of the other readers of this thread have been put out by our monopolization of the topic of discussion :)

Are you suggesting that instead of a new list, I use the LINQ without assigning to a new list as the target in the foreach loop?

If so, I prefer to avoid that. It's harder to read and harder to debug and those are more important to me than straight performance.

Yes, both the CurrentSystems and PossibleSystems variables would be IEnumerable<KnownSystem> instead of List<KnownSystem>. I can’t really see how the code would be more difficult to read, since everything else would be identical except that you would just not call ToList().

However, I suppose I know what you mean about debugging. You want to stop at a breakpoint and be able to view the lists in the debugger. I tend to forget that not everybody can use omniscient debugging yet (I use a debugger called Pernosco a lot, but it is for Linux only.) If I were using a regular debugger and I wanted to verify which systems had been in the final enumeration, I would add a conditional breakpoint inside the loop to print out some information about ks (the system name and number, for instance) and then continue execution. (In Pernosco you can do the same thing but you get all the information that would have been printed without having to actually run the program again.)

As for performance, if this code is just called once any time a fleet transits an unexplored jump point then it is probably irrelevant. Even though you make two whole copies of the list of systems (and you did just make that list significantly larger), that probably takes so little time that nobody will notice. But you might take a look to see if you have made this mistake in more important parts of the code. What is a very minor mistake here would be much more regrettable in the code that implements ship detection, for instance.

OK, I think I finally understand what you are driving at :)

I was concerned I would have the LINQ in the middle of the foreach statement, if I didn't assign it to a List() first and use that as the target for the foreach. Are you saying I could just replace the List<KnownSystem> = with  IEnumerable<KnownSystem> = , remove the ToList() and then use the IEnumerable as the target of the foreach. That would be the same in terms of readability and I assume I could check the contents of the IEnumerable instead of the List?

I basically picked up C# by writing it and figuring things out when I needed to, without any formal learning, so there will be gaps in my knowledge :)

So now you have made me curious, I started reading about it. Some people expressed a view that IEnumerable  only guarantees an enumeration and doesn't guarantee the order of execution (even if ordered beforehand). However, as I read it, its the same execution as list because the latter inherited the former. Which is correct?

And yes, I agree that in this one instance it doesn't make much difference, but it might in more substantial situations. It would depends on whether I need to do anything beyond enumerating and reading the collection.
2
C# Mechanics / Re: v2.6.0 Changes Discussion Thread
« Last post by alex_brunius on Today at 02:46:41 AM »
Population that is in excess of required manufacturing personnel numbers is generally considered to be gainfully employed, just not in trans-newtonian industries relevant to the game.

Correct, but it could still be relevant to include some smaller pressure from this factor both for gameplay reasons and for flavor/immersion reasons.

For immersion:
It's not mutually exclusive with the idea that this population is available to be more gainfully employed (earning higher salary/status) if they were moved into a prioritized trans-newtonian industry career instead where such opportunities exists on other colonies.

For gameplay:
It's handy to have colony shipping prioritize colonies with surplus workers without having to micromanage this yourself by turning stable on and off again in the larger empires having to monitor the surplus workers.
3
General Discussion / Re: What's Going On In Your Empire: C# Edition
« Last post by Kiero on Today at 02:13:26 AM »
A bizarre race has been incorporated into the empire.

Temperature range: -16.47 to 128.66

4
General Discussion / Re: Questions Not Worth Their Own Thread: C# Edition
« Last post by db48x on Today at 02:01:39 AM »
I don't want to turn this thread into a programming debate, which is one of the reasons that I rarely post code ;)

I hope that none of the other readers of this thread have been put out by our monopolization of the topic of discussion :)

Are you suggesting that instead of a new list, I use the LINQ without assigning to a new list as the target in the foreach loop?

If so, I prefer to avoid that. It's harder to read and harder to debug and those are more important to me than straight performance.

Yes, both the CurrentSystems and PossibleSystems variables would be IEnumerable<KnownSystem> instead of List<KnownSystem>. I can’t really see how the code would be more difficult to read, since everything else would be identical except that you would just not call ToList().

However, I suppose I know what you mean about debugging. You want to stop at a breakpoint and be able to view the lists in the debugger. I tend to forget that not everybody can use omniscient debugging yet (I use a debugger called Pernosco a lot, but it is for Linux only.) If I were using a regular debugger and I wanted to verify which systems had been in the final enumeration, I would add a conditional breakpoint inside the loop to print out some information about ks (the system name and number, for instance) and then continue execution. (In Pernosco you can do the same thing but you get all the information that would have been printed without having to actually run the program again.)

As for performance, if this code is just called once any time a fleet transits an unexplored jump point then it is probably irrelevant. Even though you make two whole copies of the list of systems (and you did just make that list significantly larger), that probably takes so little time that nobody will notice. But you might take a look to see if you have made this mistake in more important parts of the code. What is a very minor mistake here would be much more regrettable in the code that implements ship detection, for instance.
5
Transponders: are they always ON for civilian ships? Why would I want to keep them on, as it broadcasts their position to potential hostiles? And what would happen if I turned them off?
6
Huh. It may be that C# works differently than I expected, but the docs don’t indicate that the OrderBy method modifies the underlying list.

It's not the OrderBy, it is the Except that precedes it.

The documentation for Except doesn’t say that it modifies the list either. It is my understanding that none of the Enumerable methods modify the underlying data.

I don't want to turn this thread into a programming debate, which is one of the reasons that I rarely post code ;)

Are you suggesting that instead of a new list, I use the LINQ without assigning to a new list as the target in the foreach loop?

If so, I prefer to avoid that. It's harder to read and harder to debug and those are more important to me than straight performance.

If not, maybe DM me with an example of the code as you would write it.
7
General Discussion / Re: Questions Not Worth Their Own Thread: C# Edition
« Last post by Caesar on Yesterday at 03:59:02 PM »
Hi! It's been a while since I played, but I'm getting back into the game again. I wanted to read up on the mechanics, when I noticed the wiki doesn't work. I think I read that it may be a temporary issue but I couldn't find a good post on it. Does anyone have a clearer idea what's going on with the wiki?

Thanks in advance!
8
Spoilers / Re: Chance of recovering tech
« Last post by Droll on Yesterday at 03:31:12 PM »

What is the chance of recovering compressed fuel tech from ruins and what installation is it linked to? I'm assuming you can still do so as I haven't had this many ruins in a long time - I'm playing a ruin rich game at the moment and have recovered thousands of installations but have yet to uncover any tech from recovering them.


Welchbloke

Each installation type has a specific chance of also giving tech of an appropriate type. For example, if you recover a mine, there is a 1 in 300 chance of improving mining tech. The exception is research labs, which have a 1 in 5 chance of returning a random tech. However, this is limited to the tech level of the ruin race. So if you have manage to roll for the mining tech for example and you already have equal to or better tech than the ruin race, you won't get anything.

So in the context of the original question - Would recovering a fuel refinery have a small chance of recovering compressed fuel tech?

Fuel production tech. I don't think compressed is still in the game.

The tech and components are still in the db as ruins only techs and I remember organically getting the tech years ago. There's also some stuff still in there for the "advanced" variants of weapons.
9
General Discussion / Re: Questions Not Worth Their Own Thread: C# Edition
« Last post by db48x on Yesterday at 12:32:37 PM »
Huh. It may be that C# works differently than I expected, but the docs don’t indicate that the OrderBy method modifies the underlying list.

It's not the OrderBy, it is the Except that precedes it.

The documentation for Except doesn’t say that it modifies the list either. It is my understanding that none of the Enumerable methods modify the underlying data.
10
C# Suggestions / Re: Suggestions Thread for v2.4.0
« Last post by Steve Walmsley on Yesterday at 09:36:44 AM »
On the Movement Orders tab of the Naval Organization window, the "Delete Template" button and the "Delete" (fleet) button are right next to each other.
This positioning, despite the subsequent confirmation dialog, leads to me occasionally deleting a fleet when I intend to delete a template.

I think mistakes would be less likely if the second button were labeled "Delete Fleet."

That button is used to delete whatever you have selected - Fleet, Ship, Squadron, Naval Admin Command, Sub-fleet or Shipping Line. I probably should modify the button label though when you click on different things.
Pages: [1] 2 3 ... 10
SMF spam blocked by CleanTalk