patchFreeciv - Patches: patch #2554, lua AI module

Show feedback again

patch #2554: lua AI module

Submitted by:  Matthias Pfafferodt <syntron>
Submitted on:  Tue 22 Feb 2011 01:42:11 PM UTC  
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 08 Mar 2013 03:45:53 AM UTC, comment #12:

Ah, sorry, I misread the player_alloc stuff.

Marko Lindqvist <cazfi>
Project Administrator
Thu 07 Mar 2013 09:22:44 PM UTC, 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 07 Mar 2013 06:27:23 PM UTC, 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 07 Mar 2013 06:18:46 PM UTC, 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 07 Mar 2013 03:19:52 PM UTC, comment #8:

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

Matthias Pfafferodt <syntron>
Project Member
Thu 07 Mar 2013 03:16:19 PM UTC, 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 04 Nov 2011 08:48:22 PM UTC, 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 02 Nov 2011 11:54:42 PM UTC, 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 22 Sep 2011 07:27:19 PM UTC, 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 09 Jun 2011 11:08:29 AM UTC, 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 01 Mar 2011 03:57:26 PM UTC, 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 01 Mar 2011 03:39:13 PM UTC, comment #1:

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

Marko Lindqvist <cazfi>
Project Administrator
Tue 22 Feb 2011 01:42:11 PM UTC, 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 13 Aug 2014 12:14:49 AM UTCcazfiPlanned Release2.5.0=>
    Thu 07 Mar 2013 03:17:44 PM UTCsyntronDependencies-=>Depends on bugs #20600
    Thu 07 Mar 2013 03:17:01 PM UTCsyntronDependenciesRemoved dependancy to bugs #18732=>-
    Thu 07 Mar 2013 03:16:19 PM UTCsyntronAttached File-=>Added 0006-basic-commit-for-a-lua-ai.patch, #17404
      StatusReady For Test=>In Progress
      Summarystub lua AI module=>lua AI module
    Fri 28 Oct 2011 09:47:05 PM UTCsyntronPlanned Release2.4.0=>2.5.0
    Sun 25 Sep 2011 10:12:40 AM UTCsyntronDependencies-=>Depends on bugs #18732
    Thu 22 Sep 2011 07:27:32 PM UTCsyntronDependencies-=>Depends on patch #2969
    Thu 22 Sep 2011 07:27:19 PM UTCsyntronAttached File-=>Added 0001-basic-commit-for-a-lua-ai.patch, #14143
    Tue 22 Feb 2011 01:42:44 PM UTCsyntronDependencies-=>patch #2143 is dependent
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup