SFTtech / SFTtech/openage

Grouping resource collection to save CPU

Open
#692 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

to-discuss
Dominant language
Python
Stars
14.4k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

In the original game, when a lot of workers all work at the same resource tile they make frequent collection calls (C)
time-------->
x---C1--C2---x---C1--C2---x---C1--C2---x

C1 stands for "call of worker 1", likewise C2, traits are frames, x is the nth frame

When the resource collection is off-screen (i.e. the player doesn't watch), we could "group" resource collection calls from miners, lumberjacks and others in a single one, to save CPU, so that, say every nth frame, the resource tile value is resource -= (number of workers) * (resource taken by each worker). As a worker is full, the resource (and the rate) diminishes by a worker until he comes back to work.

Something like:
time-------->
B{1, 2}----------B{1, 2}----------B{1, 2}---G1------B{2}---R1------B{1, 2}

  • B{1, 2} is "big call {worker 1, worker 2}" (B is at frame nth),
  • G1 is when "worker 1 goes",
  • B{2} is big call with worker 2 only,
  • R1 is when "returns 1"

The resources taken by each worker would be updated syncronously in the same nth frame, with a delay to take into account the time workers actually began working at the tile (so they're not full all at the same time - wouldn't be faithful of the original game)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name any files, tests, or entry points. Start by locating the worker and resource-collection systems, then measure off-screen collection CPU cost before deciding whether grouped calls preserve worker timing and resource depletion. Done should include an implemented approach with evidence that behavior remains faithful and CPU usage improves.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
game-dev, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.