Commit graph

68 commits

Author SHA1 Message Date
Erik Ogenvik
5b282419be Finalize conversion to Python 3. 2018-05-07 11:15:26 +02:00
Erik Ogenvik
97a09ae6b0 Conversion to Python 3 through 2to3. 2018-05-07 11:15:26 +02:00
Erik Ogenvik
701d1a7208 Initial work on porting to Python 3. 2018-05-07 11:15:26 +02:00
Erik Ogenvik
fdaf230281 Handle validity check correctly. 2017-05-28 21:51:04 +02:00
Erik Ogenvik
d8eeb05c3d Revert include optimize for Python files.
CLion wasn't as good at optimizing Python as it was at optimizing C++.

This reverts commit 7aaa9b9ba7.
2017-05-28 16:32:17 +02:00
Erik Ogenvik
7aaa9b9ba7 Optimize includes. 2017-03-19 21:36:52 +01:00
Erik Ogenvik
0a81e9897f Added a concept of goal "validity".
Calling "is_valid" checks whether the goal actually can be fulfilled.
If it can't be, False is returned.
By default all Goals return True unless a "validity" function is supplied
in the constructor.

For now we only use it for checking whether movement goals can be reached.
2016-06-08 22:03:59 +02:00
Erik Ogenvik
ec857b57e5 Handle movement goals not being reachable.
Though perhaps we should have a more general mechanism for querying
goals about their validity?
2016-06-08 21:46:37 +02:00
Erik Ogenvik
374a691735 Allow destination to be set to another entity.
This only works for entities that share the same domain.
It also allows for entities to follow other entities.
2016-04-03 21:25:39 +02:00
Erik Ogenvik
924ba32982 Added extra goals to some goals.
These are goals that can be injected to run when the parent goal
is fulfilled.
2016-03-30 22:34:44 +02:00
Erik Ogenvik
48839bc8e7 Send range on to move_me goal. 2016-03-21 21:50:56 +01:00
Erik Ogenvik
58f3cabb73 Set both location and radius when setting destination. 2016-03-20 22:48:03 +01:00
Erik Ogenvik
fa4eb7bb0b Limit too long distances.
If the character wants to travel too far, we shouldn't try to map the whole
path straight away. Instead we'll cut down on the lenght, and increase the
acceptable radius.
This works since the AI will issue a new destination on its next Tick.
2016-03-19 23:05:13 +01:00
Erik Ogenvik
e76e0fc7ad Skip movement goals that are unreachable.
A goal is considered to be unreachable when all tiles in the awareness area
have been mapped, and no path still could be found.
2016-03-19 23:05:13 +01:00
Erik Ogenvik
c1d0bf48c5 Improved querying of paths. 2016-03-19 23:05:13 +01:00
Erik Ogenvik
7c2ab63fca Dial down logging. 2016-03-19 23:05:13 +01:00
Erik Ogenvik
b683fb3464 Allow for inspection of the path.
Authoring clients can send a Think op, wrapping a Get op with a "path"
attribute to get information about the path. The mind code will then
send back a list of points for the path.
2016-03-19 23:05:13 +01:00
Erik Ogenvik
14354137a7 Hooked up steering to the move_me goal. 2016-03-19 23:05:13 +01:00
Erik Ogenvik
7b0d30680c Setup steering.
The setup is that steering is handled separately from the normal mind
ticks. At a closer interval (0.2 seconds currently) steering will be
evaluated.
2016-03-19 23:05:13 +01:00
Yaroslav Taben
e0e331f08a Changed move_it_outof_me goal to use EntityFilter.
The goal now searches for entities to drop within the
inventory (contains property) of a mind that used
this goal.
2014-09-27 18:30:33 -04:00
Yaroslav Taben
550e6b8db6 Changed accompany goal to use entity filter.
With this change, the goal can still be created focusing on
an entity with specified ID, but it now also supports wider
range of criteria.
2014-08-25 15:08:47 -04:00
Yaroslav Taben
05481fb2e5 Renamed filter to entity_filter in python to avoid a conflict
filter name conflicts with built-in filter method and causes
confusion
2014-08-14 17:09:27 -04:00
Yaroslav Taben
80643d4de6 Changed avoid goal to use Entity Filter. 2014-08-08 21:05:07 -04:00
Yaroslav Taben
c13d6b269d Fixed "search" goal 2014-04-30 13:37:57 -04:00
Erik Ogenvik
873e4c7c1c Fix erratic movement in the "roam" goal. 2013-07-31 00:27:44 +02:00
Erik Ogenvik
38580dcfbd Use better param names. 2013-07-17 23:32:36 +02:00
Erik Ogenvik
313b247213 Added a "move me near" goal.
This goal will move a character close to something, and then keep the
character within a certain distance of this thing.
This is useful when you want the character to get close to something,
but then search for something else within the vicinity.
2013-06-27 21:54:35 +02:00
Erik Ogenvik
43cab79a97 Take into account size of entity when moving.
Else the NPC would always want to walk into even solid objects.
We should of course also add checks for solid and non-solid entities.
2013-06-16 00:12:05 +02:00
Erik Ogenvik
9ca9e64b7a Added roam goal.
This makes the NPC wander aimlessly within a specified series of
location. This is often more suitable than "wander", as that goal will
make the NPC wander over the whole map, which often isn't what you want.
2013-05-21 21:31:44 +02:00
Erik Ogenvik
af6ca21694 Fixed "wander" goal.
The NPC will now wander randomly. However, this isn't completely
natural. The change in direction is too erratic. And the goal should be
expanded to stay within a certain area.
2013-05-19 22:52:30 +02:00
Erik Ogenvik
6832d54c8d Added extra sanity check. 2013-04-20 17:56:55 +02:00
Erik Ogenvik
34f1544b1a Spelling fixes. 2013-04-05 20:56:55 +02:00
Alistair Riddoch
c2cff84e1f Clean up imports removing deprecated support and obsolete modules. 2009-07-01 14:07:28 +01:00
Alistair Riddoch
531e4f512d Update all scripts to use atlas.Oplist 2009-05-21 16:34:27 +01:00
Alistair Riddoch
6679b1b30f Update all Python scripts to import vector and point from physics 2009-05-20 19:34:01 +01:00
Al Riddoch
c71d5ef8a5 2008-09-17 Al Riddoch <alriddoch@googlemail.com>
* rulesets/basic/mind/goals/common/move.py: Add nominal doc strings
	  to some goal classes.
