URL:
<http://gna.org/patch/?1016>
Summary: Added 'def' keyword to FormulaAI
Project: Battle for Wesnoth
Submitted by: dhains
Submitted on: Friday 03/21/2008 at 08:53
Priority: 1 - Later
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
Added a new keyword 'def' to FormulaAI. This keyword allows creation of
functions using the following syntax:
def my_function(x,y) x + y
I had to remove const qualifiers to the function symbol table to allow
modification within formula.cpp / formula.hpp and I also added code to this
file to parse the command and add it to the symbol table.
formula_tokenizer.cpp was modified to allow identification of the new
keyword.
Error checking is done to make sure the arguments are valid identifiers and
that the syntax of the def command and arguments is correct, however the
syntax of the actual formula (i.e. 'x + y' in the above example) is not
checked at this point.
Test of the functionality can be done in scenario-formula.cfg where the
function 'make_func' is defined as 'def adder(x,y) x+y'. If the controller
of the FormulaAI side is set to human in scenario-formula.cfg and wesnoth is
started with wesnoth --test formula --debug, the function adder can be called
from the formula debugging console and returns the appropriate values, e.g.
adder(2,3) returns 5.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Friday 03/21/2008 at 08:53 Name: def.patch Size: 6kB By: dhains
<http://gna.org/patch/download.php?file_id=4009>
_______________________________________________________
Reply to this item at:
<http://gna.org/patch/?1016>
_______________________________________________
Message sent via/by Gna!
http://gna.org/
_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs