Sending orders from Lua

Can you help improve your favourite game? Hardcore C mages, talented artists, and players with any level of experience are welcome!
Post Reply
crater2150
Posts: 1
Joined: Mon Apr 11, 2016 2:44 pm

Sending orders from Lua

Post by crater2150 »

Hello,

For my master thesis, I'm developing an AI module, where most of the actual decision making is done in a Lua-Script (the module is to be used in AI courses for students with no experience in C, so a simple API and not needing the build chain set up are the main goals).

Based on the API docs I understand there are no Lua methods yet for giving orders to units and cities, setting taxes etc., so I started implementing these. But I am unsure, if I am calling the right functions. Should I use the handle_unit_do_action and handle_unit_change_activity functions or rather unit_perform_action and unit_activity_handling(_targeted)?

Another question: today my supervisor asked, if it was feasible to modify a client and implement the AI there instead of a server-side module, so that the AI could handle only some decisions (a kind of client-side advisor). Would the calls to send orders be similar to the ones the AI uses on the server side or would I have to rewrite my Lua extensions completely?
Thanks,
Alexander
cazfi
Elite
Posts: 3077
Joined: Tue Jan 29, 2013 6:54 pm

Post by cazfi »

Nothing prevents you from implementing your work on some other level, but I'd recommend doing it via our AI-module API. You may start by reading doc/README.AI_modules.

Freeciv sources have three different AI-modules (though only one is currently used in practice, others being more like dummies but showing the API part anyway); "classic", "threaded", and "stub". I'm aware of one external project building on top of that API: https://github.com/i1abnrk/fc_attitudeai

At this time the work would be easiest to make on top of freeciv S2_6 branch. The main reason being that freeciv headers have been made usable from external AI projects in S2_6: ( https://gna.org/bugs/?17582 , https://gna.org/bugs/index.php?24334 )

There was an attempt to make lua-AI module years ago, but it got stalled; https://gna.org/patch/?2554
Post Reply