Cleanup: mcrfpy.libtcod #215
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
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 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#215
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Research spike story
mcrfpy.libtcod.line
Should accept mcrfpy.Vector, tuple, or list - not separate X and Y values.
Should return tuple(mcrfpy.Vector).
mcrfpy.libtcod.compute_fov
Should be a grid method and take tuple/list/mcrfpy.Vector for a position.
Other missing methods
libtcod.line is useful because it's a list of points. They probably apply to a grid, but it's just (x,y) positions. It would also apply to heightmap positions now.
What else does libtcod have that we should expose? HeightMap, BSP, and NoiseSource cover a lot of the procedural generation. The pathfinding is largely moved to Grid's methods. Should we import markov chains for text and other utility functions, for completeness? These capabilities are already in the libraries we ship.
libtcod API Exposure Research Complete
Full research documents created in
docs/libtcod_research/:Summary
Already Covered (no action needed):
High Priority (implement for 7DRL):
Medium Priority (polish features):
3. NameGenerator - Syllable-based name generation for NPCs, places, items
4. Image Toolkit - Load images and convert to Grid/HeightMap data
Low Priority:
5. Clipboard - Use SFML's clipboard API (not libtcod's deprecated SDL-based one)
Skip:
Estimated Implementation Time
Based on existing NoiseSource/BSP/HeightMap patterns:
Total: ~3-5 hours for everything
Files Created
Line Enhancement Analysis
Existing APIs for Comparison
Grid Methods:
Entity Methods:
Current Line:
Question 1: API Style Consistency
The original research doc proposed:
line(player, enemy)- Accepting raw Entity objectsline(..., grid=grid, filter='transparent')- String-based filteringhas_line_of_sight(a, b, grid=grid)- Convenience wrapperProblems:
has_line_of_sightduplicates FOV functionalityRecommendation: Use existing
ExtractPosition()helper pattern:Question 2: "Additional, Worse" Methods
has_line_of_sight(a, b, grid)grid.compute_fov()+grid.is_in_fov()line(..., grid=grid, filter='transparent')line(..., stop_on_obstacle=True)line_iter()lazy iteratorinclude_start=Falseinclude_end=FalseThe Archery Use Case:
"Can an arrow fly from A to B?" is not an FOV question:
A target could be "in FOV" but blocked by a narrow pillar. Or vice versa.
Question 3: Completeness
line(x1,y1,x2,y2)→ listinit()/step()statefulline()with callbackBresenhamLineiterator.without_start()include_start=False.without_end()include_end=False.adjust_range()Recommendation: Minimal Enhancement
Add only:
Implementation:
ExtractPosition()for flexible position parsingExample - Archery:
What NOT to add:
grid=parameter (user checks cells manually - more explicit)filter=parameter (string-based filtering is un-Pythonic)has_line_of_sight()(use FOV instead)line_iter()(memory savings not worth complexity)Implementation Plan
Decision: Remove
mcrfpy.libtcodnamespace entirely. Expose enhanced line algorithm as top-levelmcrfpy.bresenham().Rationale:
libtcod.compute_fovalready duplicated asgrid.compute_fov()- redundantrandommodule covers RandomSource use case (Mersenne Twister, serializable state)New API:
ExtractPosition()for flexible input (tuple, Vector, list)include_start=Falsefor "cells between me and target, excluding myself"include_end=Falsefor "cells projectile passes through before hitting"Example - Archery:
Implementation:
mcrfpy.bresenham()to McRFPy_API.cppmcrfpy.libtcodsubmodule registration