Need assistance with Formula AI

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

rende
Posts: 10
Joined: May 26th, 2005, 5:59 am

Re: Need assistance with Formula AI

Post by rende »

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.
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.

barbarianhero
rende
Posts: 10
Joined: May 26th, 2005, 5:59 am

Re: Need assistance with Formula AI

Post by rende »

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.

Code: Select all

            formula="move(me.loc, nearest_loc(nearest_loc(me.loc,map(filter(map.terrain,id='forest'),loc)),unit_moves(me.loc)))"
barbarianhero
ckarai
Posts: 35
Joined: March 26th, 2008, 3:57 pm

Re: Need assistance with Formula AI

Post by ckarai »

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 ()

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]
After changing the desciption to a static one, it worked.
AI
Developer
Posts: 2394
Joined: January 31st, 2008, 8:38 pm

Re: Need assistance with Formula AI

Post by AI »

according to that stack, generating the description failed because of RNG?
User avatar
Iris
Site Administrator
Posts: 6729
Joined: November 14th, 2006, 5:54 pm
Location: Chile
Contact:

Re: Need assistance with Formula AI

Post by Iris »

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 (now available for Wesnoth 1.14.x and 1.15.4+).
ckarai
Posts: 35
Joined: March 26th, 2008, 3:57 pm

Re: Need assistance with Formula AI

Post by ckarai »

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.
Post Reply