Topic: AI: init.lua blocks the game
Tibor Topic Opener |
Posted at: 2014-01-31, 22:08
I did not know about break... Also goto will be much usefull one time in future Thanks for advices! Top Quote |
fk |
Posted at: 2014-02-01, 15:17
That is new to me, but actually I assumed that the routine had to receive 'true' where it receives 'nil'. But as Tibor states, it works flawlessly. Top Quote |
SirVer |
Posted at: 2014-02-02, 19:48
As mentioned before I also got intrigued and though about writing some AI stuff in Lua. So I started with a road connection algorithm - also I was interested how much work it would be to pull this off in Lua. It is a little rough around the edges, but basically works. I agree that the engine should provide this to Lua instead of this needed to be written in Lua, but oooh well. For now you can find my little script here: https://gist.github.com/SirVer/8773693 I think I will drop it into the repository, probably in infrastructure.lua. But not before b18 and not before I wrote some tests for it. In the meantime, I hope it is useful. Top Quote |
Tibor Topic Opener |
Posted at: 2014-02-02, 21:31
SirVer thanks for effort, I will investigate the code thoroughly... Just small comment - the algorithm presumes you know the both fields to be connected. But usually you know one end of a road (a new building) but not the other one. Or rather - you might not care where the road is to be connected. It just have to be connected to a road... Anyway you code is very usefull for me... Top Quote |
SirVer |
Posted at: 2014-02-03, 10:16
that function should be easy to write. Something along these lines could work:
Top Quote |
Tibor Topic Opener |
Posted at: 2014-02-03, 19:20
Thanks, today I created my own algorithm, but I studied your code, it was usefull. F.e. sets are very neat... And the nearest field might not allways be the one where you can build the shortest road to. My algorithm finds all possible connection points in radius 10 (it is customizable, of course) and pick the one that is reachable with shortest path... but of course, at the end usually it is the same point... Top Quote |
SirVer |
Posted at: 2014-02-03, 20:30
If you come up with a bunch of nice algorithms I think we should put them into infrastructure.lua or something similar. This road building algo for example might be useful for scenarios too. Top Quote |
Tibor Topic Opener |
Posted at: 2014-02-03, 21:50
I would like to have in few days (or short weeks) a "technological preview" - very primitive AI that can 'colonize' the whole map, of course without fighting an enemy... so of course the code will be avaiable... I myself wonder if it will work the way I hope .... Top Quote |