Batch Operations for Grid #113
Labels
No Label
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: john/McRogueFace#113
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add NumPy-style batch operations for efficient grid manipulation.
Definition of Done:
Wiki References:
Blocked by: #116 (Dirty Flag System) - batch operations will benefit significantly from dirty flag optimization
FOV Data Access Patterns
Investigation of #146 revealed that
compute_fov()has an O(n²) bug where it iterates the entire grid to build a return list. Once fixed, we need better patterns for bulk FOV access.Use cases for FOV data:
Rendering fog overlay - Already handled by the render loop checking
is_in_fov()per visible cell. No batch API needed.Selecting visible entities - "Which entities can I see?"
Applying fog rules to a color layer - "Dim undiscovered cells"
AI decision making - "What can this entity see?"
is_in_fov()is sufficientRecommendation:
compute_fov()as void (fix #146)entities_in_fov()convenience methodcells_in_radius(x, y, r)iterator for efficient radius-based operationsdiscoveredstate tracking separate from per-framevisiblestateProper exposure for FOV and pathfinding without requiring Python to receive huge arrays/lists of points is an important aspect for providing the right interface to these subsystems.
Refined Design - Batch Operations for Grid Layers
Core Problem Solved
The anti-pattern of O(n) Python/C++ boundary crossings:
New Layer Methods
ColorLayer:
TileLayer:
Position Argument Pattern
All position/size arguments accept:
mcrfpy.Vector(x, y)(x, y)tuple[x, y]listInternally converted via Vector normalization.
Anti-pattern (reject):
Correct:
draw_fov() Specification
One-time FOV drawing without perspective binding:
posusing specified algorithmapply_perspective()for that)Dependencies
Commit
018e735implements Phase 2 layer operations:ColorLayer:
fill_rect(pos, size, color)- Fill rectangular region with a colordraw_fov(source, radius=None, fov=None, visible=None, discovered=None, unknown=None)- Paint FOV-based visibilityTileLayer:
fill_rect(pos, size, index)- Fill rectangular region with a tile indexExample usage:
Phase 3 items (apply_perspective, entity.updateVisibility, entity.visible_entities) still pending.