-
Notifications
You must be signed in to change notification settings - Fork 2
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
Code(feat) fighter ai #17
base: experimental
Are you sure you want to change the base?
Conversation
Testing swizzles are using the finchtest ship sprite, which has lots of extra orange painted on it. cloaking red if in front default 0 if atSide salmon if notbehind blue if behind but too far away purplish if behind but too close neon green if behind and in range pink is all else
https://youtu.be/tB5eZiIUNOc cloaking red if in front |
Tried something new, and actually kind of got the desired behavior. Not entirely sure why it's working, but it is fairly consistent for the test job. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you going to use these variables?
{ | ||
int weaponsRange = 370; // attacker weapon range this will be passed in eventually | ||
int targetTurretRange = target.GetAICache().TurretRange(); | ||
Point offset = target.Position() - target.Facing().Unit() * weaponsRange; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Point offset = target.Position() - target.Facing().Unit() * weaponsRange; |
Point southEastUnit(southUnit.X() + eastUnit.X(), southUnit.Y() + eastUnit.Y()); | ||
Point southEast = (target.Position() + southEastUnit * targetTurretRange / 1.41); | ||
|
||
Point frontAvoid = (direction.Cross(ship.Facing().Unit()) < 0. ? northWest : northEast); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Point frontAvoid = (direction.Cross(ship.Facing().Unit()) < 0. ? northWest : northEast); |
Point southEast = (target.Position() + southEastUnit * targetTurretRange / 1.41); | ||
|
||
Point frontAvoid = (direction.Cross(ship.Facing().Unit()) < 0. ? northWest : northEast); | ||
Point rearAvoid = (direction.Cross(target.Facing().Unit()) > 0. ? southWest : southEast); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Point rearAvoid = (direction.Cross(target.Facing().Unit()) > 0. ? southWest : southEast); |
Point rearAvoid = (direction.Cross(target.Facing().Unit()) > 0. ? southWest : southEast); | ||
|
||
bool isBehind = direction.Unit().Dot(target.Facing().Unit()) < -.90; | ||
bool justLeft = direction.Unit().Dot(target.Facing().Unit()) < -.8 && direction.Cross(target.Facing().Unit()) > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool justLeft = direction.Unit().Dot(target.Facing().Unit()) < -.8 && direction.Cross(target.Facing().Unit()) > 0; |
|
||
bool isBehind = direction.Unit().Dot(target.Facing().Unit()) < -.90; | ||
bool justLeft = direction.Unit().Dot(target.Facing().Unit()) < -.8 && direction.Cross(target.Facing().Unit()) > 0; | ||
bool justRight = direction.Unit().Dot(target.Facing().Unit()) < -.8 && direction.Cross(target.Facing().Unit()) <= 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool justRight = direction.Unit().Dot(target.Facing().Unit()) < -.8 && direction.Cross(target.Facing().Unit()) <= 0; |
bool justRight = direction.Unit().Dot(target.Facing().Unit()) < -.8 && direction.Cross(target.Facing().Unit()) <= 0; | ||
bool inFront = direction.Unit().Dot(target.Facing().Unit()) > .75; | ||
|
||
bool atSide = (!inFront && !isBehind); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool atSide = (!inFront && !isBehind); |
bool tooClose = direction.Length() < weaponsRange * .9; | ||
bool outerRadius = direction.Length() < weaponsRange * 2; | ||
double reverseSpeed = ship.MaxReverseVelocity(); | ||
double speed = ship.MaxVelocity(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double speed = ship.MaxVelocity(); |
I don't know. Obviously they aren't being used right now, but they were used in VitalChip's original code to achieve more (and better) functionality than I am getting now. I've left them in for now because they might help me get to that better level. That being said, my brain's a bit fuzzy right now, so not sure when I'll be continuing work on this. |
Maybe just comment them out for now? |
Thanks for spotting this! Co-authored-by: Loymdayddaud <[email protected]>
Yes, I was intending to use them. Not sure about all of them or where exactly, but the AI is something that needs a lot of work and complexity. |
Feature: This PR implements the RearAttack pattern for high speed ships as detailed in Revamp
Feature Details
This is an attack pattern aimed primarily at fighters, causing them to preferentially circle the target ship and focus on attacking the rear of it, thus keeping them out of the line of fire of any guns it might have.
It's not actually working yet, although it does build. I've been testing it with a job that spawns a vanguard with 3x the mass (thus slowing down its turning) and a pack of Terns to attack it (which have 3x the normal engines and their hull reduced to 0 mass, thus they move very fast)