IRC logs for #openttd on OFTC at 2024-11-14
β΄ go to previous day
02:31:45 *** tokai|noir has joined #openttd
02:31:45 *** ChanServ sets mode: +v tokai|noir
02:38:28 *** tokai has quit IRC (Ping timeout: 480 seconds)
03:23:05 *** debdog has quit IRC (Ping timeout: 480 seconds)
04:00:44 *** D-HUND is now known as debdog
06:19:44 *** keikoz has quit IRC (Ping timeout: 480 seconds)
06:49:07 <truebrain> Pfff, no new translations is another failed nightly π
08:36:53 *** HerzogDeXtEr has joined #openttd
09:35:43 *** mindlesstux has joined #openttd
09:47:12 <peter1138> reldred: we're both not very good at keeping misskey up to date, eh?
09:52:52 <reldred> peter1138: God no. I update it when someone yells at me loudly enough.
09:53:53 <peter1138> I'm not yelling this time, I just noticed mine...
10:58:18 <peter1138> Ok, seems moving chunks of data once a month is cheaper than maintaining a position. (ringbuffer style)
11:49:32 <LordAro> it's the one right at the top, as usual
11:51:13 <xarick> oh, i found where the problem was
11:51:26 <xarick> `std::erase(counts[type], pair_it);`
11:53:01 <xarick> how can this generate a 6000 lines error message is beyond me
11:53:15 <LordAro> templates are real fancy
11:54:44 <andythenorth> generated code is the best code
11:56:20 <peter1138> It's not quite that many lines, it's multiple errors as it's compiling multiple files.
12:00:24 <peter1138> Okay, that's quite special AI work there.
12:04:21 <xarick> wow, that on towns is interesting
12:05:02 <xarick> gives us a quick glance if it's growing
12:06:47 <xarick> ``` assert(std::ranges::all_of(pair_it->second, [&](auto &iid) {
12:06:47 <xarick> return Industry::Get(iid)->town == town;
12:06:47 <xarick> }));``` This is some kind of assert
12:09:39 <peter1138> Well, it's ... data. It's not all that interesting though.
12:13:43 <xarick> `counts[type].emplace_back(ind->town->index, ind->index);` this is not inserting the way I want
12:14:19 <peter1138> That looks like a very strange data structure.
12:14:52 <xarick> i wand to insert a vector containing ind->index on the primary vector
12:15:30 <xarick> std::pair<TownID, std::vector<IndustryID>>
12:16:20 <xarick> `static std::array<std::vector<std::pair<TownID, std::vector<IndustryID>>>, NUM_INDUSTRYTYPES> counts; ///< Number of industries per type ingame in each town`
12:17:32 <xarick> i need to create a temp vector with the IndustryID?
12:18:02 <xarick> std::make_vector exists?
12:19:28 <peter1138> Yeah, arrays of vectors of pairs with vectors definitely indicates you are going about this the wrong way.
12:23:46 <xarick> crap, it created a vector of size 0, because the ind->index is 0, that's not what I want
12:24:33 <xarick> I want it to create a vector, then insert the ind->index into it, then emplace_back on the primary vector
12:25:13 <xarick> `counts[type].emplace_back(ind->town->index, std::vector<IndustryID>{ ind->index });` maybe?
12:28:29 <xarick> if only I could give names to these members
12:28:44 <xarick> first is TownID, second is vector of IndustryIDs
12:32:32 <xarick> oh got a crash instead, π
12:34:48 <xarick> creating an industry but still didn't assign the town to it
13:29:21 <peter1138> Hmm, what makes the town algorithms start off with a bump in supply?
13:33:05 <peter1138> (Probably because it's a tiny place with barely any production)
13:57:55 <xarick> > /* Count only those who match the same industry type and layout filter
13:57:55 <xarick> > * Unfortunately, we have to do it manually */
13:57:55 <xarick> If this was a function, what would be the name?
13:58:48 <andythenorth> CountIndustryMatchingTypeAndLayout
13:59:03 <andythenorth> or do what I do, call it CountIndustryCABBAGE
13:59:08 <andythenorth> then see if it's useful
13:59:13 <andythenorth> then find-replace later
14:00:41 <peter1138> What's the point, eh?
14:02:20 <andythenorth> VisualisationScript?
14:02:30 <andythenorth> NodeJS running in OpenTTD?
14:02:43 <andythenorth> lambdas for charts?
14:02:54 <xarick> okay so now I just don't want the number, I want a list of them
14:03:02 <xarick> let's see if I can do this
14:09:28 <xarick> `static inline std::tuple<uint16_t, std::vector<IndustryID>> &GetIndustryTypeCount(IndustryType type, Town *town = nullptr)`
14:09:45 <xarick> returns the count and a vector with them
14:10:03 <xarick> or maybe just return the vector then count it
14:42:42 <peter1138> Okay, with this town history data less memory is used, though performance is probably affected because there's necessarily more work to do.
14:44:10 <xarick> * Array containing vectors of industry types.
14:44:10 <xarick> * Each vector corresponds to a specific industry type and
14:44:10 <xarick> * contains pairs of TownIDs and their associated lists of IndustryIDs.
14:44:10 <xarick> static std::array<std::vector<std::pair<TownID, std::vector<IndustryID>>>, NUM_INDUSTRYTYPES> counts;```
14:44:28 <xarick> good english thx to Copilot
14:46:49 <xarick> how do I explain the rules I went for with the vectors?
14:49:28 <xarick> if a town has no industry of certain type, delete the pair
14:52:49 <xarick> the vectors corresponding to a specific industry type are at a minimum empty, not deleted
14:53:44 <mnhebi> If Xarick keeps going like this we'll be able to run our OpenTTDs on old Amigas at this rate.
15:05:21 <peter1138> Oh, that is beautiful. The Onion... bought Info Wars.
15:05:27 *** Flygon has quit IRC (Read error: Connection reset by peer)
15:06:17 *** belajalilija has joined #openttd
15:06:17 <belajalilija> i thought that was satire
15:06:28 <belajalilija> that really is beautiful
15:18:51 <peter1138> The right wing are crying a bit...
15:19:09 <peter1138> Well, the part who paid attention to that lot.
15:24:45 <belajalilija> going backrupt to be owned by the libs :kek:
15:26:17 <xarick> I'm too noob for templates
15:33:57 <xarick> ``` template <typename Func = decltype([]{})>
15:33:57 <xarick> static inline uint16_t GetIndustryTypeCount(IndustryType type, const Town *town = nullptr, Func func = []{})```
15:34:27 <peter1138> Just spamming keypresses at this point.
15:34:29 <xarick> how do i make a default parameter of function
15:35:37 <xarick> wanna make a function that does nothing
15:35:56 <xarick> or a function that does things if I prove one
15:37:07 <peter1138> Hmm, tracking an average without keep all the past values?
15:41:31 <LordAro> peter1138: much chortling
15:48:33 <peter1138> Weird random 3rd party site to link to. But whatever.
15:49:30 <mnhebi> a function that does nothing is not a function.
15:49:34 <mnhebi> Its in the name, function
15:52:46 <xarick> missing default argument for parameter 3
15:53:39 <peter1138> If your Func has to be present, don't put it after the optional parameter.
15:54:13 <peter1138> (If Func doesn't need to be present then you have other issues...)
15:56:24 <xarick> it doesn't need to be present, I wanna make it optional
15:56:39 <xarick> but i need a default argument π¦
15:57:00 <_jgr_> peter1138: I tend to go for exponentially weighted moving averages for this sort of thing. You only need one value of state.
16:01:11 <johnfranklin> How to read x in xarick? Egzarik? Zarik? Tzarik? Harik?
16:40:52 <_glx_> xarick: that kind of construct is definitely a big no
16:54:45 <_glx_> the first step is too clearly define the objective, storing a bunch of stuff is usually not the solution
16:59:18 <xarick> I want to create a `CountIndustryMatchingTypeAndLayout` in the newgrf_industries.cpp file
17:22:00 <peter1138> Hmm, wonder what this slow memory release in LZMA is...
17:22:06 <peter1138> Am I backdoored? π
18:11:05 <xarick> ``` template<typename Func = std::function<void(Industry *)>>
18:11:05 <xarick> static inline uint16_t GetIndustryTypeCount(IndustryType type, const Town *town = nullptr, Func func = [&](Industry *) { })``` this works
18:12:35 <xarick> not even Copilot could give a straight answer, I had to figure out myself
18:14:46 <LordAro> pretty sure the `&` should be unnecessary
18:16:18 *** brickblock19280 has joined #openttd
18:16:18 <brickblock19280> What is the reason for using cargo IDs for overriding other cargos instead of labels like with road and railtypes?
18:18:09 <peter1138> The NewGRF spec for cargoes predates anything to do with labels.
18:19:01 <peter1138> It also means that the 12 default cargo slots can be overridden easily.
18:20:18 <peter1138> Like, cargos have a label property, but it came way later which is why it's property 0x17, not 0x08 like rail/road types.
18:25:20 <brickblock19280> I guess the override would be a reason not to change it
18:26:11 <andythenorth> it's also kind of fine as is
18:26:46 <andythenorth> I think most of the issues might now be fixed
18:37:50 <peter1138> Not being able to get rid of the default rail/road types is a bit awkward.
18:38:44 <peter1138> Cargo types support GRM to allow cooperation, but that is fiddly.
18:39:22 <brickblock19280> andythenorth: It would be nice to be able to load multiple smaller industry sets together without coordination like ecs
18:40:59 <peter1138> Another issue with the dynamic approach that rail/road types take is the NewGRF has no indication that there are not enough slots remaining.
18:41:51 <xarick> you were right peter1138 LordAro, thx
18:41:53 <brickblock19280> Having a variable for that would be cool but probably really hard to implement
18:42:21 <xarick> testing for asserts now
18:44:25 <peter1138> Well, the game knows how many labels are going to be loaded.
18:44:54 <brickblock19280> Not if I make it conditional on the var
18:47:11 <peter1138> Solution: Infinite cargo types.
18:47:39 <peter1138> Of course, industries and industrytiles have another system that also has limits...
18:47:57 *** audigex has joined #openttd
18:47:57 <audigex> peter1138: AI generated cargo types, unique to each map seed
18:48:39 <peter1138> It would be relatively... possible... to make cargo slots per-GRF, and then combine them dynamically so that the actual ID used doesn't matter.
18:49:22 <peter1138> But there's need to be a new way to disable existing cargo types. And maybe you want some of them but not all. But different climates have different defaults.
18:49:40 <peter1138> And maybe it's a cargo type that looks like a default cargo type, but is actually one that was set up by a different cargo set.
18:51:09 <peter1138> Urgh, stop complaining about extension methods :/
18:51:18 <peter1138> (He can't mock them)
19:32:16 <andythenorth> I want to base another PR on it, and I'm already stacking branches locally due to unmerged PRs π
19:33:11 <LordAro> not while #12979 is open
19:35:46 <andythenorth> the bits don't care
19:39:42 <LordAro> i was under the impression they did
19:40:06 <andythenorth> strictly 12979 is needed
19:40:15 <andythenorth> for debug, script, and default vehicles
19:40:53 <peter1138> Undrafted at least.
19:41:04 <peter1138> It's now "is this the agreed way?"
19:41:24 <xarick> var67 and var68 in english plz
19:42:04 <andythenorth> industry var 0x67?
19:42:53 <andythenorth> peter1138: well you me and Pikka agree π
19:42:59 <andythenorth> and I tried dissenting
19:43:36 <andythenorth> I think 12979 is pretty convincing
19:47:30 <xarick> ah... now I see why u Clamp the counting
19:48:15 <xarick> it can't return big enough values
19:48:16 <peter1138> It's "emulate reading from memory wtihout reading from memory"
19:48:50 <peter1138> The spec says "this value is a byte/word" so we have to clamp it to match.
19:48:57 <peter1138> 256x256 is the one-true-mapsize.
19:49:13 <peter1138> Hmm, does reserving vectors on load make sense...
19:50:02 <xarick> I was seeing rrccdddd all over this place and wondering
19:50:06 <peter1138> 1) less reallocations but 2) probably going to reallocate on first tick as something is soon as something is added
19:50:51 <xarick> int64_t support for NewGRFs is in the plans?
19:59:15 <xarick> the rreserved are actually in use and can't be used?
20:01:01 <LordAro> peter1138: perhaps obvious question - do they still need to be pointers?
20:01:23 <peter1138> Reserved means "don't read those bits, they might be used later"
20:01:43 <_glx_> automatic title based on branch name π
20:02:06 <peter1138> LordAro: They point into the PersistentStorage pool, so ... no but yes.
20:03:40 <peter1138> The ID type is uint32_t, so using index instead of pointers would not particularly save anything.
20:04:16 <LordAro> wasn't immediately clear who the owner was
20:04:17 <peter1138> Pools are a bit annoying in some ways.
20:05:13 <peter1138> It's still a "list" in English π
20:06:09 <peter1138> If we'd started using std::unique_ptr a lot earlier some of the pool stuff could've been avoided.
20:07:11 <peter1138> This was turned into a pool because the original implementation had only 16 slots of storage and was directly built in to industries.
20:07:30 <peter1138> 64 bytes per industry/town wasn't so bad.
20:07:51 <peter1138> But 256 slots is 1KiB and that's... getting a lot for something that isn't often even used.
20:08:29 <peter1138> But converting from pool to non-pool again is probably more hassle than it's worth.
20:11:42 <xarick> * @brief doxxygen has this? never seen used in openttd
20:29:56 <andythenorth> compiled docs should never be in a repo?
20:30:12 <peter1138> They can be in A repo.
20:30:22 <peter1138> But maybe not the source repo.
20:30:54 <andythenorth> mostly these can't be in the wiki, due to styles
20:31:00 <andythenorth> and also edit wars that will bore me
20:31:11 <andythenorth> but if I get dead....grf.farm will go away
20:32:34 *** Wormnest has joined #openttd
20:53:51 <xarick> `return Industry::Get(iid)->town == Town::Get(pair_it->first) == town;` smart coding?
20:56:53 <xarick> I have 3 towns, and they all must be the same
21:00:00 <xarick> thx Copilot for coding comments for my functions
21:00:19 <xarick> this looks professional!
21:00:29 *** Wormnest has quit IRC (Ping timeout: 480 seconds)
21:01:20 <xarick> what's the difference between private: and protected:
21:07:55 <xarick> is var67 and var68 good to put in a commit message?
21:08:42 <xarick> oh really? for me that's the advanced part
21:22:28 <andythenorth> bed is indicated?
21:23:03 <andythenorth> I am bored of writing dist scripts triggered by build scripts for docs about cargo classes π
21:23:16 <andythenorth> my work looks like a modern javascript project
21:23:22 <andythenorth> 3 files of content, and 200 build scripts
21:25:48 <xarick> check whether there was any performance gains
21:27:37 <xarick> it's running kinda slow in relwithdebinfo
21:34:12 *** HerzogDeXtEr has quit IRC (Read error: Connection reset by peer)
21:37:16 *** Wormnest has joined #openttd
21:37:29 *** nielsm has quit IRC (Ping timeout: 480 seconds)
21:41:33 <xarick> the size of openttd.exe decreased by quite a chunk with your commit
21:48:31 <peter1138> I mean... that is nothing :p
21:52:22 <andythenorth> more Fox tommorrow
22:18:32 <peter1138> Uh oh. The Mastodon users are crying that loads of people are switching from Twitter to Bluesky and how it's all Mastodon's fault or something.
22:21:59 *** keikoz has quit IRC (Ping timeout: 480 seconds)
22:42:29 <xarick> Improved Town Industries is really really slow... 15 minutes
22:43:13 <xarick> it's a release build on both
22:43:26 <peter1138> Have you tried using normal map settings?
22:53:27 <talltyler> ITI is slow because industries have strict placement rules, so it needs to try each industry more times before it finds a suitable spot for each
22:54:49 <xarick> indeed, it's what I'm trying to boost
22:56:59 *** Wormnest has quit IRC (Ping timeout: 480 seconds)
22:57:38 <peter1138> 1024x1024 with High is 1280 industries.
22:59:45 <xarick> mixing kdtree + industry counts with towns results in 10x faster gen
23:00:06 <xarick> or is it "takes 1/10 of the time"...
23:00:55 <peter1138> Took me 3 minutes to make it a bit quicker.
23:01:33 <xarick> dont forget to disable multiple industries per town
23:02:39 <peter1138> (Left started about 10-15 seconds before Right, but that's inconsequential)
23:02:58 <peter1138> Multiple industries is enabled, yes.
23:03:38 <xarick> so you're also doing a PR
23:04:24 <peter1138> No, I just wanted to try something simple that you seemed to be making overly complicated.
23:04:58 <talltyler> peter1138: Shouldnβt it be the other way? One industry per town has to check for duplicates, multiple industries does whatever it wants π
23:05:18 <talltyler> (As I understand it, thatβs what Xarick is working on)
23:05:20 <peter1138> Left is still going, 7800.
23:05:33 <peter1138> Right is 45 days into the game.
23:06:10 <xarick> I overcomplicated it π
23:06:29 <peter1138> Hmm, although it said it was generating 20,000+, there's only 12,654.
23:06:51 <peter1138> I guess that's some of them giving up?
23:08:11 <peter1138> Hmm, I can also get rid of IndustryTypeCounts.
23:08:21 <talltyler> Secondary industries only spawn in cities, so you might have hit a hard limit there π
23:08:48 <talltyler> So yes, giving up, but trying harder might not produce any results
23:08:53 <xarick> it generated 7777 for me
23:09:06 <peter1138> Depends on your settings, yes.
23:09:25 <peter1138> I've got 12661 now, some must have spawned since π
23:09:37 <peter1138> Left is at 10,000, still going.
23:10:11 <xarick> let me pass u my settings
23:10:50 <peter1138> Ah, I can tweak FindTownForIndustry as well
23:12:00 <peter1138> Yeah, this is the test that isn't being used right now.
23:13:41 <xarick> I tweaked `FindTownForIndustry`, `CheckIfFarEnoughFromConflictingIndustry`, `GetClosestIndustry` and the `else` part of `GetCountAndDistanceOfClosestInstance`
23:13:53 <peter1138> I think it's fair to say this is an improvement, even if it's not perfect.
23:14:40 <peter1138> CheckIfFarEnoughFromConflictingIndustry is difficult to improve as there are only up to 3 industry types to exclude.
23:15:51 <peter1138> It also scans the map, instead of the pool.
23:17:24 <peter1138> I think that scan might be a bit flawed, it will check each tile of each industry.
23:18:10 <peter1138> kdtree would be ideal if you could filter the tree.
23:18:25 <peter1138> I don't know if that's a modification that can be made.
23:19:16 <peter1138> Still nearly 6000 attemps to go.
23:19:28 <peter1138> Right is in September already.
23:26:34 *** Wormnest has joined #openttd
23:32:40 *** Wolf01 has quit IRC (Quit: Once again the world is quick to bury me.)
23:37:44 <peter1138> Hmm, 12,810 it ended up with
23:37:55 <peter1138> But that's basically 30 minutes to generate in master.
23:38:18 <peter1138> And... 2-3 minutes with my change.
23:44:02 <peter1138> 24 * 240, perhaps a bit excessive.
23:46:13 <peter1138> About 5 seconds faster on a 1024x1024/high map.
23:48:04 <talltyler> peter1138: I donβt think ITI uses this anymore, if I recall correctly I switched to just the callback
23:50:32 <peter1138> 2048x2048 is where it starts to get slow (in master)
23:54:10 <peter1138> For a full map generation, master: 2m 24s, my .. patch: 38s
23:54:18 <peter1138> So not instant, but... an improvement.
23:55:56 <peter1138> No MKV love here π
23:58:06 <peter1138> I broke the first rule of performance tweaks: steal whatever JGRPP changed first.
continue to next day β΅