vaendryl / Sunrider

source code of the visual novel 'Sunrider'
http://sunrider-vn.com/
41 stars 21 forks source link

rewrite AI #58

Open vaendryl opened 9 years ago

vaendryl commented 9 years ago

goals:

DoumanAsh commented 9 years ago

As addition it maybe nice to make AI to analyze condition of player units. If it see some weak unit then attack it. Maybe for ryders only(ignoring hate system)? Like "oh hell some noob with low hp, i gonna freaking kill it !" Well it may make a game a little harder if player will not keep all units healed up then enemy could gang rape unit with low hp :D

vaendryl commented 9 years ago

actually, AI has always done that! there's specific code that makes any enemy units immediately fire their weapon (ignoring hate) when it detects the expected damage is greater than their current HP value, and it's always been like that :D

DoumanAsh commented 9 years ago

Oh... i see. My bad then

BlueOrange commented 9 years ago

consider moving towards a different hex before firing a weapon

Gave this a shot - see Pull request.

DoumanAsh commented 9 years ago

It seems possible to break AI like that: http://i64.fastpic.ru/big/2014/1008/8d/5dbca3e012dc2a4281d5fceedba2288d.png

I guess you maybe aware but just in case. At this exact position AI does nothing at all. Just standing while there is someone in range of 2 hexes It seems always attempts to move somewhere while in this state but it cannot. Also it seems that estimation of damage doesn't work for Sunrider and Black Jack in that case. It is zero for both of them

p.s. it is test battle though p.s.s. there may be a problem with priority calculation:

priority = int(estimation * (1 + (pship.hate/100.0)**1.3/10))

http://i66.fastpic.ru/big/2014/1008/77/d2eba4b5942ffa6290858e551ce25077.png

p.s.s.s. actually next formula just gives negative value so if AI thinks that target is too heavy guarded then it's sad:

estimation = (weapon.damage-pship.armor_2)_weapon.shot_count*accuracy / 100.0

http://i67.fastpic.ru/big/2014/1008/c5/eb81b10dc68e5be91e1f5be74dde4bc5.png

i guess it is intended but it looks kinda strange when AI is just standing :)

vaendryl commented 9 years ago

well, there are 2 things at play: 1) if the AI can't do any damage because it can only use assault and assault does jack squat what s hould it do? just try and do 8 damage and be happy with that? yes, in this case it should move in for melee but that hasn't been coded (very well) yet...

2) this is something you just made me realise: when calculating the defensive appeal of a spot it also counts its own defences. this means if it's the only unit there and it supplies flak and or shielding it will not want to leave its own shielding/flak cover. this is bad.

DoumanAsh commented 9 years ago

My main concern that with current calculations you can break AI... it stops do anything at all until player units will move or it will be attacked... That's need to be re-worked. I also thought about making some sorta personalities for different unit types. For example raiders should be more aggressive while big ships are more defensive But that's for future, the main issue now is to prevent this freezing somehow.

So currently: Nothing to attack -> attempt to look for better spot -> nowhere to run? It's dead end right now, i wonder why move toward None didn't cause exceptions but it's not good anyway. I'm thinking about something like desperate attack or running away for hopeless situations... it's more logical...

Also i don't really think it is good that AI sees everything at the start but i guess they have very advanced intel :D

vaendryl commented 9 years ago

yeah, it's not perfect yet. I don't think it ever will be but I do plan on continuing to work on it down the line.

DoumanAsh commented 9 years ago

After some looking into code i came to some new ideas: 1) Start to use unit's morale(currently it's being unused) 2) Morale should be raised with each killed enemy unit 3) High morale(>200) gives 'inspired' buff. It raises all stats at small amount. 4) Add state 'desperate'. Unit fall into such state if morale is low and it can do nothing. In desperate state it ignores own safety. 5) Add state 'give up'. Unit will stop attempts to attack and ran away to the end of map to exit battle. Happens with low hp and morale <= -100. For non-lead ships only

I were doing some digging into code and that's what is came to me. I'm not sure how exactly you're going to re-write AI(and how you want to see it), so i just leave for now these ideas here.