patchFreeciv - Patches: patch #2554, lua AI module

Show feedback again

patch #2554: lua AI module

Submitted by:  Matthias Pfafferodt <syntron>
Submitted on:  Tue Feb 22 13:42:11 2011  
Category: aiPriority: 5 - Normal
Status: In ProgressPrivacy: Public
Assigned to: NoneOpen/Closed: Open
Planned Release: Contains string changes: None

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Fri Mar 8 03:45:53 2013, comment #12:

Ah, sorry, I misread the player_alloc stuff.

Marko Lindqvist <cazfi>
Project Administrator
Thu Mar 7 21:22:44 2013, comment #11:

Thanks for the comments! I will change the patch accordingly.

Could you help me to find the place there default ai player_alloc is called?

The calling structure is:
. => lai_player_alloc (lai_func.c)
.. => player_set_ai_data (using struct lai_plr *luaplr as ai data)
.. => lai_api_player_alloc (api_lai_base.c)
... => dai_data_init

Matthias Pfafferodt <syntron>
Project Member
Thu Mar 7 18:27:23 2013, comment #10:

First data handling error I notice:

luaai player_alloc allocates memory and stores it to player structure. But default ai player_alloc gets called too, overwriting the pointer.

Marko Lindqvist <cazfi>
Project Administrator
Thu Mar 7 18:18:46 2013, comment #9:

- Build system needs to handle luaai as independent type. Now it seems to depend on how threaded ai is configured.
- Increase of maximum number of simultaneous AI types is separate change which should not be part of this patch.

Marko Lindqvist <cazfi>
Project Administrator
Thu Mar 7 15:19:52 2013, comment #8:

please remember to apply the dependencies patch #2969 and bug #20600 before this one

Matthias Pfafferodt <syntron>
Project Member
Thu Mar 7 15:16:19 2013, comment #7:

I reworked the lua ai patch. At the moment it can be activated (use ./fcser -L lua) and runs without crash or errors. But, the lua AI does not really moves its units etc. Thus, help is needed!

I suspect the error in the area of data handling. The AI functions use arguments which are not handled in the default lua name space. Remembering the calling flow:

<server> => LuaAI function => call to lua => callback to C => default AI

the arguments (pointers) have to be 'tunneled' throw lua. I use a 'dummy' data type lai_data for this. It 'transports' the pointer via the lua environment. I'm not sure if this is the corret way to go ...

(file #17404)

Matthias Pfafferodt <syntron>
Project Member
Fri Nov 4 20:48:22 2011, comment #6:

I've skimmed through the whole patch, and I have to say that it looks promising. I hope you can commit this soon (As a general note, I personally don't like your habit of committing huge patch series at once - while you keep individual patches manageable small, committing them at once does not really give me possibility to look them one small bit at a time. I usually end up checking only first patch of the series. I'd much prefer you committed first patches of the series once they are ready and you're still working on latter ones)

Marko Lindqvist <cazfi>
Project Administrator
Wed Nov 2 23:54:42 2011, comment #5:

Looked just configure stuff, and that at least is not at all correct. Search ai/ and for word "threaded" to see how enabling/disabling static/dynamic threaded ai is implemented.

Marko Lindqvist <cazfi>
Project Administrator
Thu Sep 22 19:27:19 2011, comment #4:

updated version - it (kind of) works:

- all callbacks are implemented but do nothing at the moment

(file #14143)

Matthias Pfafferodt <syntron>
Project Member
Thu Jun 9 11:08:29 2011, comment #3:

Well, finishing of default ai code refactoring is still week or two away since I were absent for a while. I'm not only posting to repeat over and over that we are still a week away from completion. Progress has been made, and now all the patches have already been made (they still need fixing, but at least we have tickets to follow now). Remaining ones are patch #2692, patch #2693, patch #2694 and patch #2286

Marko Lindqvist <cazfi>
Project Administrator
Tue Mar 1 15:57:26 2011, comment #2:

In any case I think we should finish refactoring of default ai code before lua ai module stuff starts to go in. I don't want latter to postpone former by adding complexities. Default ai work is more than our internal cleanup (of default ai itself). It gives clear base to build other ai modules, and I actually consider it a requirement for any custom ai module.
Default ai refactoring is quite close to completion. This means. scale of the project being that I started it almost two years ago, that we should be just a couple of weeks from the point where it can be considered done.

Marko Lindqvist <cazfi>
Project Administrator
Tue Mar 1 15:39:13 2011, comment #1:

Trying to open file #12399:
"Non-authorized access to file attached to private item"

Marko Lindqvist <cazfi>
Project Administrator
Tue Feb 22 13:42:11 2011, original submission:

file #12399 defines a stub for a lua ai module. This is posted here as foundation for further patches ...

Matthias Pfafferodt <syntron>
Project Member


(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files


   bug dependencies, patch dependencies.

   patch dependencies.


Carbon-Copy List
  • -unavailable- added by cazfi (Posted a comment)
  • -unavailable- added by syntron (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Error: not logged in



    Follow 11 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed Aug 13 00:14:49 2014cazfiPlanned Release2.5.0=>
    Thu Mar 7 15:17:44 2013syntronDependencies-=>Depends on bugs #20600
    Thu Mar 7 15:17:01 2013syntronDependenciesRemoved dependancy to bugs #18732=>-
    Thu Mar 7 15:16:19 2013syntronAttached File-=>Added 0006-basic-commit-for-a-lua-ai.patch, #17404
      StatusReady For Test=>In Progress
      Summarystub lua AI module=>lua AI module
    Fri Oct 28 21:47:05 2011syntronPlanned Release2.4.0=>2.5.0
    Sun Sep 25 10:12:40 2011syntronDependencies-=>Depends on bugs #18732
    Thu Sep 22 19:27:32 2011syntronDependencies-=>Depends on patch #2969
    Thu Sep 22 19:27:19 2011syntronAttached File-=>Added 0001-basic-commit-for-a-lua-ai.patch, #14143
    Tue Feb 22 13:42:44 2011syntronDependencies-=>patch #2143 is dependent
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup