Currently Online

Latest Posts

Topic: AI as a scipt

Ron_of_Nord
Avatar
Topic Opener
Joined: 2024-04-20, 23:43
Posts: 42
OS: Windows
Version: 1.2.1
Ranking
Pry about Widelands
Location: Land_down_under
Posted at: Yesterday 04:10

Hi Folks, I read a few posts on the AI and got to wondering wether the inbuilt scripting could handle or improve the current AI, I don't have a constant fast internet connection, I use a dongle, so trying to read through the Lua scripting pages gets a bit frustrating when the connection drops out. Is there a plain text version of the Widelands Lua scripting interface I can get my hands on. I have a love og game AI and some ideas on that front, but I really need either a plain text or pdf version of the inteface to have a look at while I'm testing my ideas. Also, is the sciprt compiled or interpreted, I couldn't figure it out from the source code this morning when the AI idea's I had first blossomed in my mind. After creating my own game AI language ( which is a script language) , I thought maybe I could try rewritting parts of it as a Lua script in widelands. My own AI language is written in Forth with a prolog extention. I don't know the widelands lua interface well enough to attempt anything but some simple code at the moment.


The aussies are coming, ya ho! ya ho!

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2082
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: Yesterday 10:17

You can download the latest documentation as a ZIP archive of HTML files here:
https://github.com/widelands/widelands/releases/download/latest/Widelands-daily-Developer-Documentation.zip

I once tried to script an AI for a scenario, but I gave that up because the main problem with Lua is that is is extremely slow compared to C++. Everything in Lua is interpreted at runtime. To get acceptable performance I believe you'd need to compile your code into the Widelands executable, using C++ or some other language that can interface with C++ headers.


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2750
Ranking
One Elder of Players
Location: Bavaria
Posted at: Yesterday 20:03

Currently there is no direct lua api to influence or control the AI.

Our lua interface was originally invented to control the storyline of a scenario.
after some time it was chosen to implement the definitions of the tribes units as well.
And finally it is and gets still widened to control the ui of the game for various reasons.

The AI is only influenced by the tribe defin ition files where some vital information is stored that the AI uses to have better knowledge of a tribe.

In the c++ functions there are several decision steps implemented which are run according to a scheduler:
- building buildings
- building roads
- diplomacy
- building ships
- attacking enemies
- ,anage soldiers
- etc.

each of this functions is influenced by a a simple implementation of a genetic algorithm, which mainly influences the weights of game state parameters in decision finding algorithms.


Top Quote