widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #02539
Re: Fwd: can find any more resources
-
To:
widelands-dev@xxxxxxxxxxxxxxxxxxx
-
From:
Fòram na Gàidhlig <fios@xxxxxxxxxxxxxxxxxxx>
-
Date:
Tue, 29 Jul 2014 11:02:09 +0100
-
In-reply-to:
<CAGCtC0CGxYKgm38MLh6X=77nWg=CQHhBj0OaVqKuEWA49bZYsA@mail.gmail.com>
-
User-agent:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
You could check for the code where production programs (for mines) and
production sites (for other sites) send "Out of Resources" messages. The
production program has a handle on the production site, so both of these
could set a flag in the production site that the AI could check for, or
whenever the player gets a notification message the AI gest a message as
well. This way, the calculation of the check if a site is out of
resources remains with the production and worker programs.
29/07/2014 08:52, sgrìobh Tibor Bamhor:
> SirVer,
>
>
> I tried, spend some time, but all those namespaces, classes, virtual
> functions are too complicated to me. I even failed to identify a place
> (source file) where such function would logically belong.
>
>
> :(
>
>
>
> 2014-07-25 22:58 GMT+02:00 Holger Rapp <HolgerRapp@xxxxxxx
> <mailto:HolgerRapp@xxxxxxx>>:
>
> Hooray \o/ !!!
>
> On 25.07.2014, at 22:23, Tibor Bamhor <tiborb95@xxxxxxxxx
> <mailto:tiborb95@xxxxxxxxx>> wrote:
>
>> I will look at it...and do what I can..
>>
>>
>> 2014-07-25 22:08 GMT+02:00 Holger Rapp <HolgerRapp@xxxxxxx
>> <mailto:HolgerRapp@xxxxxxx>>:
>>
>> Which just strengthens my argument, right? The code there is
>> already copy and pasted and if anything changes you have to
>> change it twice. With your change we need to change it three
>> times.
>>
>> You are a good programmer and can do it. If you do not do it
>> you accrue technical debt that others have to suffer under
>> later on.
>>
>>
>> On 25.07.2014, at 21:52, Tibor Bamhor <tiborb95@xxxxxxxxx
>> <mailto:tiborb95@xxxxxxxxx>> wrote:
>>
>>> similar procedure is used twice in production_program.cc, but
>>> both istances adds some own woodo-magic I dont fully
>>> understand and dont need. So there is no count-resources-only
>>> algorithm used there so for me it is hard to integrate. Maybe
>>> for more skilled programmer it would be doable...
>>>
>>>
>>> 2014-07-25 21:35 GMT+02:00 Holger Rapp <HolgerRapp@xxxxxxx
>>> <mailto:HolgerRapp@xxxxxxx>>:
>>>
>>>
>>> On 25.07.2014, at 21:31, Tibor Bamhor <tiborb95@xxxxxxxxx
>>> <mailto:tiborb95@xxxxxxxxx>> wrote:
>>>
>>>> Hi,
>>>>
>>>> In the meantime I looked into particular cc file (I dont
>>>> remember which one) and in AI I implemented basically
>>>> the same procedure - AI counts current and starting
>>>> amount of resources within radius around a mine and
>>>> calculate the % of exhaustion.
>>>
>>> That is really bad. We already have enough copy & pasted
>>> code in Widelands. Please do not add to this. Pull the
>>> common function into a new common header and use it from
>>> the AI and the old code, please.
>>>
>>>> Seems it works fine.
>>>>
>>>> Also it would be usefull if AI could query&modify ware's
>>>> target quantities. So far there are no ready-for-AI
>>>> functions for this it seems. I am considering to write
>>>> them, but perhaps some more skillfull programmer could
>>>> do the job.
>>>>
>>>> To be consistent with similar functions used by AI, new
>>>> functions could be:
>>>> int send_player_get_ware_target(ware)
>>>> bool send_player_set_ware_target(ware, int)
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 2014-07-25 21:01 GMT+02:00 Holger Rapp
>>>> <HolgerRapp@xxxxxxx <mailto:HolgerRapp@xxxxxxx>>:
>>>>
>>>>
>>>> On 25.07.2014, at 00:04, Tibor Bamhor
>>>> <tiborb95@xxxxxxxxx <mailto:tiborb95@xxxxxxxxx>> wrote:
>>>>
>>>>> well, after some investigation in code it seems
>>>>> that mine is able to mine some % of resources
>>>>> within some radius. Obviously it does not mine
>>>>> resources evenly across fields, so to check one
>>>>> (even central) field is not enough.
>>>>
>>>> You could randomize the field that resources are
>>>> taken from, so that this happens evenly.
>>>>
>>>>>
>>>>> Also it seems that there is no avaiable function to
>>>>> query if mineable resources are mined or not yet.
>>>>> Of course, the mine sends a message ("cant find any
>>>>> more resources") but I am not sure if AI can easily
>>>>> read them. It would help much…
>>>>
>>>> So there must be a method in the mine that does it
>>>> already. You can pull it out and make it available
>>>> for the AI to use. Something like void
>>>> percentage_of_coal_available(field, radius,
>>>> coal_resource_index,
>>>> & total_pieces_of_coal_at_start,
>>>> &total_pieces_of_coal_now);
>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------- Forwarded message ----------
>>>>> From: *Tibor Bamhor* <tiborb95@xxxxxxxxx
>>>>> <mailto:tiborb95@xxxxxxxxx>>
>>>>> Date: 2014-07-24 23:05 GMT+02:00
>>>>> Subject: can find any more resources
>>>>> To: widelands-dev@xxxxxxxxxxxxxxxxxxx
>>>>> <mailto:widelands-dev@xxxxxxxxxxxxxxxxxxx>
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> Please explain to me:
>>>>>
>>>>> I am watching a game (testing AI), there is a mine
>>>>> that shows "can't find any more resources",
>>>>> performance % is 0, it is full of food, yet when I
>>>>> click on it and click DBG it shows coal: 19/20.
>>>>> This is coal mine (the first/lowest level of mine).
>>>>>
>>>>> Now for AI it is quite relevant question - AI test
>>>>> remaining resource on the field and if 0, the mine
>>>>> is to be dismounted. But if mine is not able to
>>>>> mine all resources on a field, then things are
>>>>> getting more complicated.
>>>>>
>>>>> Now I noticed that mines have aihint like
>>>>> mines_percent=30. Does it mean that this mine can
>>>>> mine only 30% of initial amount 20? 30% of 20 is 6
>>>>> so the mine should stuck on remaining resources
>>>>> 14/20, or not?
>>>>>
>>>>> Waiting for explanation, thanks!
>>>>>
>>>>> Tibor
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Mailing list: https://launchpad.net/~widelands-dev
>>>>> Post to : widelands-dev@xxxxxxxxxxxxxxxxxxx
>>>>> <mailto:widelands-dev@xxxxxxxxxxxxxxxxxxx>
>>>>> Unsubscribe : https://launchpad.net/~widelands-dev
>>>>> More help : https://help.launchpad.net/ListHelp
>>>>
>>>>
>>>> _______________________________________________
>>>> Mailing list: https://launchpad.net/~widelands-dev
>>>> Post to : widelands-dev@xxxxxxxxxxxxxxxxxxx
>>>> <mailto:widelands-dev@xxxxxxxxxxxxxxxxxxx>
>>>> Unsubscribe : https://launchpad.net/~widelands-dev
>>>> More help : https://help.launchpad.net/ListHelp
>>>
>>>
>>
>>
>
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~widelands-dev
> Post to : widelands-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~widelands-dev
> More help : https://help.launchpad.net/ListHelp
>
>
>
> No virus found in this message.
> Checked by AVG - www.avg.com <http://www.avg.com>
> Version: 2014.0.4716 / Virus Database: 3986/7937 - Release Date: 07/28/14
>
Follow ups
References