Need assistance with Formula AI
Moderator: Forum Moderators
Re: Need assistance with Formula AI
Ah cool, I'll take a look at that tonight. I am passing the FormulaAI move function the loc of the nearest forest, hoping this would only move the undead to the closest hex in range which was along the intended path. I'll have to take a look and see if I can change the move implementation to work this way or if it might be better to do the range checks/pathfinding outside the move.Thanks, it works well, but there's a little bug in the implementation.
The undead just jumps to the nearest location, instead of walking.
I mean the closest forest requires 15 steps, the unit can move 5, but it simply jumps to the nearest forest in 1 turn.
barbarianhero
Re: Need assistance with Formula AI
Ok, so looks like move_unit needs a valid move...Good to know! Here is a revised formula which should make valid moves. The example in SVN HEAD is also updated, only using castle terrain instead of forests.
barbarianhero
Code: Select all
formula="move(me.loc, nearest_loc(nearest_loc(me.loc,map(filter(map.terrain,id='forest'),loc)),unit_moves(me.loc)))"
Re: Need assistance with Formula AI
FormulaAI works well after the modifications. Although generating descriptions to units crashes (I don't know whether it is related to the changes)
Code: Select all
#0 0x08484d06 in simple_rng::random_next () #1 0x08484d92 in simple_rng::get_random () #2 0x084802b7 in unit_race::generate_name () #3 0x083604df in unit::read () #4 0x08364d45 in unit::unit () #5 0x08117632 in get_player_info () #6 0x082cc099 in play_controller::init () #7 0x082d2430 in play_controller::play_controller () #8 0x082df6de in playsingle_controller::playsingle_controller () #9 0x082de348 in playmp_controller::playmp_controller () #10 0x082befdd in playmp_scenario () #11 0x082c2c16 in play_game () #12 0x08256b47 in enter_connect_mode () #13 0x082571f6 in enter_create_mode () #14 0x08257434 in mp::start_server () #15 0x08062c87 in (anonymous namespace)::game_controller::play_multiplayer () #16 0x080696c8 in play_game () #17 0x0806a68e in main ()
After changing the desciption to a static one, it worked.Code: Select all
[unit] x,y=9,7 type="Walking Corpse" generate_description=yes formula="move(me.loc, nearest_loc(nearest_loc(me.loc,map(filter(map.terrain,id='forest'),loc)),unit_moves(me.loc)))" [ai_vars] terrain_type='forest' [/ai_vars] [/unit]
Re: Need assistance with Formula AI
according to that stack, generating the description failed because of RNG?
Re: Need assistance with Formula AI
ckarai: It would be nice if you could recompile Wesnoth with debug information (--enable-debug switch in configure) so that we could get the source code files and lines in that backtrace.
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
Re: Need assistance with Formula AI
I updated the SVN and it works now.
I used the configure scripts instead of scons to build, as scons doesn't have make clean.
The clock of my computer is always late as I run Linux under VMWARE. I can imagine that this confused scons.
I used the configure scripts instead of scons to build, as scons doesn't have make clean.
The clock of my computer is always late as I run Linux under VMWARE. I can imagine that this confused scons.