IRC logs for #openttd on OFTC at 2018-08-18
            
00:10:08 <Samu> ah i see what happened
00:10:26 <Samu> an airplane crashed and it was the only airplane servicing the two airports
00:10:36 <Samu> the event handler didn't pick it up on time
00:11:07 <Samu> the 2 airports are thus left behind, empty
00:11:07 *** Gustavo6056 has joined #openttd
00:11:47 <Samu> what can I do in this situation? The code handles aircraft replacement, but requires the crashed aircraft to still exist
00:15:23 *** The_Saladman has joined #openttd
00:18:31 *** Gustavo6046 has quit IRC
00:18:43 *** Stimrol has quit IRC
00:20:34 *** Stimrol has joined #openttd
00:30:54 *** Progman has quit IRC
00:45:45 *** Gustavo6056 has quit IRC
00:47:42 *** Gustavo6046 has joined #openttd
00:52:22 *** Gustavo6046 has quit IRC
00:52:35 *** Gustavo6046 has joined #openttd
00:53:09 *** Gustavo6046 has quit IRC
00:53:22 *** Gustavo6046 has joined #openttd
01:03:24 *** Wacko1976 has quit IRC
01:13:04 *** Wormnest has quit IRC
01:18:02 *** Wolf01 has quit IRC
01:22:45 *** frosch123 has quit IRC
01:28:35 *** KouDy has joined #openttd
01:47:39 *** acklen has quit IRC
02:01:19 *** Supercheese has quit IRC
02:45:30 *** KouDy has quit IRC
02:50:50 *** KouDy has joined #openttd
02:57:00 *** keoz has quit IRC
02:59:42 *** HerzogDeXtEr has quit IRC
03:02:51 *** snail_UES_ has joined #openttd
03:04:20 *** Thedarkb-T60 has quit IRC
03:19:35 *** Flygon has joined #openttd
03:50:50 *** Samu has quit IRC
04:00:00 *** KouDy has quit IRC
04:07:23 *** Flygon has quit IRC
04:48:00 *** Mazur has quit IRC
04:57:50 *** Mazur has joined #openttd
05:02:40 *** glx has quit IRC
05:08:47 *** rocky113844 has joined #openttd
05:12:15 *** haudrauf has quit IRC
05:13:31 *** haudrauf has joined #openttd
05:28:31 *** KouDy has joined #openttd
05:32:12 *** KouDy has quit IRC
05:42:29 *** KouDy has joined #openttd
06:48:04 *** HeyCitizen_ has joined #openttd
06:53:28 *** HeyCitizen has quit IRC
06:54:57 *** Gustavo6056 has joined #openttd
06:59:56 *** Gustavo6046 has quit IRC
07:09:43 *** cHawk has quit IRC
07:10:46 *** The_Saladman has quit IRC
07:36:59 *** HeyCitizen has joined #openttd
07:38:50 *** HeyCitiz- has joined #openttd
07:39:04 *** snail_UES_ has quit IRC
07:43:18 *** HeyCitizen_ has quit IRC
07:45:03 *** HeyCitizen has quit IRC
08:18:36 *** Gja has joined #openttd
08:23:45 *** Gja has quit IRC
08:37:26 *** tokai has quit IRC
08:38:02 *** tokai has joined #openttd
08:38:02 *** ChanServ sets mode: +v tokai
08:50:46 *** Compu has joined #openttd
08:55:50 *** andythenorth has joined #openttd
09:01:11 *** cHawk has joined #openttd
09:03:53 <andythenorth> o/
09:21:03 *** sla_ro|master has joined #openttd
09:41:19 *** HerzogDeXtEr has joined #openttd
10:27:35 *** mocniak has quit IRC
10:34:15 *** sla_ro|master has quit IRC
10:39:53 *** keoz has joined #openttd
10:53:35 *** Stimrol has quit IRC
10:58:10 *** Wacko1976 has joined #openttd
11:00:33 *** Stimrol has joined #openttd
11:04:11 *** Thedarkb-T60 has joined #openttd
11:09:00 *** haudrauf has quit IRC
11:13:16 *** haudrauf has joined #openttd
11:14:24 *** Progman has joined #openttd
11:28:34 *** Wolf01 has joined #openttd
11:28:49 <Wolf01> o/
11:33:30 *** Maraxus has joined #openttd
11:42:07 *** synchris has joined #openttd
11:49:46 *** sla_ro|master has joined #openttd
11:51:12 *** frosch123 has joined #openttd
13:01:25 *** agentw4b__ has joined #openttd
13:02:00 *** Samu_ has joined #openttd
13:02:13 <Samu_> hi
13:03:39 <Samu_> I found a bug in WrightAI
13:03:55 <Samu_> any chances it will be fixed?
13:04:43 <LordAro> probably not
13:04:54 <Samu_> the bug is at line 263 main.nut
13:05:07 <Samu_> this.SellAirports(i);
13:05:17 <Samu_> that i is expected to be a vehicleID
13:05:27 <Samu_> but it's providing a stationID instead
13:06:33 <Samu_> that will make wrightai unable to remove the airport, or even remove the wrong airport
13:10:47 <Samu_> there is no vehicles at all at that point
13:10:58 <Samu_> so, i'm not really sure how to handle this bug
13:11:23 <Samu_> he found a station with no vehicles, and the only way to remove the airports is by providing a vehicleID
13:17:29 <Samu_> this.route_1.GetValue(i)
13:17:49 <Samu_> this brings up the tileindex of the airport
13:18:12 <Samu_> i is the vehicle ID
13:18:26 <Samu_> what if I don't have the vehicleID
13:18:39 <Samu_> how do I retrieve the tileindex from this.route_1?
13:19:36 <Samu_> this.route_1.HasValue
13:19:40 <Samu_> does that exist?
13:20:56 <Samu_> GetItemGivenValue?
13:22:57 <Samu_> RemoveValue (int64 value)
13:23:35 <Samu_> this might be it
13:26:16 *** Wormnest has joined #openttd
13:26:42 <Samu_> Wormnest: hi
13:26:49 <Samu_> are you familiar with wrigthai?
13:26:49 *** keoz has quit IRC
13:27:10 <Wormnest> Hi Samu
13:27:20 <Wormnest> Well a little bit but it´s a long time ago
13:27:44 <Samu_> have u come with a bug where it is trying to remove empty airports but it's using the wrong ID?
13:29:19 <Wormnest> No idea, as I said it´s a long time ago
13:35:10 <Samu_> how do I get the location of an airport if the airport is joined with another station (bus stop in this case)?
13:35:25 *** andythenorth has quit IRC
13:35:39 <Samu_> when I get the location of the station, I get the bus stop tile
13:35:48 <Samu_> if I remove that tile, the airport isn't removed :/
13:35:53 <Samu_> bah
13:41:04 <Samu_> gonna try to grab it by the hangar
13:41:05 <Samu_> brb
13:43:16 <Samu_> nah, I need to know the exact top corner of the airport location
13:43:28 <Samu_> can't use hangar location :(
13:44:22 <Wormnest> Have you looked in SuperLib for a useful function
13:47:54 <Samu_> doesn't use superlib :(
13:48:23 <Wormnest> Well you can copy the function from Superlib:
13:48:27 <Wormnest> function _SuperLib_Airport::GetAirportTile(station_id)
13:48:55 <Wormnest> As long as the licenses are compatible that is of course
13:51:28 <Samu_> no idea if they are
13:51:34 <Samu_> ludiai says gpl 2.0
13:53:26 <Wormnest> SuperLib is the same so that´s fine
13:55:37 <Samu_> I found it in superlib
13:55:48 <Samu_> nice, it needs a tilelist just to grab the top corner
14:20:01 *** andythenorth has joined #openttd
14:20:45 <Samu_> thx Wormnest, this fixed it!
14:21:44 <Samu_> this.route_1.RemoveValue(airport_tiles.Begin()); I hope this is doing what I think it does
14:21:54 <Samu_> this.route_2.RemoveValue(airport_tiles.Begin()); I hope this is doing what I think it does
14:21:59 <Samu_> 1 and 2
14:23:02 <Samu_> removes all items, in this case, all vehicleids that have the airport top corner tile as the value
14:30:28 *** keoz has joined #openttd
14:34:42 <Samu_> LuDiAI vs LuDiAI AfterFix, that's how I called it
14:34:51 <Samu_> let's see who wins
14:35:38 *** chomwitt has joined #openttd
14:37:44 *** Thedarkb-T60 has quit IRC
14:41:27 <Samu_> strange, LuDiAI is still doing better
14:44:55 <Samu_> I see why
14:45:57 <Samu_> LuDiAI stops at 500 road vehicles, doesn't have to manage that many road vehicles
14:46:17 <Samu_> more time for handling aircraft
15:09:27 *** Thedarkb-T60 has joined #openttd
15:16:04 *** Maraxus has quit IRC
15:22:53 <Samu_> https://imgur.com/Nlq4mjA
15:23:03 <Samu_> overtook it for the first time
15:27:09 <Samu_> it's unfair, LuDiAI builds airports that doesn't use them
15:28:21 <Samu_> there's less room for airports for the fixed version
15:28:40 <Samu_> interesting paradigm
15:29:26 <LordAro> well of course if you run them both at the same time it's not a fair test
15:29:32 <LordAro> they're competing for the same resources
15:31:15 <Samu_> maybe the map needs to be really big
15:31:20 <Samu_> gonna try 2k map
15:31:27 <LordAro> why would that help?
15:31:34 <LordAro> they use the same logic for deciding where to build
15:31:54 <Samu_> because LuDiAI leaves airports behind, unused, so i need more towns
15:32:07 <Samu_> not sure if this would fix anything, but...
15:32:14 <LordAro> well why are you trying it then?
15:32:15 <Samu_> solve*
15:32:57 <LordAro> the new version will try to build airports at exactly the same town
15:38:13 <Samu_> something else I find it weird
15:38:33 <Samu_> LuDiAI uses big planes on small airports, causing many crashes
15:38:52 <Samu_> my fixed version only uses small planes on small airports, with much much less crashes
15:39:02 <Samu_> and still... by brute force, the big planes win
15:40:12 <Samu_> LuDiAI doesn't sell / renew old planes
15:40:16 <Eddi|zuHause> that's how evil corporations work. lost profits not outweighing the cost of crashes?
15:41:12 <Samu_> my fixed version sells old vehicles, doesn't exactly renew though
15:41:23 *** sim-al2 has quit IRC
15:41:41 <Eddi|zuHause> just use autorenew
15:41:42 <Samu_> if it sold the last vehicle on that route, it also sells the airports
15:42:33 <Samu_> i'm unsure i can use autorenew, because the road part of the code is already renewing manually
15:43:08 <Samu_> it's handling road vehicles pretty different than air vehicles
15:44:57 <Samu_> LuDiAI crashed, the index len does not exist?
15:45:05 <Samu_> must investigate
15:46:17 <Samu_> for(local i = 0; i < m_townRouteArray.len(); ++i) {
15:56:03 <Samu_> what is len supposed to be?
15:57:18 <LordAro> something for determining the length of an array, i imagine
15:57:33 <Samu_> isn't that Count()?
15:57:38 <LordAro> usually
15:59:29 <Samu_> constructor() { m_townRouteArray = [];
15:59:30 *** Thedarkb-T60 has quit IRC
16:01:38 <Wolf01> Bye
16:01:39 *** Wolf01 has quit IRC
16:04:04 <Samu_> i'm unsure how to fix this, will need help
16:04:35 <Samu_> https://paste.openttdcoop.org/pyxd59mk8
16:04:47 <Samu_> the crash happened at line 65
16:05:49 <LordAro> oh ok, it's not an AIList, so it is supposed to be using len()
16:09:12 <Samu_> i'm looking at line 22, return null, and I'm wondering if it should be return 0?
16:09:49 <LordAro> it is a bit unusual to return 2 different types
16:10:01 *** Sacro has quit IRC
16:10:08 <LordAro> but i don't know what value it should actually return
16:10:54 <Samu_> if (routeResult) {
16:11:14 <Samu_> essentially if (1) {
16:11:20 <Samu_> or if (null) {
16:11:50 <LordAro> null is usually falsy, 1 is usually truthy
16:13:47 <Samu_> darn, i should have used restart command
16:13:58 <Samu_> now i dunno if i'm able to replicate the crash
16:15:26 <Wormnest> If it crashed at line 65 then m_townRouteArray must have been null I think
16:16:12 <Samu_> ah, i got a crash report posted about this same problem https://www.tt-forums.net/viewtopic.php?f=65&t=82685&sid=f2c236839d44d16a88d26f5e4298945b
16:16:18 <Samu_> nice of me
16:19:06 *** snail_UES_ has joined #openttd
16:30:02 *** keoz has quit IRC
16:32:11 *** Thedarkb-T60 has joined #openttd
16:35:09 <Samu_> can't reproduce the darn crash :(
16:56:08 *** Gja has joined #openttd
16:57:45 *** Gja has quit IRC
16:57:55 <Samu_> ok, i think i know where the crash originates
16:58:18 <Samu_> when ludiai gets 501 road vehicles, which is over his max of 500
16:59:01 <Samu_> if(MAX_TOWN_VEHICLES == routeManager.getRoadVehicleCount() - 1) { routeManager.m_townRouteArray[i].sendLowProfitVehiclesToDepot(); }
16:59:21 <Samu_> MAX_TOWN_VEHICLES is 500
16:59:27 <Samu_> if (500 == 501 - 1)
16:59:51 <Samu_> he wants to maintain is max of 500 vehicles
17:00:02 <Samu_> and not exceed it
17:01:22 <Samu_> this crash is probably unable to happen on my version because I raised MAX_TOWN_VEHICLES to 5000
17:01:39 <Samu_> as long as openttd max road vehicles is 5000, the ai would never get 5001 road vehicles
17:03:41 <Samu_> but i'd still like to know how to fix it
17:05:30 *** Thedarkb-T60 has quit IRC
17:05:33 <LordAro> i imagine it wants a >= somewhere
17:09:24 <Samu_> (AIVehicle.GetProfitLastYear(vehicle) < (highestProfitLastYear() / 6))) {
17:09:55 <Samu_> problem seems to be highestProfitLastYear()
17:10:14 <Samu_> it should be m_townRouteArray[i].highestProfitLastYear()
17:10:24 <Samu_> if I'm reading this correctly
17:10:49 *** snail_UES_ has quit IRC
17:12:30 <Samu_> or maybe not :(
17:12:54 <LordAro> what is the error message?
17:13:05 <LordAro> the error message should be pointing you at where the problem is
17:13:47 <Samu_> routeManager.highestProfitLastYear() perhaps
17:14:17 <Samu_> the error is https://www.tt-forums.net/viewtopic.php?f=65&t=82685&sid=f2c236839d44d16a88d26f5e4298945b
17:15:11 <LordAro> right, so it's very clear what the error message is
17:15:18 <LordAro> well, not very clear
17:15:20 <LordAro> but clear enough
17:15:51 <LordAro> i.e. the object that calls 'len' does not have that method attached to it
17:16:24 <LordAro> since we've already determined that len must exist on a list object, it can't actually be a list object
17:16:35 <LordAro> why that is is what you've got to work out
17:17:11 <Samu_> replace highestProfitLastYear() with routeManager.highestProfitLastYear()
17:17:17 <Samu_> is that it?
17:17:30 <Samu_> (AIVehicle.GetProfitLastYear(vehicle) < (highestProfitLastYear() / 6))) {
17:17:34 <Samu_> at here
17:17:36 <LordAro> i feel like you didn't read a single word of what i just said
17:17:38 <LordAro> try again
17:17:44 <Samu_> eh ok let me try
17:22:58 <Samu_> the object that calls len
17:23:35 <Samu_> highestProfitLastYear() is the object?
17:23:47 <Samu_> or is it m_townRouteArray
17:23:50 <Eddi|zuHause> that's why i have an ignore list, to protect my sanity
17:23:54 <LordAro> the latter
17:24:05 <LordAro> highestProfitLastYear is a function
17:24:11 <LordAro> (or a function call, depending on context)
17:24:12 <Samu_> doesn't have that method attached to
17:25:54 <Samu_> must attach a method?
17:26:20 <LordAro> that's a bit of a bad explanation, i'll give you that one
17:26:35 <Samu_> routeManager.highestProfitLastyear() - there I attached it :o
17:27:04 <LordAro> right, so highestProfitLastYear is a function method "attached" to routeManager
17:27:11 *** KouDy has quit IRC
17:27:16 <LordAro> so what is len?
17:28:25 <LordAro> (i want you to answer this, so show that you're actually learning something)
17:28:31 <LordAro> to show*
17:28:36 <Gustavo6056> Hey, bros! Who remember me?
17:28:45 <Gustavo6056> remembers*
17:30:04 <Samu_> len, i'm not sure, it keeps track of the built routes .
17:30:05 <Samu_> function buildRoute(buildManager, cityFrom, cityTo, cargoClass)
17:30:17 <Samu_> local route = buildManager.buildRoute(cityFrom, cityTo, cargoClass);
17:30:24 <LordAro> stop pasting code and think about it
17:30:26 <Samu_> m_townRouteArray.append(route);
17:30:49 <Samu_> is the number of routes it has appended?
17:31:10 <LordAro> i was speaking in a more general sense, but close enough!"
17:31:12 <LordAro> -"
17:31:37 <Samu_> if you say it's using null
17:31:48 <Samu_> it would mean m_townRouteArray = null;
17:31:54 <Samu_> it can't be null
17:31:57 <Samu_> they exist already
17:32:05 <LordAro> are you sure about that?
17:32:14 <Samu_> yes
17:32:27 <Samu_> or no?
17:32:39 <LordAro> what happens if highestProfitLastYear is called before the constructor?
17:32:58 *** smoke_fumus has joined #openttd
17:34:14 <Samu_> m_town_RouteArray = null?
17:34:24 <Samu_> m_townRouteArray = null
17:34:45 <Samu_> there is no len?
17:34:51 <LordAro> :)
17:36:26 <Samu_> but they exist already, ludiai is now trying to remove the least profit vehicles from his routes
17:36:42 <LordAro> if i'm remembering my squirrel correctly, you can call methods with and without the class instance
17:36:54 <LordAro> which is rather confusing
17:38:25 *** Sacro has joined #openttd
17:43:08 <Samu_> here's the other function https://paste.openttdcoop.org/pyzhscwft
17:43:28 <Samu_> line 23
17:44:15 <LordAro> not sure i can help you significantly further, play around, add some debug print statements, see what you find
17:44:48 <Samu_> it's a function on Route.nut calling another from RouteManager.nut
17:45:50 <Samu_> im trying now to replicate the crash, but not sure how to make it trigger
17:46:23 <Samu_> just know that it got to get 501 vehicles
17:46:41 <Samu_> and be running that part of the code in that exact moment
17:49:48 <Samu_> the sum of the cargo waiting must also be more than 150
17:51:17 <Samu_> the vehicle must also be older than 2 years
17:53:40 <Samu_> very hard conditions to get it to trigger
17:53:59 <Samu_> must have not sold a vehicle in the last 2 months
17:56:50 *** KouDy has joined #openttd
17:58:26 <Samu_> routeManager.m_townRouteArray[i].sendLowProfitVehiclesToDepot();
17:58:38 <Samu_> the array exists!
18:00:41 <Samu_> gonna try increase the chances by creating BIIIG CITIES on start up
18:02:14 <Samu_> oh crap, the cpu usage deal
18:07:15 <Samu_> reduced the max vehicles to 150, let's see if i can make it happen
18:07:22 <Samu_> quckly
18:08:59 <Wormnest> I would add a check for m_townRouteArray == null and if it is write a debug msg
18:09:45 <Samu_> aha, got a crash!
18:10:11 <Samu_> mister white got 151 vehicles and crashed
18:10:35 <Samu_> meanwhile I found some other with 152 and didn't crash, then again the function requires an exact match of 151
18:10:45 <Samu_> this seems more buggy than I first thought
18:14:49 <Samu_> (AIVehicle.GetProfitLastYear(vehicle) < (routeManager.highestProfitLastYear() / 6))) {
18:14:55 <Samu_> restesting with this change
18:18:43 <Samu_> the index routeManager does not exist :(
18:18:50 <Samu_> became worse
18:22:14 <Samu_> LuDiAIAfterFix.routeManager.highestProfitLastYear()
18:22:24 <Samu_> i have to pass the darn routeManager around
18:22:33 <Samu_> just dunnot how, yet
18:25:05 <Samu_> routeManager = RouteManager();
18:25:11 <Samu_> so I see
18:25:29 *** agentw4b_ has joined #openttd
18:27:40 <Samu_> sorry :( doesnt work
18:28:36 <Samu_> I'll never learn
18:31:43 <LordAro> not if you refuse to learn the basics
18:32:55 *** agentw4b__ has quit IRC
18:38:35 *** agentw4b__ has joined #openttd
18:39:29 *** agentw4b___ has joined #openttd
18:40:53 <Samu_> trying something else
18:40:56 <Samu_> for(local i = 0; i < routeManager.m_townRouteArray.len(); ++i) {
18:44:56 <Samu_> the index routeManager doesn't exist :(
18:45:03 <Samu_> fake news
18:45:07 <Samu_> it exists :(
18:45:20 *** agentw4b____ has joined #openttd
18:45:42 <LordAro> routeManager is not the same as RouteManager
18:46:10 *** agentw4b_ has quit IRC
18:46:55 *** agentw4b__ has quit IRC
18:47:40 *** agentw4b_ has joined #openttd
18:48:19 <Samu_> there is a constructor in main.nut with routeManager = RouteManager();
18:48:38 <Samu_> I want to get it
18:49:32 <Samu_> there can be only 1
18:50:23 <Samu_> all route operations are being done into 'routeManager'
18:50:35 <Samu_> so it's on this one i got to get the array from
18:50:43 <Samu_> but I can't seem to reach it
18:52:49 *** agentw4b___ has quit IRC
18:53:25 *** agentw4b____ has quit IRC
18:59:28 *** Gja has joined #openttd
19:00:18 *** Thedarkb-T60 has joined #openttd
19:14:40 *** Thedarkb-T60 has quit IRC
19:30:41 *** Thedarkb-T60 has joined #openttd
19:33:37 *** glx has joined #openttd
19:33:37 *** ChanServ sets mode: +v glx
19:47:51 <Samu_> i managed to do it
19:48:12 <Samu_> not with the best approach though, but will suffice for now
19:51:57 *** Gja has quit IRC
20:05:34 *** tokai|noir has joined #openttd
20:05:34 *** ChanServ sets mode: +v tokai|noir
20:12:34 *** tokai has quit IRC
20:17:09 <Samu_> routeManager.m_townRouteArray[i].sendLowProfitVehiclesToDepot(routeManager);
20:17:46 <Samu_> (AIVehicle.GetProfitLastYear(vehicle) < (highestProfitLastYear(routeManager) / 6))) {
20:18:08 <Samu_> for(local i = 0; i < routeManager.m_townRouteArray.len(); ++i) {
20:18:17 <Samu_> and thus, the routeManager was passed around
20:18:24 <Samu_> :)
20:19:03 <Samu_> because I don't know how to do it the right way
20:21:36 <peter1138> ew at "for("
20:23:30 <Samu_> I would prefer to access it directly
20:24:05 <Samu_> but nevermind. it works, it's what matters for now
20:46:57 *** gelignite has joined #openttd
20:54:34 *** Maraxus has joined #openttd
20:57:06 *** andythenorth has quit IRC
21:10:53 *** andythenorth has joined #openttd
21:14:20 *** Thedarkb-T60 has quit IRC
21:15:04 *** KouDy has quit IRC
21:18:11 *** iSoSyS has joined #openttd
21:20:55 *** sla_ro|master has quit IRC
21:49:39 *** KouDy has joined #openttd
22:12:31 *** andythenorth has left #openttd
22:23:05 *** sim-al2 has joined #openttd
22:38:34 *** Maraxus has quit IRC
22:39:07 *** frosch123 has quit IRC
22:39:22 *** gelignite has quit IRC
22:56:22 *** synchris has quit IRC
22:58:37 *** agentw4b__ has joined #openttd
23:02:50 *** agentw4b_ has quit IRC
23:14:47 *** Thedarkb-T60 has joined #openttd
23:41:35 *** smoke_fumus has quit IRC