trAInsported

Show off your games, demos and other (playable) creations.
User avatar
AnToHu0
Prole
Posts: 17
Joined: Tue Mar 19, 2013 6:05 am
Location: South Urals

Re: trAInsported: Alpha testers needed

Post by AnToHu0 »

Is that possible to know where one of my trains locates now? For example my train goes to a passenger, but another AI boards him first and i need to recalculate the path to new goal. For this i need to know current coordinates of my train. Ofcource its possible to wait when the train arrives to next junсtion, but this way it needs more calculations to check stored passengers list.
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: trAInsported: Alpha testers needed

Post by Germanunkol »

AnToHu0 wrote:Is that possible to know where one of my trains locates now? For example my train goes to a passenger, but another AI boards him first and i need to recalculate the path to new goal. For this i need to know current coordinates of my train. Ofcource its possible to wait when the train arrives to next junсtion, but this way it needs more calculations to check stored passengers list.
Hey,
No, that's not possible. Of course, you could estimate, but since you can't actually do anything when not at a junction, the calculations I'd have to do internally would probably be almost as costly as the calculations people need to do now. However, I'll think about just exposing the internal train values to the users, maybe that's possible somehow.

One thing I noticed: Everyone seems to be using Djikstra, A* or similar algorithms. All of these work in real-time, there's no pre-calculation involved. However, since there's more time in ai.init() than in any other function, it might be smart to set up some sort of net of connections in there. Dijkstra could even work with that...
Has anyone tried something like this? I realise it's more involved, but it might be worth it...
asfreng wrote:np dude, thats its free xD, how can i test my AI using the numbers of lines u are using in the server?
I decided to leave it at the old settings for the time being. But you can see how the server has a real hard time keeping up when you connect to it and your AI is playing...
You can however get the source code from github or extract the .love file I posted, open Scripts/ai.lua and change the line
local MAX_LINES_EXECUTING = 20000
near the top to something like
local MAX_LINES_EXECUTING = 5000

I might have to go for 5000 or so in the future. That's too bad :( But I don't see a way around this. One of my friends suggested being able to "buy" more code-lines using the money the train makes, that might be interesting in this case.
Maybe I'll set a maximum 5000, unless you spend money on code lines, in which case you can get up to 10 000 lines.
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
asfreng
Prole
Posts: 14
Joined: Tue Mar 19, 2013 10:40 pm

Re: trAInsported: Alpha testers needed

Post by asfreng »

thx, ill try to make it ligther :)
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: trAInsported: Alpha testers needed

Post by Germanunkol »

asfreng wrote:thx, ill try to make it ligther :)
Wow, your new AI seems to kick ass... well done, it's won all of its matches so far!
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
asfreng
Prole
Posts: 14
Joined: Tue Mar 19, 2013 10:40 pm

Re: trAInsported: Alpha testers needed

Post by asfreng »

Here is some feedback:

- I did upgrades in the code of two types +performance -lines and -performance -lines, the second are the problem, for example

(2 lines)
local aux = "this" .. "is" .. "a".. "string"
local aux2 = aux .. aux .. aux .. aux .......

changing to

(1 line)
local aux2 = "this" .. "is" .. "a".. "string" .. "this" .. "is" .. "a".. "string" ........

is a -performance -lines, that means, its more "heavy" to calculate but it has less line count

here is other example

table.sort( {2,34,45,5,6,3,12,3,23,4,34,5} )
line cost 1!!!!!, in large tables it can be a problem :(

There is a way to take the real line cost of build in functions?

- Theres a way to get the time to a passanger lose his vip status? (i mean without calculate it, something like passanger.vipTimeLeft)
It would be very usefull :)
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: trAInsported: Alpha testers needed

Post by Germanunkol »

asfreng wrote:Here is some feedback:

- I did upgrades in the code of two types +performance -lines and -performance -lines, the second are the problem, for example

(2 lines)
local aux = "this" .. "is" .. "a".. "string"
local aux2 = aux .. aux .. aux .. aux .......

changing to

(1 line)
local aux2 = "this" .. "is" .. "a".. "string" .. "this" .. "is" .. "a".. "string" ........

is a -performance -lines, that means, its more "heavy" to calculate but it has less line count

here is other example

table.sort( {2,34,45,5,6,3,12,3,23,4,34,5} )
line cost 1!!!!!, in large tables it can be a problem :(

There is a way to take the real line cost of build in functions?
Thanks for the tests!
This is indeed a problem, and I tried to figure this one out for quite some time now.
I use the sethook function to count the number of Lua executions. Using this, I could stop the coroutine after a certain amount of time or a certain amount of lines. With lines, the problem is that they, as you noticed, don't take the same amount of line and don't even correspond 1:1 to the number of lines.
When stopping after a certain time instead, the problem is that the game runs very differently on different PCs, making the idea of an online server running the same script unusable...
asfreng wrote:
- Theres a way to get the time to a passanger lose his vip status? (i mean without calculate it, something like passanger.vipTimeLeft)
It would be very usefull :)
Uhm, it should be easy to calculate, right?
Since I don't have any functions that actually allow access to the VIPs, the easiest way is to store the time when ai.newPassenger is called. Just use os.time() to calculate the difference.
Anything I'd do internally would just take more lines again...
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
asfreng
Prole
Posts: 14
Joined: Tue Mar 19, 2013 10:40 pm

Re: trAInsported: Alpha testers needed

Post by asfreng »

Germanunkol wrote: Thanks for the tests!
This is indeed a problem, and I tried to figure this one out for quite some time now.
I use the sethook function to count the number of Lua executions. Using this, I could stop the coroutine after a certain amount of time or a certain amount of lines. With lines, the problem is that they, as you noticed, don't take the same amount of line and don't even correspond 1:1 to the number of lines.
When stopping after a certain time instead, the problem is that the game runs very differently on different PCs, making the idea of an online server running the same script unusable...
Yes, count time is not a option, ill tell u if I think something to solve it :(
Germanunkol wrote: - Theres a way to get the time to a passanger lose his vip status? (i mean without calculate it, something like passanger.vipTimeLeft)
It would be very usefull :)
Uhm, it should be easy to calculate, right?
Since I don't have any functions that actually allow access to the VIPs, the easiest way is to store the time when ai.newPassenger is called. Just use os.time() to calculate the difference.
Anything I'd do internally would just take more lines again...
nevermind this, is more simple than i thought
User avatar
AnToHu0
Prole
Posts: 17
Joined: Tue Mar 19, 2013 6:05 am
Location: South Urals

Re: trAInsported: Alpha testers needed

Post by AnToHu0 »

In my AI i need to use the sleep(s) function, i implement it by using os.time() and "while true" cycle, but i can`t use it because of run time restrictions of game. Is there a way to create and use sleep function in game?
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: trAInsported: Alpha testers needed

Post by Germanunkol »

Uhm... why do you need to sleep?
Any calculation done by your AI should be as fast as possible, because it pauses the entire game...
Or to put it into other words: while your AI sleeps, nothing happens in the game. After you're done sleeping, the game state will be exactly the same as before. So there's no point in sleeping, really...
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
User avatar
AnToHu0
Prole
Posts: 17
Joined: Tue Mar 19, 2013 6:05 am
Location: South Urals

Re: trAInsported: Alpha testers needed

Post by AnToHu0 »

Yes, you are right. I`m already understood how to solve the problem, without using sleep function. I forgot that there are no parallel threads in lua and sleep in one AI can freeze all game ;)
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google Adsense [Bot] and 4 guests