Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#2256 closed defect (fixed)

PATCH] Need to improve the AI handling of bartering

Reported by: mimo Owned by: wraitii
Priority: Nice to Have Milestone: Alpha 16
Component: UI & Simulation Keywords: patch
Cc: wraitii Patch:

Description

When playing with several AIs, bartering quite often lead to ridiculous exchange rates where we can buy several hundreds wood, stone or metal with 100 food. Looking at the code in ai/aegis/headquarters.js it seems that the AI try to barter when it needs a resource, whatever the resource and whatever the exchange rate are.

As food is illimited, the AI should refrain to acquire food with bartering, but rather try to construct new farms when needed.

Then, when bartering, it should check the exchange rate, and not barter if this exchange rate is really too poor.

In addition, for higher AI levels, the AI could do preventive bartering selling its food excess when the rate is good (both to constitute stocks of resources and to bother its opponents by making food bartering less profitable for them).

Attachments (1)

aibarter.diff (9.5 KB ) - added by mimo 10 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by historic_bruno, 10 years ago

Cc: wraitii added

comment:2 by wraitii, 10 years ago

Interesting input. I think I haven't really rewrote bartering for the new Aegis while I changed a ton of other stuffs, so incoherent behavior is not too surprising. Usually it's mostly done to overcome the AI bad resource planning.

comment:3 by wraitii, 10 years ago

Milestone: BacklogAlpha 16

Moving to A16 or I'll completely forget about this.

comment:4 by mimo, 10 years ago

Keywords: patch review added
Summary: Need to improve the AI handling of barteringPATCH] Need to improve the AI handling of bartering

Here is a patch for it.

comment:5 by leper, 10 years ago

headquarters.js at line 781 needs braces around the if (as the else if doesn't do what the indentation claims that it does).

comment:6 by mimo, 10 years ago

Thanks, new version updated

by mimo, 10 years ago

Attachment: aibarter.diff added

comment:7 by wraitii, 10 years ago

Thanks for the patch mimo… I've given it a look and it seems good, but I fear your algorithm may be too clever (it assumes a human player and not the current AI). I'll use all your changes but write my own new "TryBartering" function to be cleverer. Might switch to this when the resource collection is improved.

comment:8 by wraitii, 10 years ago

Owner: set to wraitii
Resolution: fixed
Status: newclosed

In 14582:

Various improvements to AI's early game. Simplify some code and improve on other. Add a few different strategies (Rush/normal/boom, quite basic for now, refs #2344).
Aegis should mostly respect tech limitations so I'll ref #1964.
I'm going to go with #2364 is fixed, the AI should be more efficient in early-game, and late-game is a known problem.
Fixes #2274 and fixes #2379.
Refs #2372 as it should fix several of those warnings for AIs.
Fixes #2256 with a new bartering system, in parts taken from mimo's patch.

comment:9 by sanderd17, 8 years ago

Keywords: review removed
Note: See TracTickets for help on using tickets.