home / skills / bdambrosio / cognitive_workbench / mc-map-query

This skill queries the persistent spatial map to aid reasoning, planning, and safe exploration by returning relevant cells from memory.

npx playbooks add skill bdambrosio/cognitive_workbench --skill mc-map-query

Review the files below or copy the command above to add this skill to your agents.

Files (2)
Skill.md
5.0 KB
---
name: mc-map-query
type: python
description: "Queries the persistent spatial map representing everything the agent currently knows about the environment (from past and present observations). Useful for reasoning, explanation, and planning."
situational: false
---

# Minecraft Map Query Tool

Queries cell-based SpatialMap for spatial planning. Supports multiple query types for coverage analysis, movement planning, safety assessment, and resource discovery.

## Purpose

Query spatial memory for strategic information. Returns cells matching criteria for movement planning, hazard avoidance, exploration targeting, and resource gathering.

## Input

Common parameters:
- `query`: Query type (see list below)
- `x`, `z`: Center coordinates for radius-based queries
- `y`: Y coordinate (optional, used for query-time computations)
- `radius`: Search radius (default: 10)

Query-specific parameters:
- `threshold`: Confidence threshold for `cells-low-confidence` (default: 0.5)
- `max_age`: Maximum age in seconds for `cells-stale` (default: 300)
- `max_delta_y`: Max Y change for `cells-reachable` (default: 1)
- `min_dist`: Minimum distance for `cells-observed-from-distance`
- `resource_type`: Resource type for `cells-with-resource`
  - Generic types: `'wood'`, `'ore'`, `'food_source'`, `'stone'`, `'dirt'`, `'sand'` (matches all instances)
  - Instance-specific: `'minecraft:oak_log'`, `'oak_log'`, `'minecraft:coal_ore'`, etc. (exact match)
  - `minecraft:` prefix optional (automatically normalized)
- `predicate`: Filter for `cells-nearest` (walkable, safe, hazard, resource)

**Important**: Some queries now support query-time computation when `y` (and optionally `x`, `z`) are provided:
- `cells-blocked`: Computes blocking relative to position (requires `x`, `z`, `y`)
- `cells-reachable`: Computes delta_y and blocking relative to current position (uses `y` if provided)
- `cells-requiring-climb`: Computes step_up relative to Y coordinate (requires `y`)
- `cells-with-drop-risk`: Computes drop risk relative to Y coordinate (uses `y` if provided)

## Query Types

Coverage / Observability:
- `stats`: Map statistics (no coords required)
- `cells-unobserved`: Unmapped cells within radius
- `cells-low-confidence`: Cells with confidence below threshold
- `frontier-cells`: Observed cells adjacent to unobserved
- `cells-observed-from-distance`: Cells observed from far away
- `cells-stale`: Cells with old observations

Reachability / Locomotion:
- `cells-reachable`: Walkable cells within delta_y constraint (uses `y` for query-time delta_y and blocking)
- `cells-blocked`: Blocked cells relative to position (requires `x`, `z`, `y`) or unwalkable cells if no position
- `cells-requiring-climb`: Cells needing upward movement (requires `y` for query-time step_up computation)
- `cells-with-drop-risk`: Cells involving unsafe descent (uses `y` for query-time drop risk computation)

**Note**: "blocked", "step_up", and "step_down" are now query-time attributes computed relative to current position, not static cell properties. Provide `x`, `z`, `y` coordinates for accurate query-time computation.

Safety / Survival:
- `cells-safe-to-stand`: Low hazard, walkable cells
- `cells-high-hazard`: Cells with hazards (lava, fire, etc.)
- `cells-escape-nodes`: Good retreat positions

Resources:
- `cells-with-resource`: Cells with specified resource type
  - Accepts generic types (`'wood'`, `'ore'`, `'food_source'`, `'stone'`, `'dirt'`, `'sand'`) or instance-specific (`'minecraft:oak_log'`, `'coal_ore'`, etc.)
  - Generic queries match all instances (e.g., `'wood'` matches all log/plank types)
- `cells-with-item-entities`: Cells with visible dropped-item entities (ephemeral resources)
- `cells-water-source`: Cells with water

