Latest Posts

Topic: AI patch suggestion

Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-04-30, 20:11

one of problems i see is that when building military buildings AI does not consider mines - military buildings should be pushed as close to hills with mineable fields as possible. Can somebody help with this?
I found this piece of code:

map.find_fields(Area<FCoords>(field.coords, range), nullptr, find_unowned)

This is basically what I want, I just need something proper instead of "find_unowned"
Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-04-30, 21:56

I just commited v. 6964...


Top Quote
SirVer

Joined: 2009-02-19, 14:18
Posts: 1445
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2014-05-01, 09:01

map.find_fields(Area<FCoords>(field.coords, range), nullptr, find_unowned)

find_unowned is a functor of type FindNodeUnowned as defined in src/ai/ai_help_structs.h (which is a terrible name for a file). You need to write your own functor that returns true in accept() when you like a field.


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-05-06, 21:59

Well, still working on my AI, here is a screenshot from todays test:



As you can see the players are able to keep growing for many hours...

I reworked economy, military (expansion, not fighting) but there is still a lot of work :)


Top Quote
SirVer

Joined: 2009-02-19, 14:18
Posts: 1445
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2014-05-07, 06:27

If you made some significant improvements, I suggest merging them into trunk ASAP so that others can benefit from your work. You can continue working, but smaller patches are easier to work with anyways. Just propose your branch for merging when you think it is in a mergable state, then make a new one to continue working in.


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-05-07, 22:33

SirVer wrote:

If you made some significant improvements, I suggest merging them into trunk ASAP so that others can benefit from your work. You can continue working, but smaller patches are easier to work with anyways. Just propose your branch for merging when you think it is in a mergable state, then make a new one to continue working in.

Those changes are quite significant thought I did no changes deep under the hood, I changed only defaultai.cc and defaultai.h.

I reworked scoring of buildings, added some stops/go controls for various "processes", perhaps it slowly gets to mergeable state.

But I have not tested other races then barbarians yet, though algorithm should be race-independent.

But there are still areas that need improvement (mines and so).

And I would be realy thankfull if some independent person could test this before it is even merged. Just keep in mind it is not finished yet..


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-05-14, 21:52

Hi small update after couple of busy days, I would appreciate testing and feedback, it seems that AI works quite fine though a lot of polish and tweaking is possible and will be done...

Today I tested my AI with Dark Forest map, its specific is that it is full of trees and here is a result:




So basically my goals are achieved, and I would like to know if changes are acceptable :)

There is one remaining feature missing yet: The alghoritm is "mines-blind" so new military buildings just ignore presence of mines/underground raw materials. (They are now aware of surface stones though)

Some buildings like rangers, gamekeepers are now controlled by stock level and can be stopped and resumed as needed.
Also new mines are established only when stock level of particular raw material is under the treshold - this is to prevent unneeded growth of some raw material stocks (and futile spending of food and tools for miners)

The branch is avaiable (as mentioned before):

bzr branch lp:~tiborb95/widelands/tiborb-ai

feedback welcomed :)


Top Quote
SirVer

Joined: 2009-02-19, 14:18
Posts: 1445
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2014-05-15, 14:12

Tibor, if you are happy with your changes, feel free to suggest them for merging.


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-05-15, 20:13

Hi, most of all it needs testing and feedback. Moreover I dont consider it as finished (ready for stable release) but I presume further tweaking and changes.

So I will ask for merging. BTW, merging is undoable I believe...


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-05-16, 21:28

Hi, today I modified algorithm for placing new military buildings to recognize nearby mine-able fields. Because previously new military buildings were placed based on amount unowned teritory only, and with this change I want to push military buildings as close to mines as possible.

However I messed commiting to launchpad, my last commits are not shown there, my 'bzr log' shows:

------------------------------------------------------------
revno: 6975
committer: tiborb************
branch nick: tiborb-ai
timestamp: Fri 2014-05-16 22:14:03 +0200
message:
  conflicts resolved (2nd attempt)
------------------------------------------------------------


Please advice how to clean the mess up...
Top Quote