Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artificial Stupidity--changes to AI, possibly improvements #358

Merged
merged 34 commits into from Mar 3, 2013

Conversation

hmaon
Copy link
Contributor

@hmaon hmaon commented Mar 1, 2013

The code for taking cover now evaluates tiles based on multiple factors with different weights assigned to different variables; probably the most important is the amount of soldiers which can see an alien at the given tile (see surveyXComThreatToTile() in TileEngine.cpp). The AI will also try not to stand in fire, smoke, directly next to soldiers, or next to windows. It should also prefer to stand somewhat close to other aliens but not close enough to make a really tempting grenade target.

The AI also tries to keep its state around for multiple actions for a bit more continuity. This was part of an effort to make reapers stop being bad and might be unnecessary.

There's a change to validMeleeRange() which was done to allow reapers to attack targets properly. When looking for a spot from which to bite humans, the could would test the attack in all directions. After approaching the target however, the reaper would face the target and the code would check the attack only in that direction. Sometimes it would fail. This change only made it so the code checks in all directions when it comes time to actually attack. A closer look at the code is needed, I guess.

There is still a problem with melee attacks between units at different heights, especially on mountain hills!

In a final effort to make reapers less bad, I gave all melee units more actions. They should be scary and to be effectively frightening they need to be able to spend all their TUs on attacking when possible. There's no point in preserving TUs for reaction fire in the case of melee units, after all.

There is also an AI option, "sneakyAI," which causes the pahtfinding code to avoid visible tiles. Turn it on if you want the ailens to cheat like crazy, I guess. Note that it doesn't work well for 2x2 units yet.

I added a change to the pathfinding code so that aliens can share the locations of X-Com soldiers (over their space-walkie-talkies) for purposes of path planning. See method SavedBattleGame::eyesOnTarget(), it's handy.

Aliens will also now turn to face the nearest insolent X-Com upstart at the end of their last hide action. If they actually hid well and nobody's visible from their hiding spot, they'll use pathfinding to face in the direction of their aggro target's likely approach.

In short, this is a lot of stuff for one pull request.

Conflicts:
	src/Battlescape/Pathfinding.cpp
Conflicts:
	src/Battlescape/UnitWalkBState.cpp
	src/Engine/Options.cpp
	src/OpenXcom.2010.vcxproj
sectoids are scurrying well

Conflicts:
	src/Savegame/BattleUnit.cpp
tile-scoring based on LOS to soldiers works now, apparently
BattleUnit badly needs a copy constructor
added flags to BattleUnit to try to add some continuity to AI actions
probably more?

Conflicts:
	src/Savegame/BattleUnit.cpp
some clean-up in AggroBAIState
mean soldier distance calculated in survey function
XXX dynamic_cast to AggroBAIState in handleAI() does not work, investigate
copy constructor written for BattleUnit for proper operation of survey...()
total TU cost of calculated path is available from Pathfinding now

Conflicts:
	src/Savegame/BattleUnit.cpp
changed the valid melee range check to not consider direction when a 2x2 unit
is actually in range to attack, just as it ignores direction when looking for a
position to run to for an attack
actually consider distance from action target to aggrotarget, at least a little
bit, duh
things seem to be running fairly well
aliens know about all soldiers known to any alien when pathfinding; they use
their space-walkie-talkies
@Warboy1982
Copy link
Collaborator

but did you fix reapers?

@hmaon
Copy link
Contributor Author

hmaon commented Mar 1, 2013

Don't forget to neuter and spay your reapers!

I did get them to successfully attack in all directions in the x,y plane. Their problems with z need a look from someone who understands the voxel hit stuff better.

Warboy1982 added a commit that referenced this pull request Mar 3, 2013
Artificial Stupidity--changes to AI, possibly improvements

what could possibly go wrong?
@Warboy1982 Warboy1982 merged commit 30e231b into OpenXcom:master Mar 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants