Commit graph

165 commits

Author SHA1 Message Date
Mark de Wever
973a0a7d5c Remove trailing whitespace. 2009-01-01 10:28:26 +00:00
Mark de Wever
a5d1d2e969 New year copyright update. 2009-01-01 10:27:41 +00:00
Tomasz Śniatowski
e11598ce0e Rename unit_type_map::find to unit_type_map::find_unit_type.
This function has been problematic so it's better if it has a unique
way that's easy to grep for.
2008-12-27 18:30:44 +01:00
Mark de Wever
cb2b8708b8 Fixed compilation with Python 2.6 (bug #12638 (included a patch)). 2008-12-09 14:02:51 +00:00
Alexander van Gessel
f42a8aac32 Fix some syntax errors in python2.6 ifdefs. 2008-12-05 19:25:11 +01:00
Eric S. Raymond
8e23cdb6a7 Address bug #12638 (compilation crash). This is a theoretical fix based
on examining the 2.6 Python.h header.  It will need testing.
2008-12-05 13:19:16 +00:00
Ignacio R. Morelle
c0d39e3de9 Hopefully reduced cohesion a bit by moving the...
...end_*_exception classes/structs out from menu_events.hpp.
2008-11-23 17:23:42 +00:00
Sergey Popov
9441fcec27 Committed ivan_i's fixes for his patch(2008-11-17T19:20:48Z!loonycyborg@gmail.com). 2008-11-21 13:57:32 +00:00
Sergey Popov
2709806eec Committed a patch by ivan_i:
- Added a command-line option to invoke wesnoth's built-in python
  interpreter in interactive mode.

- Exposed wesnoth's random number generator to python.
2008-11-17 19:20:48 +00:00
Sergey Popov
bd8330c4b0 Fixed a mistake in python_ai.hpp pointed out by ivan_i. 2008-11-14 22:50:55 +00:00
Alexander van Gessel
65b4ed6b09 Revert 2008-10-12T00:33:55Z!ai0867@gmail.com,2008-10-06T10:15:23Z!ai0867@gmail.com.
This removes the "consider attack" event. (bug #12375)
2008-10-26 18:39:10 +01:00
Sergey Popov
54fa8f0d94 Made python ais work again. They were broken when they were moved to
data/ai/python from data/ais.
2008-10-26 10:28:17 +00:00
Tomasz Śniatowski
01e504ede6 remove some map.hpp dependencies,
...also separated viewpoint and map_exception classes from map.hpp
into separate headers (no cpp files)
2008-10-17 17:53:08 +01:00
Tomasz Śniatowski
c54a538139 Refactor gamemap::location -- rename to map_location,
...move into separate cpp/hpp pair. The code under src/ was modified
mainly using a global search-and-replace. This change allows reducing
code dependencies and gets rid of inner-class confusion (parts of the
code had to use "location" when referring to gamemap::location, it is
now consistent across the codebase.)
2008-10-15 17:38:51 +01:00
Alexander van Gessel
d0a69634e4 Add (un)consider events to AIs. (bug #12375) 2008-10-12 01:33:55 +01:00
Eric S. Raymond
140b180f33 Emergency fix for bug #12394: Cautious AI.
Revert relevant files to revision 2008-09-16T17:45:50Z!lari.nieminen@iki.fi.  This backs out suokko's
changes to the AI between 2008-09-16 and 2008-09-18. Three bug fixes
by other people also get thrown out.  These are:

mordante's 2008-09-18T19:42:07Z!koraq@xs4all.nl fix for a compiler warning
soliton's 2008-09-16T20:07:54Z!soliton@wesnoth.org fix for a warning.
dragonking's 2008-09-16T18:41:30Z!b.waresiak@gmail.com fix for bug #11916.

I'll try to do more merges forward before we ship, but at least
these changes get the blocker out of the way.

File                    Omitted revs (*= not suokko's)
---------------------	-----------------------------------------------
ai.hpp          	2006-01-08T19:52:44Z!me@jwbjerk.com 
                        2008-09-18T14:30:42Z!paniemin@cc.hut.fi 
                        2008-09-16T19:26:36Z!paniemin@cc.hut.fi 
                        2008-09-16T18:14:54Z!paniemin@cc.hut.fi
ai.cpp          	2006-01-08T05:21:35Z!me@jwbjerk.com 
                        2008-09-17T00:33:01Z!paniemin@cc.hut.fi 
                        2008-09-16T20:00:03Z!paniemin@cc.hut.fi 
                        2008-09-16T19:26:36Z!paniemin@cc.hut.fi 
                        2008-09-16T18:14:54Z!paniemin@cc.hut.fi
ai_attack.cpp    	2006-01-08T19:57:59Z!me@jwbjerk.com 
                        2008-09-18T19:42:07Z!koraq@xs4all.nl* 
                        2008-09-18T14:30:42Z!paniemin@cc.hut.fi 
                        2008-09-17T00:33:01Z!paniemin@cc.hut.fi
ai_interface.hpp	2006-01-07T18:11:36Z!n1401e@hotmail.com
ai_move.cpp      	2006-01-08T19:57:59Z!me@jwbjerk.com 
                        2008-09-18T14:30:42Z!paniemin@cc.hut.fi 
                        2008-09-17T10:01:20Z!paniemin@cc.hut.fi 
                        2008-09-17T00:33:01Z!paniemin@cc.hut.fi 
                        2008-09-16T20:00:03Z!paniemin@cc.hut.fi 
                        2008-09-16T18:14:54Z!paniemin@cc.hut.fi
ai_python.cpp   	2006-01-08T05:21:35Z!me@jwbjerk.com 
                        2008-09-13T21:59:45Z!paniemin@cc.hut.fi
ai_village.cpp  	2006-01-08T05:21:35Z!me@jwbjerk.com 
                        2008-09-17T00:33:01Z!paniemin@cc.hut.fi 
                        2008-09-16T18:14:54Z!paniemin@cc.hut.fi
formula_ai.hpp  	2006-01-07T18:11:36Z!n1401e@hotmail.com
formula_ai.cpp  	2006-01-07T19:31:27Z!crazy-ivanovic@gmx.net* 
                        2008-09-16T19:26:36Z!paniemin@cc.hut.fi 
                        2008-09-16T18:41:30Z!b.waresiak@gmail.com*
2008-10-04 21:07:05 +00:00
Pauli Nieminen
0626d88862 [[AI tuning]]
* Improved default the attack selection of default AI

* Improved movement target selection

* Allowed leader to retreat from dangerous location

* Tried to teach AI to understand poison and leadership in attack
  selection but result wasn't 100% success

* Fixed some minor bugs found from AI
2008-09-18 14:30:42 +00:00
Pauli Nieminen
e8444eee2f Changed unit::underlying_id_ to integer that is incremented...
...everytime new unit is created

- Fixes problems with duplicated unit_map ids
2008-09-13 21:59:45 +00:00
Mark de Wever
d438f80f12 Added a MSVC 9 projectfile and some fixes for that compiler (patch #1093). 2008-08-17 08:07:54 +00:00
Mark de Wever
68bb9dd937 Fix incomplete copyright information as spotted by alink. 2008-07-11 22:24:21 +00:00
Greg Copeland
7aa7c0c290 AI now fetches scripts rather than asking ai_python::python_ai to do it. 2008-07-09 20:29:50 +00:00
Mark de Wever
409fee3819 Initialize all members. 2008-07-07 16:23:46 +00:00
Greg Copeland
64a71d3c20 Removed "wrap" macro...
...as it was far too confusing to properly maintain GIL
lock-strategy. This should be last major round of GIL-lock
optimization and bug fixes. Not every corner case has been tested but
thus far, things look real stable.
2008-07-01 16:30:47 +00:00
Greg Copeland
e97c813ba9 Further refinement and bug fixes to release the GIL on various functions. 2008-06-30 23:25:41 +00:00
Greg Copeland
33adb8ee83 Changed get_variable to use Py_UNBLOCK_THREADS/Py_BLOCK_THREADS...
...more efficiently rather than the multi-release/lock cycle I had in place.
2008-06-30 22:37:40 +00:00
Greg Copeland
cbba09d4e0 Converted more wesnoth module functions to release the GIL.
Added comment to bruteforce_unsafe.py about memoize caveat
and maps which can change during gameplay.
2008-06-30 21:40:20 +00:00
Greg Copeland
da1914665a Removed commented line - no longer needed...
...since confirmation it compiles via gcc 4.3.x series.
2008-06-30 19:31:44 +00:00
Greg Copeland
43c35ecb70 removed extra underscore. 2008-06-30 18:44:38 +00:00
Greg Copeland
6ddeeed687 Now returns boolean value. 2008-06-30 18:42:18 +00:00
Greg Copeland
59a9f5223e This reverts to the original version...
...which does not use Py_RETURN_TRUE or Py_RETURN_FALSE. This means
the function does not return a boolean value. A doxygen todo comment
was added to revisist this at a later time.
2008-06-30 18:36:22 +00:00
Greg Copeland
46a72cf471 Attempt to work around overzealous compiler. 2008-06-30 18:22:11 +00:00
Greg Copeland
9e9960bcb5 Continue to add code that releases the GIL.
Modernized some code to comply with newer (python 2.4+) C-API
interfaces. Some wesnoth functions now return bool values, as
documented, rather than ints. A new version of bruteforce has been
added which shows unsafe AI. This AI runs 2x-14x faster than the stock
bruteforce because of memoize pattern and psyco.  The AI is only
available if unsafe AI execution is enabled (disable option).
2008-06-30 16:22:20 +00:00
Greg Copeland
8d140eed87 Added comment to python_ai::get_available_scripts...
...to reflect new UNSAFE changes.
2008-06-30 13:52:59 +00:00
Greg Copeland
2618cc3d15 get_variable now allows a default value to be passed to the call.
If the key is not found, the default value is returned. set_variable
exception handling has been fixed to return an exception in the
current call frame.

Many wesnoth module functions now release the python GIL when it is
both safe to do so and the function call takes long enough where it
also makes sense. A new global boolean variable, 'restricted' is now
set before the user AI script is invoked. This variable indicates if
it is running inside of a restricted python environment or not. A new
class of unrestricted scripts are now listed. Previously only scripts
which have '#!WPY' at the top are allowed. If only allow safe python
scripts is disabled, scripts which start with #!UNSAFE_WPY are also
shown to users. This allows AI authors to specifically target either a
restricted or unrestricted environment. New "system" class attributes
are exposed in the restricted environment. These include; '__call__',
'__copy__', '__deepcopy__', '__doc__', '__name__', '__repr__' and
'__str__', in addition to the old __init__ method.
2008-06-30 13:44:59 +00:00
Greg Copeland
b17f86b9cd Fixed wrapper_set_variable exception handling. When a object
could not be marshalled, an exception was throw but not indicated
by the return value. This confused the exception stack causing
the stack to unwind - ignoring the existing stack frame. This
essentially prevented the exception from being caught unless
wrapped in double try/except blocks.
2008-06-29 19:34:01 +00:00
Mark de Wever
74481433fd Update doxygen comment style. 2008-06-23 19:07:30 +00:00
Greg Copeland
6b4e207e37 The safe execution of python AIs can now be enabled/disabled...
...from the advanced preferences menu. By default, all python AIs are
executed under safe.py's full control.
2008-06-19 21:41:26 +00:00
Tomasz Śniatowski
cabba4ce23 Refactor gamemap::on_board() -- remove flag parameter,
...split into gamemap::on_board_with_border().
2008-06-14 12:32:53 +01:00
Elias Pschernig
0025ec1d0f If the python AI can't find the wesnoth install,
...fall back to the current directory.
2008-05-14 16:30:16 +00:00
Mark de Wever
7acbc98933 Fix some compiler warnings about unused variables. 2008-05-09 16:25:26 +00:00
Elias Pschernig
ff1229fadc Pierre Bourdon (delroth) added gold_per_village and is_border to the Python AI. 2008-04-30 16:47:15 +00:00
Elias Pschernig
cf449290cb Python's stderr is redirected to a file pyerr.txt...
...made the python script execute even if pyerr.txt cannot be written to.
2008-04-28 14:53:26 +00:00
Jörg Hinrichs
7e491a85c4 Cleaning up the unit_type stuff, to provide a much better encapsulation:
- get rid of redundant functionality

- make the unit_type_data interface more easily accessible

- reduce the public interface of unit_type_data

- rename unit_type_factory to unit_type_map_wrapper

- add a whole lot of "const"
2008-04-01 21:51:29 +00:00
Elias Pschernig
96f01a0cea Made the python AI compile again after the unit_type_data::instance() change,
...and also added the wesnoth.log() function to the Python AI which I
still had uncommitted in my local copy for some reason.
2008-03-30 15:39:05 +00:00
Eric S. Raymond
03a5505e4e Eliminate wesconfig.h includes where they are no longer needed.
Fix a minor Windows porting bug due to a typo (WIN32 -> _WIN32).

Make game_config.o explicitly dependent on the verion stamp file in scons.
2008-03-26 10:41:50 +00:00
Eric S. Raymond
d648270ebb Re-introduce wesconfig.h include to some files...
...where it will be handy for the scons build.
2008-03-24 13:43:45 +00:00
Bruno Wolff III
e8a45d8e93 Semantic change.
I silenced a gcc 4.3 warning by adding parens around a shift. Based on what
I see in the code it looks like the parens really were needed and that
previously it was doing the wrong thing.
2008-03-19 16:45:50 +00:00
Eric S. Raymond
f6e4419d2f unit::underlying_description_ -> unit::underlying_id_ 2008-03-12 20:07:36 +00:00
Mark de Wever
001af46e6e Updated all headers to 2008. 2008-02-16 08:47:16 +00:00
Ali El Gariani
3588d69fb5 Small optimization of the python wrapper for unit_type.attacks()
But we still don't cache it. Seems safe to do, will try after tagging.
2008-02-11 09:26:19 +00:00