[Freeciv-Dev] Re: AI danger (Re: Re: A bunch of patches)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
--- Petr Baudis <pasky@xxxxxxxxxxx> wrote:
> > > > Everywhere the code used v * m / dist, it instead calls this function:
> > > >
> > > > int adjust_danger_for_distance(struct unit *punit,
> > > > int danger, int move, int distance)
> > > > {
> > > > int moves = distance / move;
> > > > int attacks = move / distance;
> > > > if (moves)
> > > > return danger / moves;
> > > > if (attacks && !unit_flag(punit, F_ONE_ATTACK))
> > > > return danger * attacks;
> > > > return danger;
> > > > }
> > > >
> >
> > Question on this function. Moves is move_rate?, you have not checked
> whether the unit can even attack(battleship is never a threat to an air
unit), >is this handled elsewhere?
> move is probably move_rate (didn't look at the usage of the funct, though),
> moves
> is how many moves we have to do, attacks is how many times we can attack.
>
OK, I think move and moves are confusingly named. You are expecting the casual
reader of the code to know what the difference is. I would suggest move_rate,
max_move_rate or current_mv_rate instead of move. I've got nothing for moves.
Attacks, you can either go for a comment or rename it attacks_per_turn.
> > Danger * if unit ignores walls
> > Danger * if unit is immune to zoc
> > etc
> See assess_danger family, especially assess_danger_unit() and
> assess_danger().
>
Yes, but those functions do not impress me. I really do not understand how
the formulas were derived.
> > I suspect this is a very badly bugged piece of code. Petr and Ross will
> > probably agree.
> It looks it works, that's important. It's probably buggy somewhat, but it
> doesn't crash and works reasonably - when we'll decypher how it works, we
> will
> be able to fix it in better way.
>
> PS: My mind is in SNAFU state now, so I'm not sure if I wrote even anything
> meanable now ;).
>
Well, I suspect your comments were not "meanable". They were meanful however ;).
__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
|
|