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

AI Won't Build Cities Right by Cities Belonging to Other AIs #119

Merged
merged 7 commits into from Mar 14, 2022

Conversation

QuintillusCFC
Copy link
Member

@QuintillusCFC QuintillusCFC commented Feb 18, 2022

Teach the AI not to build cities where other AIs have already built cities. If a settler is heading towards a destination, and that tile or a neighboring tile has a city, then it will seek a new destination instead. This new destination will take into account its current location, i.e. it will prefer locations closer to it rather than walking back across the empire, if a location nearby is available.

This branch adds two new AI players (for a total of 3).

Base automatically changed from BFSPathing to Development February 22, 2022 05:09
…ities. If a settler is heading towards a destination, and that tile or a neighboring tile has a city, then it will seek a new destination instead. This new destination will take into account its current location, i.e. it will prefer locations closer to it rather than walking back across the empire, if a location nearby is available.
…om here, but now it's in its own component.

Also add a fix in PlayerAI so it doesn't crash if an explorer AI has nowhere to move.  Not sure why this happens yet, and it's rare, but the new print statement (and ability to set a breakpoint) ought to help figure it out.
Later on we'll have to consider when a path is blocked, but for now this avoids a possible null situation.
@QuintillusCFC QuintillusCFC marked this pull request as ready for review February 22, 2022 20:45
@QuintillusCFC QuintillusCFC linked an issue Feb 23, 2022 that may be closed by this pull request
Copy link
Member Author

@QuintillusCFC QuintillusCFC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the main task, it looks okay, but it's going to have conflicts with Flintlock's changes, for example in PlayerAI.cs. That isn't all bad, some of the conflicts like the unit movement ones will be better afterwards. But I'm not going to try to rebase it right now. Hopefully it'll be merged tomorrow.

@QuintillusCFC
Copy link
Member Author

Tested things out with the latest changes. This change appears to be working as expected. I did notice that with the latest architectural changes, the AI isn't sending out galleys anymore - which goes back to what I mentioned in #148 . But that's not related to the settler changes here. It was actually kind of fun watching the AI duke it out with animations, the Dutch and Greeks had a big border war that went back and forth as they randomly attacked each other.

@QuintillusCFC QuintillusCFC merged commit 316d521 into Development Mar 14, 2022
@QuintillusCFC QuintillusCFC deleted the AIRespectsOtherAICities branch March 14, 2022 06:57
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.

With Multiple AI, They Shouldn't Settle Cities on the Same Tiles
1 participant