Forage resources

From pjt222/agent-almanac · View interactive version

Forage resources is an AI agent skill from the GitHub repository pjt222/agent-almanac. Apply ant colony optimization and foraging theory to resource search, exploration-exploitation tradeoffs, and distributed discovery. Covers scout deployment, trail reinforcement, diminishing returns detection, and adaptive foraging strategy selection. Use when searching a large solution space where

How to use this skill

Skill file

Forage Resources

Apply foraging theory and ant colony optimization to systematically search for, evaluate, and exploit distributed resources — balancing exploration of unknown territory with exploitation of known yields.

When to Use

Inputs

Procedure

Step 1: Map the Foraging Landscape

Characterize the resource environment to select appropriate foraging strategy.

  1. Identify the resource type and its distribution:
  1. Assess the information landscape:
  1. Determine the cost structure:

Got: A characterized foraging landscape with resource distribution type, information availability, and cost structure. This determines which foraging model to apply.

If fail: If the landscape is completely unknown, start with maximum exploration (all scouts, no exploitation) for a fixed time budget to build an initial map. Switch to the appropriate model once the landscape character becomes clear.

Step 2: Deploy Scouts with Trail Marking

Send exploratory agents into the search space with instructions to mark what they find.

  1. Allocate scout percentage (start with 20-30% of available agents as scouts)
  2. Define scout behavior:
  1. Design the scout pattern:

Got: Scouts deployed across the search space, depositing trail signals proportional to resource quality. The initial map of the landscape begins to emerge from scout reports.

If fail: If scouts find nothing in the initial sweep, either the scout percentage is too low (increase to 50%), the search pattern is wrong (switch from random walk to Levy flight for patchy resources), or the quality assessment is miscalibrated (lower the detection threshold).

Step 3: Establish Trail Reinforcement

Create positive feedback loops that amplify successful paths and let unsuccessful ones fade.

  1. When a forager follows a trail and finds a good resource:
  1. When a forager follows a trail and finds nothing:
  1. Set reinforcement parameters:
Trail Reinforcement Dynamics:
┌─────────────────────────────────────────────────────────────────────┐
│                                                                     │
│  Strong trail ──→ More foragers ──→ If good: reinforce ──→ EXPLOIT │
│       ↑                                                      │      │
│       │                              If bad: no reinforce    │      │
│       │                                     │                │      │
│       │                                     ↓                │      │
│  Decay ←── Weak trail ←── Fewer foragers ←── Trail fades    │      │
│       │                                                      │      │
│       ↓                                                      │      │
│  No trail ──→ Scouts explore ──→ New discovery ──→ New trail ↗      │
│                                                                     │
└─────────────────────────────────────────────────────────────────────┘

Got: A self-regulating feedback loop where good resources attract increasing attention and poor resources are naturally abandoned. The system balances exploitation and exploration through trail dynamics alone.

If fail: If all foragers converge on a single trail (premature convergence), the decay rate is too slow or the saturation cap is too high. Increase decay, lower the cap, or introduce random exploration mandates (e.g., 10% of foragers always ignore trails). If trails fade too fast and nothing gets exploited, reduce the decay rate.

Step 4: Detect Diminishing Returns

Monitor resource yields to know when to shift from exploitation back to exploration.

  1. Track yield per unit effort for each active foraging site:
  1. Implement the marginal value theorem:
  1. Trigger scouting waves when:

Got: The foraging swarm naturally shifts between exploitation phases (concentrated on known-good sites) and exploration phases (scouts dispersed), driven by yield monitoring rather than arbitrary schedules.

If fail: If the swarm stays on depleted sites too long, the marginal value threshold is set too low or the travel cost estimate is too high. Recalibrate by comparing actual yield rates. If the swarm abandons good sites too early, the threshold is too sensitive — add a smoothing window to the yield measurement.

Step 5: Adapt Foraging Strategy to Conditions

Select and switch between foraging strategies based on environmental feedback.

  1. Match strategy to landscape:
  1. Monitor for strategy-environment mismatch:
  1. Implement adaptive switching:

Got: A foraging system that adapts its exploration-exploitation balance to the current environment, maintaining effectiveness as conditions change.

If fail: If strategy adaptation itself becomes unstable (oscillating between exploration and exploitation), add damping: require the mismatch signal to persist for N time units before triggering a strategy shift. If no strategy seems to work, reassess the landscape characterization from Step 1 — the resource distribution may be more complex than initially assumed.

Validation

Pitfalls

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.