Topic: LUA AI development preview :)
Tibor Topic Opener |
Posted at:
2014-02-06, 22:17 UTC+1.0
Well, everybody who is interested in my LUA AI can download map that has AI incorporated in it, here: https://drive.google.com/folderview?id=0BwLCOOJL0crnZ25KcklqTWlrQ3c&usp=sharing Download and unpack it in maps folder so the result would be folder named scen-test.wmf (yes, the suffix as if it was a file) Then run it as: /...../widelands --scenario=/home/tibor/.widelands/maps/scen-test.wmf This is under linux, of course The map is only for one player - you, but just dont interfere, only watch... Currently it can expand territory and build wood "industry". After short time the game goes into phase 'wood shortage' when all bulding except for wood-related is stopped. In fact you should watch graph of teritory and trunk cutting. After some time the game reaches a point when there are no free soldiers and can not expand further. Everything is very random so next time the game can develop quite differently No mining nor farming is incorporated yet... So far biggest obstacles are:
Even that what is implemented is not to be considered a final version of algorithm.... Any ideas welcommed, though I have many of them in my head yet... ![]() ![]() |
SirVer |
Posted at:
2014-02-07, 07:33 UTC+1.0
Cool stuff, congratulations. If you are happy with staying in this mode where you watch the AI play as the controlling player, you can also use UI scripting to implement the missing functionality. For example to stop a building wl.ui.MapView():click(field_of_building). Then you have to look which windows are open by iterating through wl.ui.MapView().windows and in the window you can look at win.buttons and finally :click() the button you are interested in (like stopping the building). This is cheating because you cannot do it for other players then the one that is currently played, but it can give you a way to try your features. ![]() ![]() |
Tibor Topic Opener |
Posted at:
2014-02-07, 21:22 UTC+1.0
Well I will look at those UI stuff - because I need that functionality. Moreover, once the direct LUA API will be added, replacement will be trivial... I have long period of development in single AI 'watch only' mode in front of me. Later on I can easily allow also standard AI players into the game and let them fight... If my enthusiasm will persist that long...
Edited:
2014-02-07, 23:34 UTC+1.0
![]() ![]() |
Tibor Topic Opener |
Posted at:
2014-02-10, 22:26 UTC+1.0
Hi, so I tested the UI stuff. It works. Kind of... I spend couple of hours today, I implemented dismounting of buildings, stopping and resuming production (rangers and hardeners) and decreasing number of soldiers in a building. But it did not worked properly. On the beginning of the game it did, but later on it was not reliable. It looked like dialog window for wrong building were opened. Wrong buildings were dismounted and so on. Though all manipuation with windows was not visible so I can not say for sure... Moreover, it stole my cursor and I was not able to put the widelands window into background and work on something else.. So this is not a way to go. I am sorry... Especially because I spent some time on it. If somebody will be so willing to add needed APIs to the game I would resume my work though ![]() ![]() |
SirVer |
Posted at:
2014-02-11, 08:07 UTC+1.0
you can look at the tutorial in campaigns to see how you can make the cursor move slowly so you can see what is happening.
But that would make your AI not be compatible anymore - didn't you say you did not want to add new stuff to the engine? I think your needs can be accommodated after b18 - most of the methods should be fairly easy to add. ![]() ![]() |
Tibor Topic Opener |
Posted at:
2014-02-11, 22:09 UTC+1.0
No, I dont like the idea at all I believe what I want should be easy to implement and no changes to "engine" should be needed, because those functionality is allready implemented via graphical interface. So I could say it would be kind of a parity of GUI vs LUA API ![]() ![]() |
SirVer |
Posted at:
2014-02-11, 22:26 UTC+1.0
Everything that needs changes in c++ are changes to the engine in mind. I agree that it should be fairly easy to add - but you said earlier that you do not want to touch the c++ code because your AI would no longer be portable. That got me confused. If you want those features it is the best idea that you add them yourself - you might be able to persuade others to do it, but to have it right when you need them you better program them yourself. ![]() ![]() |
Tibor Topic Opener |
Posted at:
2014-02-11, 23:02 UTC+1.0
Allright, may be these are changes to engine - from my understanting I do not want any changes in the way how widelands internally works, I have no idea how it works. Also a person who plays the game does not need to understand what is going under the hood... Changes that would take 30 minutes for experienced widelands developer might take 10 hours for me (if not much more). And I am not interested in the development of widelands itself as I was not interested into development of road algorithm and so on... And I dont want to have own incompatible version of widelands on my PC and not be able to show my work to anybody. So this is my stand, if some good soul implements missing features I will gladly resume my work. If not, I still be glad because I learned new stuff!
Edited:
2014-02-11, 23:50 UTC+1.0
![]() ![]() |
SirVer |
Posted at:
2014-02-12, 06:14 UTC+1.0
Now I understand better what you meant with 'no incompatible changes'. Before b18 no new features can go into Widelands - so you'll have to wait till b18 is released before we can add the features you need to the Engine. Till then, UI scripting is the best you can do to implement your features. ![]() ![]() |
Tibor Topic Opener |
Posted at:
2014-02-12, 23:05 UTC+1.0
Thanks for your understanding ![]() ![]() |