Complete.Org: Mailing Lists: Archives: freeciv-ai: August 2002:
[freeciv-ai] Re: coreai: process_attacker_want()
Home

[freeciv-ai] Re: coreai: process_attacker_want()

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Per I. Mathisen" <per@xxxxxxxxxxx>, freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: coreai: process_attacker_want()
From: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Date: Mon, 26 Aug 2002 05:54:43 -0700 (PDT)

--- "Per I. Mathisen" <per@xxxxxxxxxxx> wrote:
> This was as far as I got on this horrible function before I decided I
> should start in the other end (ai_military_advisor) and try to unravel
> what it really does and document it before proceeding.
> 
> This code really needs to be simplified and generalised - it is probably
> the most horrible piece of code ever written for freeciv (even worse than
> the dreaded fstk) - and I have some ideas on how to do this.
> 
> Right now the code tries to second-guess the game engine's calculations,
> to figure out what are the good units. This is not only horrible difficult
> to do well, but also unnecessary, as we can use these calculations
> directly through unit_win_chance(att, def)
> 
> Finding best defending unit for pcity:
>       - Find most likely attacker p1
>       - Run unit_type_iterate(id) {
>               - Create virtual unit p with type id
>               - Run a simulated attack with p1 on pcity defended by p2
>               - Calculate want based on win chance and cost to produce
>       }
>       - Select unit with highest win chance as best defender
> 
> Finding best attacking unit against pcity:
>       - Run unit_type_iterate(id) {
>               - Every second time we enter this loop, omit all
>                 units that cannot occupy a city to get a statistically
>                 diverse population of attack units. Maybe do this
>                 to some other parameters too for more diversity.
>               - Create virtual unit p with type id
>               - Run a simulated attack with p on pcity
>               - Calculate want based on win chance amortized over
>                 move_rate / distance / cost to produce
>       }
>       - Select unit with highest win chance as best attacker
> 
> Why unit_win_chance() is not used at all in the AI code is a mystery to
> me. Yeah, it will add some heat to the CPU, but we can aggressively cache
> the results, and the code currently in cvs is also quite nasty (in so many
> ways). It would be nice if someone could have look at win_chance and see
> if could be made less computationally intensive (at cost of less accuracy,
> fine).
> 


Amazingly, this idea has occured to two people before. Shocking, isn't it?
One of them was some nobody named Greg Berkolaiko, a guy who's only on the list
for his bad boy looks ;).

The other guy was me.

Greg, resend your combat odds patch. It looks like Per is finally ready for the
mountain to come to him. Greg's patch is already great as is, IMO.

Aloha,
RK.

The human race has been fascinated by sharks for as long as I can
remember.  Just like the bluebird feeding its young, or the spider
struggling to weave its perfect web, or the buttercup blooming in
spring, the shark reveals to us yet another of the infinite and
wonderful facets of nature, namely the facet that it can bite your head
off.  This causes us humans to feel a certain degree of awe.
-- Dave Barry, "The Wonders of Sharks on TV"

__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com


[Prev in Thread] Current Thread [Next in Thread]