Multi-Objective:
- `cells-candidate-waypoints`: Safe, reachable waypoint candidates
- `cells-nearest`: Nearest cells matching predicate
- `cells-worth-revisit`: Low confidence or inferred cells

Note: Legacy Collection-based queries (`location`, `property`, `waypoint`, `unexplored`, `nearest`) are deprecated. Use SpatialMap queries instead.

## Output

Returns uniform_return format with:
- `value`: Human-readable summary
- `data`: `{success, query_type, result_count, results: [cell...]}`

## Usage Examples

Map statistics:
```json
{"type":"mc-map-query","query":"stats"}
```

Unobserved cells:
```json
{"type":"mc-map-query","query":"cells-unobserved","x":-112,"z":-123,"radius":15}
```

Safe cells nearby:
```json
{"type":"mc-map-query","query":"cells-safe-to-stand","x":-112,"z":-123,"radius":10}
```

Find water:
```json
{"type":"mc-map-query","query":"cells-water-source"}
```

Find wood (generic - matches all log/plank types):
```json
{"type":"mc-map-query","query":"cells-with-resource","resource_type":"wood"}
```

Find specific wood type:
```json
{"type":"mc-map-query","query":"cells-with-resource","resource_type":"minecraft:oak_log"}
```

Find ore (generic - matches all ore types):
```json
{"type":"mc-map-query","query":"cells-with-resource","resource_type":"ore"}
```

Nearest walkable:
```json
{"type":"mc-map-query","query":"cells-nearest","x":-112,"z":-123,"predicate":"walkable"}
```

Overview

This skill queries the agent's persistent spatial map to extract cells that match strategic criteria for planning, safety, and resource tasks. It returns standardized summaries and structured results that support movement planning, hazard assessment, exploration, and resource discovery. Use it to convert the agent's memory into actionable sets of locations.

How this skill works

The skill inspects a cell-based SpatialMap built from past and present observations. You provide a query type and optional parameters (center coordinates, radius, thresholds, resource type, etc.) and the skill filters or computes attributes like reachability, blocking, confidence, and hazard risk. Results are returned as a uniform object with a human-readable summary and an array of matching cells and metadata.

When to use it

  • Plan a safe route or pick waypoint candidates near the agent.
  • Locate resources (wood, ore, water, food) or specific block instances for gathering.
  • Identify unexplored or low-confidence areas for targeted exploration.
  • Detect hazards, stale observations, or cells that present drop/climb risks.
  • Assess coverage and general map statistics to inform strategy.

Best practices

  • Include x,z (and y when relevant) for accurate query-time computations like blocking, reachability, and drop/climb risk.
  • Use radius to limit search scope and control performance; defaults are available if omitted.
  • Normalize resource_type inputs (minecraft: prefix optional) for exact matches or use generic types for broader results.
  • Apply thresholds (confidence, max_age, max_delta_y) to tune sensitivity for stale or low-confidence cells.
  • Prefer multi-objective queries (candidate waypoints, nearest) when you need combined safety and reachability checks.

Example use cases

  • Find nearby safe tiles to stand on after spotting a hostile mob: query cells-safe-to-stand with center coordinates and radius.
  • Target unexplored terrain for efficient mapping: query cells-unobserved or frontier-cells around the agent.
  • Plan a climb or descent: query cells-requiring-climb or cells-with-drop-risk providing current y to compute step and drop attributes.
  • Gather resources: query cells-with-resource using generic types like 'ore' or a specific ID like 'minecraft:coal_ore'.
  • Recover from outdated data: query cells-stale or cells-low-confidence to prioritize re-observation.

FAQ

What is the difference between generic and specific resource_type?

Generic types (e.g., 'wood', 'ore') match all instances in that category. Specific IDs (e.g., 'minecraft:oak_log') perform exact matches; the 'minecraft:' prefix is optional.

When should I include the y coordinate?

Provide y for queries that compute relative attributes at query time (cells-blocked, cells-reachable, cells-requiring-climb, cells-with-drop-risk) to get accurate step, blocking, and drop-risk results.