IRC logs for #openttd on OFTC at 2023-02-21
            
00:19:22 *** Wormnest has joined #openttd
01:12:03 *** Wormnest has quit IRC (Ping timeout: 480 seconds)
01:49:44 *** Wormnest has joined #openttd
02:42:23 *** Wormnest has quit IRC (Ping timeout: 480 seconds)
03:07:05 *** tokai|noir has joined #openttd
03:07:05 *** ChanServ sets mode: +v tokai|noir
03:13:44 *** tokai has quit IRC (Ping timeout: 480 seconds)
03:20:48 *** WormnestAndroid has quit IRC (Ping timeout: 480 seconds)
03:21:12 *** Wormnest has joined #openttd
03:21:39 *** WormnestAndroid has joined #openttd
03:22:05 *** WormnestAndroid has quit IRC (Read error: Connection reset by peer)
03:22:12 *** WormnestAndroid has joined #openttd
03:22:15 *** WormnestAndroid has quit IRC (Read error: Connection reset by peer)
03:22:57 *** WormnestAndroid has joined #openttd
03:41:06 *** D-HUND has joined #openttd
03:44:34 *** debdog has quit IRC (Ping timeout: 480 seconds)
03:46:40 *** Wormnest has quit IRC (Quit: Leaving)
04:14:32 *** TROILUS has quit IRC (Read error: Connection reset by peer)
04:14:33 *** TROILUS2 has joined #openttd
04:14:34 *** TROILUS2 is now known as TROILUS
04:18:35 *** TROILUS has quit IRC ()
04:18:57 *** TROILUS has joined #openttd
05:52:12 *** Flygon has joined #openttd
07:08:27 *** keikoz has joined #openttd
07:20:29 *** nielsm has quit IRC (Ping timeout: 480 seconds)
07:43:06 *** sla_ro|master has joined #openttd
07:57:39 *** HerzogDeXtEr has joined #openttd
09:56:04 *** gelignite has joined #openttd
09:57:20 *** Samu has joined #openttd
11:47:38 *** WormnestAndroid has quit IRC (Remote host closed the connection)
11:58:07 *** WormnestAndroid has joined #openttd
12:30:23 *** WormnestAndroid has quit IRC (Read error: Connection reset by peer)
12:30:57 *** WormnestAndroid has joined #openttd
12:30:59 *** WormnestAndroid has quit IRC (Read error: Connection reset by peer)
12:31:13 *** WormnestAndroid has joined #openttd
13:15:25 *** gnu_jj_ has quit IRC ()
13:15:29 *** gnu_jj has joined #openttd
13:37:01 *** geli has joined #openttd
13:43:24 *** gelignite has quit IRC (Ping timeout: 480 seconds)
14:02:34 *** sla_ro|master has quit IRC ()
14:03:57 *** geli has quit IRC (Quit: Stay safe!)
15:01:47 *** nielsm has joined #openttd
15:40:19 *** TROILUS has quit IRC (Quit: Ping timeout (120 seconds))
15:40:27 *** TROILUS has joined #openttd
15:45:30 *** D-HUND is now known as debdog
16:11:49 *** Wormnest has joined #openttd
16:16:28 *** TROILUS3 has joined #openttd
16:18:07 *** TROILUS has quit IRC (Read error: Connection reset by peer)
16:18:07 *** TROILUS3 is now known as TROILUS
16:38:28 *** Wormnest has quit IRC (Quit: Leaving)
16:43:02 <petern> Wait, really no chat since midnight?
16:52:02 <andythenorth> I had day off
16:52:14 <andythenorth> well actually we all just talked in jgr channel
16:59:53 <LordAro> wow
17:03:23 *** Wormnest has joined #openttd
17:22:27 *** Wolf01 has joined #openttd
17:36:34 *** sla_ro|master has joined #openttd
17:45:25 *** gelignite has joined #openttd
18:00:28 <Samu> hello, i have a quest
18:01:08 <Samu> turn those excessive cpu valuating AIs into working AIs
18:02:12 <Samu> but I wanted to do it in a fast way
18:03:17 <andythenorth> we should take AIs out of the game
18:03:35 <andythenorth> they should run as lambdas, connecting like a human player does
18:03:43 <andythenorth> oh, wait, single-player mode 😛
18:03:44 <andythenorth> silly me
18:04:45 <Samu> i wanted a macro or something in squirrel equivalent that replaces Valuate into a for loop
18:05:00 <Samu> without me having to edit the entire code
18:05:21 <glx[d]> valuate is a for loop
18:05:47 <Samu> well, yes, but it's done in openttd instead
18:05:51 <glx[d]> and if you do it in squirrel it will be slower
18:05:53 <andythenorth> I thought valuate was optimised 😛
18:06:14 <andythenorth> hmm
18:06:26 <andythenorth> maybe the model is all wrong
18:06:35 <andythenorth> we gave AI full view of the map / world
18:06:40 <Samu> rather do it slower than having the ai crash
18:06:40 <andythenorth> but then it's slow
18:06:52 <andythenorth> maybe we should have agent-based
18:06:56 <andythenorth> so each vehicle gets an AI
18:07:00 <andythenorth> etc
18:07:17 <andythenorth> I used to write agent-based flash games accidentally without knowing what they were
18:07:43 <andythenorth> e.g. it was easier in Flash IDE to just write a self-contained loop on a monster sprite for a game
18:07:59 <andythenorth> handling movement, health, etc
18:08:00 *** Flygon has quit IRC (Quit: A toaster's basically a soldering iron designed to toast bread)
18:08:16 <andythenorth> compared to a single central game loop taking care of everything
18:08:34 <andythenorth> the sprite was then just placed on the main stage as an actor and would run
18:09:17 <andythenorth> hmm vehicles with self-modifying orders? o_O
18:09:48 <glx[d]> main issue I can see with changing list values in squirrel is the automatic sorting
18:10:07 <Samu> https://gist.github.com/SamuXarick/d9337407bc094417e2a5c41931df735a
18:10:19 <Samu> how do i do a replacement for Valuate?
18:10:30 <Samu> using <- assignment or something
18:11:37 <andythenorth> it's just a for loop no?
18:11:56 <andythenorth> for i in [x1, x2, x3] etc
18:12:22 <Samu> yes, but I wanted it to automagically substitute any Valuate that is found into that for loop
18:12:24 <andythenorth> use lookups to populate arrays/slots
18:12:37 <Samu> without me having to dig the entire AI
18:12:42 <andythenorth> oh don't know
18:13:03 <Samu> many different AIs crash due to evaluator
18:13:03 <andythenorth> whatever you do, I'd time it over multiple sizes of dataset
18:13:09 <andythenorth> Valuate is allegedly fast
18:15:25 <Samu> oh, it's not return what I want, it's SetValue :8
18:15:30 <Samu> ah dumb me
18:17:23 <glx[d]> if you sort by item you can easily use a for loop and SetValue()
18:17:41 <Samu> lists are already sorted
18:17:57 <glx[d]> but IT IS VITAL to sort by item and not by value if you do that
18:18:30 <Samu> really?
18:19:02 <Samu> does it matter that much?
18:19:05 <glx[d]> if you change a value while sorted by value, you reorder the list, so your iteration is broken*
18:19:43 <glx[d]> Valuate always uses by item sorting internally
18:20:16 <Samu> I don't remember having an issue doing it without sorting by item
18:20:28 <Samu> my AI would be broken
18:20:31 <glx[d]> with Valuate it's safe
18:21:23 <glx[d]> but if you do the for loop in squirrel to valuate manually it requires to be sorted by item
18:21:38 <Samu> that means my AI is broken?
18:21:48 <glx[d]> else you will change iterated values while iterating
18:21:58 <Samu> doesn't feel broken, omg, i need to test that now
18:29:28 <Samu> https://gist.github.com/SamuXarick/d9337407bc094417e2a5c41931df735a
18:29:35 <Samu> I do this in the entire code
18:29:48 <Samu> never had any apparent issue
18:30:14 <Samu> https://github.com/SamuXarick/LuDiAI-AfterFix/blob/835425c0cde2e0e4c8d458e57296d2c2a1303490/AirBuildManager.nut#L888-L891
18:30:16 <Samu> i mean this
18:34:42 <Samu> anyways, I'll do it the correct way when i get time to fix it
18:35:53 <petern> hmm, 30-odd rockets wasn't enough to kill this Icon of Sin...
18:37:41 <petern> I guess the hole it's in is bigger than the standard Icon of Sin map, so it just takes more rockets to damage it.
18:37:53 <Samu> gonna do a test myself
18:50:09 <glx[d]> Your code uses default sort (but I don't remember which one is default)
18:52:07 <glx[d]> Anyway a simple test is to print the item, you'll probably see missing or repeated items if the list is ressorted
18:52:42 <andythenorth> pacificpunch: what issue are you addressing? Crashes? Excess CPU use?
18:52:58 <glx[d]> Excess CPU I guess
18:53:13 <glx[d]> Too big list can do that
18:54:06 <andythenorth> I don't really understand the performance model
18:54:17 <andythenorth> but if the AI is doing something like walking all the tiles
18:54:23 <andythenorth> to place stations or build routes
18:54:31 <andythenorth> then that is going to be a problem
18:54:54 <glx[d]> It's not an issue if done in squirrel because it can be suspended
18:55:12 <andythenorth> oh valuate isn't?
18:55:13 <glx[d]> But Valuate is done in C++ and we can't suspend
18:55:17 <andythenorth> it's one opcode?
18:55:38 <andythenorth> yes ok I see
18:55:57 <DorpsGek> [OpenTTD/OpenTTD] 2TallTyler opened issue #10498: [Crash]: Assert in autoreplace GUI when clicking on an articulated variant vehicle being autoreplaced https://github.com/OpenTTD/OpenTTD/issues/10498
18:56:12 <andythenorth> so what is the use case for these valuators that are problematic?
18:56:23 <andythenorth> the game can do things like walk the vehicle lists trivially
18:56:29 <andythenorth> maybe we need precomputed valuations?
18:56:39 <andythenorth> or we need to limit list contents in script?
19:16:12 <andythenorth> nah precomputing valuations would probably eat RAM?
19:16:28 <andythenorth> unmanageable number of possible combinations
19:35:18 <Samu> so i guess i ended up on a neverending foor loop
19:35:26 <Samu> glx was right
19:39:34 <Samu> what if i start with value of 0
19:39:45 <Samu> let' seee
19:51:13 *** WormnestAndroid has quit IRC (Ping timeout: 480 seconds)
19:55:06 <petern> Whew, finally completed WOS.
19:57:14 *** WormnestAndroid has joined #openttd
20:10:45 <glx[d]> andythenorth: oh and @ fail 😉
20:10:55 <andythenorth> lol sorry 🙂
20:10:55 <andythenorth> ha
20:11:10 <Samu> when the value is 0
20:11:25 <Samu> hmm wait i'll show u the program
20:11:27 <andythenorth> petern: goes Doom faster on M2? https://www.amazon.co.uk/2022-Apple-MacBook-laptop-chip/dp/B0B3B2QRWQ/
20:11:38 <petern> Probably 🙂
20:11:45 <glx[d]> default sorter is by descending values
20:12:34 <Samu> https://gist.github.com/SamuXarick/d9337407bc094417e2a5c41931df735a
20:12:42 <Samu> when the values are 0
20:12:46 <Samu> there was no issue
20:12:49 <Samu> i got no assert
20:12:57 <andythenorth> FML I have one of these in a cupboard with slightly less RAM https://www.apple.com/uk/shop/product/G0ZN2B/A/refurbished-16-inch-macbook-pro-24ghz-8-core-intel-core-i9-with-retina-display-space-grey?fnode=6bb594b5e1f284f171209d06f4545c2263f87d4860e3be59c3d45821eac3eac1e332065d85c9ca6a587660bfcdbf32681f88823f98f5890feb147724eb2da79d87ba0d973e8efaed2f80cd9a993935d7
20:12:59 <andythenorth> I should sell it
20:13:16 <andythenorth> based on what Apple are asking refurb
20:13:41 <Xarick> https://cdn.discordapp.com/attachments/1008473233844097104/1077684557572214814/Unnamed_1935-03-24.png
20:13:54 <Samu> reached the end with no assert
20:14:53 *** TROILUS9 has joined #openttd
20:14:56 *** TROILUS has quit IRC (Remote host closed the connection)
20:14:57 *** TROILUS9 is now known as TROILUS
20:15:59 <Samu> oh wait, i found a bug
20:16:10 <Samu> i am using main_list for list2
20:16:14 <Samu> :(
20:16:36 <Samu> should be copy_list
20:17:44 <Samu> well, still no assert
20:17:56 <Xarick> https://cdn.discordapp.com/attachments/1008473233844097104/1077685628088627290/Unnamed_1935-01-111.png
20:20:37 <Samu> why didn't it assert?
20:20:54 <Samu> values started as 0
20:29:13 <Samu> just tried random values
20:29:29 <Samu> no assert, it finished
20:30:01 <Samu> is my test methodology flawed or is there an explanation?
20:31:17 <glx[d]> https://cdn.discordapp.com/attachments/1008473233844097104/1077688987868737656/image.png
20:31:17 <glx[d]> tried with <https://gist.github.com/glx22/70c32706efcc78843b8b4af3514d2fc7> result is
20:31:28 <glx[d]> you can see the issue
20:35:10 <glx[d]> https://cdn.discordapp.com/attachments/1008473233844097104/1077689964776657007/image.png
20:35:10 <glx[d]> same loop with the list sorted by item
20:37:36 <Samu> it reached 0 and started iterating again, that's weird
20:37:41 <Samu> i see
20:39:41 <glx[d]> it's not weird, it's the result or sorting by descending values, and changing values during iteration
20:39:46 <glx[d]> *of
20:40:53 <glx[d]> sorting by item is not affected by this
20:41:45 <glx[d]> and if I display the list content again it will still use the same order but show 0, -1, -2, -3, ...
20:44:26 <glx[d]> btw your test is flawed, you do the exact same thing in both lists 🙂
20:49:36 <glx[d]> though theorically copy_list content should probably differ as new values are lower than 0
20:51:25 <glx[d]> ah no can't happen, you just end up setting the value multiple time for some items
20:53:03 <Samu> ah, now that makes sense
20:53:05 <glx[d]> copy_list loop iterates 2000 items I think
20:53:24 <Samu> gonna add a counter
20:53:31 <glx[d]> 1000 with initial 0, then the same with the new values
20:53:51 <Samu> oh, i can't add a counter in the valuate
20:53:56 <Samu> nvm
20:54:26 <Samu> oh it's not in the valuate that i add the counter, it's on the for loop
20:54:33 <Samu> ok let's add counter
20:55:19 <glx[d]> I won't try, but with SetValue(item, GetValue(item) - 1) it's probably an infinite loop
21:00:10 <Xarick> https://cdn.discordapp.com/attachments/1008473233844097104/1077696257054748682/Unnamed_1935-01-019.png
21:00:22 <Samu> everything makes sense now
21:00:34 <Samu> thanks for the time explaining me
21:00:38 <Samu> what really happens
21:02:28 <Samu> my AI might be doing that multiple loop thing
21:02:53 <Samu> setting the value multiple times
21:03:51 <Samu> back to the main topic then
21:04:09 <Samu> i need to copy the list
21:04:19 <Samu> add the items from the main list
21:04:35 <Samu> set sorting by item, ascending or descending?
21:05:00 <Samu> then set value, and then swaplist? will swap list also swap the sorting type?
21:05:06 <Samu> i hope not
21:15:29 <glx[d]> order doesn't matter as long as it's sorted by item
21:18:24 <Samu> at the end it must be ordered by the way it used to be
21:18:49 <Samu> im testing
21:18:55 <glx[d]> <https://github.com/OpenTTD/OpenTTD/blob/master/src/script/api/script_list.cpp#L580-L584> everything is swaped
21:20:15 <Samu> crap, exactly what I don't want :(
21:20:47 <glx[d]> Sort() doesn't actually sort
21:21:01 <Samu> gonna try Clear then AddList
21:21:53 <glx[d]> list content is always sorted internally by item and by value, Sort() just sets how the content is iterated
21:22:54 <glx[d]> so calling Sort() is not that expensive
21:26:00 <Samu> Clear+AddList works! nice nice!
21:26:10 <Samu> it keeps the original sorting type
21:38:23 <Samu> https://gist.github.com/SamuXarick/d9337407bc094417e2a5c41931df735a this won't compile
21:38:29 <Samu> squirrel is different
21:38:42 <Samu> how do i template or whatever it's called in squirrel
21:42:37 <glx[d]> I don't think squirrel supports varargs
21:43:45 <glx[d]> ah it does ```
21:43:45 <glx[d]> function test(a,b,...)
21:43:45 <glx[d]> {
21:43:45 <glx[d]> for(local i = 0; i< vargc; i++)
21:43:45 <glx[d]> {
21:43:47 <glx[d]> ::print("varparam "+i+" = "+vargv[i]+"\n");
21:43:47 <glx[d]> }
21:43:49 <glx[d]> }
21:43:49 <glx[d]> test("goes in a","goes in b",0,1,2,3,4,5,6,7,8);
21:47:15 <glx[d]> but I think you need to switch on vargc and write the call with fixed parameters
21:57:52 *** gnu_jj has quit IRC (Read error: Connection reset by peer)
21:58:49 *** gnu_jj has joined #openttd
22:05:04 <Samu> looks like i did it
22:05:14 <Samu> it's not quite as I expected
22:07:01 <Samu> got this https://gist.github.com/SamuXarick/d9337407bc094417e2a5c41931df735a
22:07:09 <Samu> it compiled
22:08:02 <Samu> there's no prettier way to do it?
22:09:07 *** HerzogDeXtEr has quit IRC (Read error: Connection reset by peer)
22:12:40 <Samu> how many arguments can a function have?
22:18:14 *** sla_ro|master has quit IRC ()
22:23:48 <glx[d]> with 10 you're probably fine
22:24:59 <glx[d]> you can skip the copy and use Sort() before and after valuation
22:26:29 <glx[d]> ah no, there's no way to know the current sorter
22:27:51 <Samu> i need .tointeger()
22:27:59 <Samu> because of bools, it's gonna become very horizontal
22:28:17 *** nielsm has quit IRC (Ping timeout: 480 seconds)
22:29:46 <Samu> nop, still failed
22:29:50 <Samu> then i don't know
22:31:37 <Samu> first victim: FastPTPAI
22:31:50 <Samu> replacing valuators is still a daunting task
22:32:17 <Samu> isn't there a better way to do it?
22:32:32 *** keikoz has quit IRC (Ping timeout: 480 seconds)
22:37:00 <Samu> like a replacement function which is done in the compat files?
22:39:35 <Samu> or with a regex
22:53:32 <glx[d]> you can redefine Valuate
22:53:46 *** Wolf01 has quit IRC (Quit: Once again the world is quick to bury me.)
22:54:00 <glx[d]> like it's done in compat files for some functions
22:54:36 <Samu> how?
22:55:58 <glx[d]> AIList.Valuate <- function(...
22:56:03 <glx[d]> I think
22:57:15 <Samu> hmm
22:57:54 <Samu> listname.Valuate(xyz) <- function(listname, xyz, ...) ?
23:00:37 <Samu> FastPTPAI is now a happy non crashing ai
23:01:11 <Samu> it's probably slow now heheh
23:04:03 <Samu> https://gist.github.com/SamuXarick/d9337407bc094417e2a5c41931df735a#file-gistfile1-nut-L7-L33
23:04:11 <Samu> null becomes 0?
23:04:23 <Samu> with the .tointeger() conversion?
23:05:40 <glx[d]> null doesn't have .tointeger()
23:07:09 <glx[d]> ```GSIndustryList.Valuate <- function(func, ...) {
23:07:09 <glx[d]> GSLog.Info("nothing done");
23:07:09 <glx[d]> }``` I tried the same with GSList but subclasses are not affected
23:07:46 <glx[d]> https://cdn.discordapp.com/attachments/1008473233844097104/1077728366758731836/image.png
23:08:58 <glx[d]> output for with the remapped Valuate```
23:08:58 <glx[d]> local inds = GSIndustryList();
23:08:58 <glx[d]> inds.Valuate(GSIndustry.GetIndustryType);
23:08:58 <glx[d]> inds.Sort(GSList.SORT_BY_ITEM, true);
23:08:58 <glx[d]> for (local i = inds.Begin(); !inds.IsEnd(); i = inds.Next()) {
23:08:59 <glx[d]> GSLog.Info("industry " + i + " = " + inds.GetValue(i));
23:08:59 <glx[d]> inds.SetValue(i, -inds.GetValue(i));
23:09:01 <glx[d]> }
23:10:11 <Samu> i can't use GSIndustryList
23:10:29 <Samu> or can i?
23:10:31 <Samu> i mean
23:10:53 <Xarick> ah I see here
23:13:48 <Xarick> no, i need to pass the list as parameter somehow
23:13:53 *** gnu_jj has quit IRC (Remote host closed the connection)
23:14:57 *** gnu_jj has joined #openttd
23:16:18 <glx[d]> ```GSIndustryList.Valuate <- function(func, ...) {
23:16:18 <glx[d]> GSLog.Info("nothing done");
23:16:18 <glx[d]> for (local i = this.Begin(); !this.IsEnd(); i = this.Next()) {
23:16:18 <glx[d]> GSLog.Info("industry " + i + " = " + this.GetValue(i));
23:16:18 <glx[d]> this.SetValue(i, -this.GetValue(i));
23:16:19 <glx[d]> }
23:16:19 <glx[d]> }
23:16:52 <Xarick> what if the list has another name?
23:17:05 <glx[d]> https://cdn.discordapp.com/attachments/1008473233844097104/1077730713329221712/image.png
23:17:05 <glx[d]> followed by the output after valuate call
23:17:36 <glx[d]> Valuate applies to the list itself so this represent the list
23:18:43 <Xarick> i'll check this tomorrow, i'm out of time now 😦
23:19:26 <Xarick> https://cdn.discordapp.com/attachments/1008473233844097104/1077731302775726110/Unnamed_1960-04-20.png
23:19:26 <Xarick> FastPTPAI is happy!
23:19:30 <Xarick> cyas goodnight
23:28:02 *** Samu has quit IRC (Ping timeout: 480 seconds)
23:54:17 <DorpsGek> [OpenTTD/OpenTTD] nikolas opened pull request #10499: Fix #10222 without regression error https://github.com/OpenTTD/OpenTTD/pull/10499
23:57:07 <DorpsGek> [OpenTTD/OpenTTD] nikolas updated pull request #10499: Fix #10222 without regression error https://github.com/OpenTTD/OpenTTD/pull/10499