Opened 12 years ago

Closed 11 years ago

Last modified 4 years ago

#1387 closed enhancement (fixed)

[PATCH] Limit gatherers per resource

Reported by: historic_bruno Owned by: wraitii
Priority: Should Have Milestone: Alpha 13
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description

Currently you can order a ridiculous number of units to gather from a single resource. We need to enforce some sensible limits, whether it be farms, trees, or mines. It should be added as a new element to the ResourceSupply component. Units can be tasked to gather normally, but when reaching the target, a check is performed on the number of current gatherers. The "extra" units can move on to a similar nearby resource or go idle (or we can add some kind of queue system where units wait for a slot to open, without constantly using the pathfinder).

Attachments (2)

Gatherers3.patch (4.1 KB ) - added by Maciej Piekarz 11 years ago.
GathererLimits.patch (20.6 KB ) - added by wraitii 11 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 by Maciej Piekarz, 11 years ago

Hey, I thought I could try doing this.

I have a small question though. Is there any way to check what a given entity is doing at the moment? Or at least check, if it's collecting suplies?

EDIT: nvm, found UnitAI.js

Last edited 11 years ago by Maciej Piekarz (previous) (diff)

by Maciej Piekarz, 11 years ago

Attachment: Gatherers3.patch added

comment:2 by Maciej Piekarz, 11 years ago

Attached diff, that allows limiting amount of workers per resource supply.

Tested following scenarios (with limit of 5 workers per field):

  • built 2 fields, sent 6 workers to work in one field. One moved to the 2nd field and worked there
  • built 1 field, sent 6 workers to work there. One worker went back to base and stood there idle

Now, the problem is - resource supply templates won't load, unless max number of workers is specified, so I guess there should be some discussion about these limits per each resource and it should be added to diff.

comment:3 by Maciej Piekarz, 11 years ago

Summary: Limit gatherers per resource[PATCH] Limit gatherers per resource

comment:4 by leper, 11 years ago

Keywords: patch review added

comment:5 by historic_bruno, 11 years ago

Milestone: BacklogAlpha 13

by wraitii, 11 years ago

Attachment: GathererLimits.patch added

comment:6 by wraitii, 11 years ago

Thanks or the patch crezax. It seemed to work (pretty good for a beginner :) ), but I think this behaviour should be handled more by UnitAI than by passively recounting now and then in ResourceSupply. Using you patch as a framework I've uploaded a new one.

Units will try to find a new nearby resource if there is one, and if none, they will return to the nearest dropsite. The information about gatherers is broadcast as a message for AIs (and I have updated qBot and Aegis to use them), and "Display Selection State" has been updated too. I have changed all basic templates to have a minimal number of gatherers, the numbers are basically based on "how many units approximately can go around said resource", feel free to discuss.

I have failed to have it bug (then again it took me a good 3 hours to get it to work. Thank god for the JS debugger), but I'd recommend to try it out anyway.

Two issues remaining: should a notification be sent? Formations also begin by walking towards the resource and then only break if there is not enough space. This could be annoying, particularly for treasures (which currently can only be gathered by 1 unit).

Last edited 11 years ago by wraitii (previous) (diff)

comment:7 by Maciej Piekarz, 11 years ago

Good to know it wasn't that bad wraitii :) BTW, you mentioned JS debugger, when I tried debugging my code, I tried using http://trac.wildfiregames.com/wiki/JavascriptDebugging but I can't see 0ad/source/tools/jsdebugger/ directory in repository. Tried looking for index.html, jsdebugger etc without any luck. Is there something I'm missing, or is that tutorial outdated? I could really use having working JS debugger for future :)

in reply to:  7 comment:8 by zoot, 11 years ago

Replying to crezax:

Good to know it wasn't that bad wraitii :) BTW, you mentioned JS debugger, when I tried debugging my code, I tried using http://trac.wildfiregames.com/wiki/JavascriptDebugging but I can't see 0ad/source/tools/jsdebugger/ directory in repository. Tried looking for index.html, jsdebugger etc without any luck. Is there something I'm missing, or is that tutorial outdated? I could really use having working JS debugger for future :)

Are you using the latest version from SVN/GitHub? It should be in there: https://github.com/0ad/0ad/tree/master/source/tools/jsdebugger

comment:9 by Maciej Piekarz, 11 years ago

ok thanks :) somehow that directory wasn't there when I checked out SVN repository

comment:10 by wraitii, 11 years ago

Owner: set to wraitii
Resolution: fixed
Status: newclosed

In 13277:

Limit the number of gatherer per resource, as described in #1387. Based on work by crezax. Fixes #1387

comment:11 by wraitii, 11 years ago

In 13288:

Improve workers' reactions when they find out that the resource they gathered from is full. Refs #1387

comment:12 by wraitii, 10 years ago

In 14552:

Change the defense system used by Aegis to use more modular armies. This should be faster and easier to extend, though right now it might not be as efficient as before.
Fix a few bugs, including a few bad ones in the economy.
Change the way messages are handled, should be marginally faster in the later game.
Makes gatherers count limit be per-player (refs #1387 and #643).

comment:13 by JoshuaJB, 10 years ago

In 14848:

Revert gather limits to be global instead of per-player. Refs #1387

comment:14 by sanderd17, 8 years ago

Keywords: review removed

comment:15 by Freagarach, 4 years ago

In 24036:

Don't store the gatherers per player.

r14848/rP14848 deprecated the use of storing the gatherers on a per player basis.
This removes it entirely thus saving a few useless calls and operations.

Refs #1387.
Differential Revision: D2755
Reviewed by: @bb.

Note: See TracTickets for help on using tickets.