2008-09-17 17:46:35 +00:00
Al Riddoch
e5bee108c9 2008-09-17 Al Riddoch <alriddoch@googlemail.com>
* rulesets/basic/mind/goals/common/common.py,
	  rulesets/basic/mind/goals/common/move.py,
	  rulesets/basic/mind/goals/humanoid/build_home.py,
	  rulesets/basic/mind/goals/humanoid/fire.py,
	  rulesets/basic/mind/goals/humanoid/mason.py,
	  rulesets/basic/mind/goals/humanoid/transaction.py:
	  Clean up the way goals are imported so it makes more sense,
	  and doxygen has an easier time with it.
2008-09-17 17:33:30 +00:00
Al Riddoch
8e9bd398af 2008-01-04 Al Riddoch <alriddoch@googlemail.com>
* rulesets/Python_API.cpp: Remove the server_python flag used to
	  allow scripts to run unmodified on the obsolete python prototype.

	* rulesets/basic/mind/NPCMind.py,
	  rulesets/basic/mind/goals/animal/herd.py,
	  rulesets/basic/mind/goals/common/common.py,
	  rulesets/basic/mind/goals/common/move.py,
	  rulesets/mason/world/objects/buildings/House.py: Remove support
	  for running these scripts on the obsolete python prototype.
2008-01-04 00:45:39 +00:00
Al Riddoch
127bfd5d92 2007-04-24 Al Riddoch <alriddoch@zepler.org>
* rulesets/basic/mind/goals/common/misc_goal.py,
	  rulesets/basic/mind/goals/common/move.py,
	  rulesets/basic/mind/goals/humanoid/construction.py,
	  rulesets/mason/define_world.py: Fix most goals so they no longer
	  require a reference to the owning mind object on initialisation,
	  meaning they are now more stateless.
2007-04-23 23:42:38 +00:00
Al Riddoch
d43e7f2bb4 2007-04-22 Al Riddoch <alriddoch@zepler.org>
* rulesets/basic/mind/goals/common/move.py: Expire the accompany goal
	  used by mercenaries when the person they are working for no longer
	  exists.
2007-04-22 21:54:00 +00:00
Al Riddoch
05c29a2070 2007-04-08 Al Riddoch <alriddoch@zepler.org>
* rulesets/basic/mind/goals/common/misc_goal.py,
	  rulesets/basic/mind/goals/common/move.py,
	  rulesets/basic/mind/goals/humanoid/construction.py:
	  Re-write goals relating to gathering things off the ground
	  to be clearer, more efficient, and to deal with lists of types.

	* rulesets/mason/define_world.py: Use warrior test to test gathering
	  lists of types.
2007-04-08 22:05:39 +00:00
Al Riddoch
23090634f6 2007-03-08 Al Riddoch <alriddoch@zepler.org>
* Makefile.am: Remove GNU echo isms.

	* rulesets/basic/mind/goals/common/move.py: Modify the pick_up_focus()
	  goal so it clears the focus. gather() now gathers things
	  indefinitely.

	* rulesets/mason/define_world.py: Add a test script for warriors to
	  gather stuff.
2007-03-08 14:14:00 +00:00
Al Riddoch
638dc66da0 2006-08-30 Al Riddoch <alriddoch@zepler.org>
* rulesets/Python_API.cpp: Change the entity_new constructor used
	  by define world scripts so that it takes an optional "pos" argument
	  rather than the long obsolete "xyz".

	* rulesets/mason/define_world.py, rulesets/werewolf/define_world.py:
	  Modify the most relevant define_world scripts to use the changed API.

	* rulesets/basic/mind/goals/common/move.py: Remove a long obsolete
	  commented out debug line.
