SoC2012 Tyrannodogg Make lua AI developement easier

From The Battle for Wesnoth Wiki

This page is related to Summer of Code 2012
See the list of Summer of Code 2012 Ideas

This is a Summer of Code 2012 student page


Tyrannodogg - Make lua AI development and usage easier

At the moment the parts, which make a lua AI, are scattered around several WML Entities, resulting in a load of boilerplate code.

My approach is to shift more parts of the functionality into lua code, in a way that simple scripts can handle all steps necessary.

This includes wrapping the current default AI for lua usage.

I will also provide scripts for logging and further debugging.



SoC Application

Submitted to google


In order to get familiar with the codebase i am working on the following patch:

Further explanation

In the end I'd like to have a luaAI look like the following example and have at least the described capabilities or similar ones

  engine = "lua"
  code = <<
  -- make all print calls chat messages instead
  --could also be default_ai.no_actions
  ai = require("default_ai.all_actions")
  --add a new action
  ai.beserk = {}
  function ai.beserk.evaluation() return 50000 end
  ai.beserk.execution = require("my_clever_script")
  --delete a action
  --modify an action
  local move_eval = ai.ca_move.evaluation
  function ai.ca_move.evaluation(...) 
      --make move less important
      local result = move_eval(...)
      return result / 2
  --for a whole new ai approach even the main loop may be interchangeable
This page was last edited on 29 April 2012, at 19:35.