2006-08-29 23:54:08 +00:00
Al Riddoch
6453493c6f 2006-07-11 Al Riddoch <alriddoch@zepler.org>
* rulesets/BaseMind.cpp, rulesets/MemMap.cpp, rulesets/MemMap.h:
	  Remove commented out lookId code. Re-write findByLocation to
	  require a type as well, and use a more efficient search to find
	  the entities requested.

	* rulesets/Py_Map.cpp: Re-write find_by_location wrapper to handle
	  the extra type argument.

	* rulesets/basic/mind/Memory.py: Re-write recall_place so that
	  type and radius are now required, and make sure all types listed
	  are checked for.

	* rulesets/basic/mind/goals/common/move.py: Check if recall_place
	  has returned anything at all.
2006-07-11 17:42:22 +00:00
Al Riddoch
02e151cb4e 2006-06-05 Al Riddoch <alriddoch@zepler.org>
* rulesets/basic/mind/goals/common/move.py: Make deer run further
	  when they are scared, thus making their movement smoother.
2006-06-05 14:50:55 +00:00
Al Riddoch
9600aabab5 2006-01-21 Al Riddoch <alriddoch@zepler.org>
* client/Py_CreatorClient.cpp, rulesets/Py_Map.cpp,
	  rulesets/Py_Operation.cpp, rulesets/Py_Oplist.cpp,
	  rulesets/Py_Point3D.cpp, rulesets/Py_Vector3D.cpp,
	  rulesets/Py_WorldTime.cpp, rulesets/Python_API.cpp:
	  Convert functions that take a single argument to use METH_O
	  and avoid calling PyArg_ParseTuple.

	* rulesets/Py_Point3D.cpp, rulesets/Py_Vector3D.cpp,
	  rulesets/basic/mind/goals/common/move.py: Rename
	  unit_vector_to_another_vector to unit_vector_to.
2006-01-22 02:13:52 +00:00
Al Riddoch
e2b83394b0 2005-12-13 Al Riddoch <alriddoch@zepler.org>
* common/const.h: Add a second const for the non-squared default
	  box size for visibility calculations.

	* modules/Location.cpp: Initialise cached box size members with
	  defaults from consts.

	* rulesets/basic/mind/goals/common/move.py: Don't remove focus
	  knowledge about item just because it has been picked up. This
	  fixes eating acorns.

	* rulesets/basic/mind/goals/common/misc_goal.py: Remove focus knowledge
	  when something is eaten.
2005-12-13 01:38:08 +00:00
Al Riddoch
77c19a4395 2005-12-05 Al Riddoch <alriddoch@zepler.org>
* rulesets/Py_BBox.cpp, rulesets/Py_Optime.cpp,
	  rulesets/Py_Statistics.cpp, rulesets/Py_Thing.cpp: Ensure that
	  setattr returns an exception if the attribute is not a valid one.

	* rulesets/Py_Map.cpp, rulesets/Py_Point3D.cpp,
	  rulesets/Py_Quaternion.cpp, rulesets/Py_World.cpp,
	  rulesets/Py_WorldTime.cpp: Remove setattr, as no attributes can
	  be set on this type.

	* rulesets/Py_Mind.cpp, rulesets/Py_Oplist.cpp,
	  rulesets/Py_Vector3D.cpp: Clean up type structure.

	* rulesets/basic/mind/goals/common/move.py: Remove attempt
	  to set "rotation" attribute on location, as its obsolete
	  and pointless.
2005-12-05 04:01:11 +00:00
Al Riddoch
a02f9e5f55 2005-07-07 Al Riddoch <alriddoch@zepler.org>
* rulesets/basic/mind/goals/common/common.py,
	  rulesets/basic/mind/goals/common/misc_goal.py,
	  rulesets/basic/mind/goals/common/move.py,
	  rulesets/basic/mind/goals/humanoid/build_home.py,
	  rulesets/basic/world/probability.py,
	  rulesets/basic/world/objects/plants/Tree.py,
	  rulesets/mason/define_world.py, rulesets/mason/mind/SkelMind.py,
	  rulesets/mason/world/objects/Weather.py,
	  rulesets/mason/world/objects/animals/Deer.py,
	  rulesets/mason/world/objects/animals/Pig.py,
	  rulesets/mason/world/objects/outdoor/Gravestone.py,
	  rulesets/mason/world/objects/plants/seeds/Seed.py,
	  rulesets/mason/world/objects/undead/Skeleton.py,
	  rulesets/werewolf/define_world.py:
	  Switch to importing random and fall back to deprecated whrandom
	  on older python versions.
2005-07-07 01:04:40 +00:00
Al Riddoch
a05e7ff8d3 2005-07-04 Al Riddoch <alriddoch@zepler.org>
* rulesets/basic/mind/goals/common/misc_goal.py: More changes
	  to make goals work with new spot_something.

	* rulesets/basic/mind/goals/common/move.py: Modify hunt pursuit goal
	  to fit with spot_something.
2005-07-04 00:44:57 +00:00