Skip to main content

Crate gametools

Crate gametools 

Source
Expand description

§gametools

gametools provides reusable utilities for common game-building needs such as card decks, dice, spinners, dominos, grids, field of view, pathfinding, ranked ordering, and bounded resources. The goal is to provide flexible, modular tools to simplify prototyping and building games and simulations.

§Features

  • cards: generic card faces plus deck, hand, and pile abstractions, with standard 52-card and Uno helpers.
  • dice: Die and Rolls support for regular and exploding dice along with common roll-analysis helpers.
  • grid: point-addressed rectangular grids with bounded or toroidal row, column, and neighbor traversal helpers.
  • fov: field-of-view maps with raycasting, shadowcasting, and rectangle-based algorithms.
  • pathfinding: Dijkstra maps plus A* variants for bounded or toroidal grids.
  • ordering: stable ranked lists (RankedOrder) and heap-backed queues (PriorityQueue) for turn order and scheduling.
  • metered_resource: bounded unsigned counters with saturating increase and reduction helpers.
  • refilling_pool: infinitely reusable random pools with conditional and contextual draw helpers.
  • spinners: decision wheels with weighted, coverable wedges that can hold arbitrary values.
  • dominos: domino set creation, train management, and longest-train solving.
  • Module-specific error enums plus GameError / GameResult for aggregate error handling across the crate.

Re-exports§

pub use cards::AddCard;
pub use cards::Card;
pub use cards::CardCollection;
pub use cards::CardFaces;
pub use cards::CardHand;
pub use cards::Deck;
pub use cards::Hand;
pub use cards::Pile;
pub use cards::Rank;
pub use cards::Suit;
pub use cards::TakeCard;
pub use dice::Die;
pub use dice::DieResult;
pub use dice::Rolls;
pub use dominos::BonePile;
pub use dominos::Domino;
pub use dominos::DominoHand;
pub use dominos::MAX_PIPS;
pub use dominos::Train;
pub use metered_resource::MeteredResource;
pub use refilling_pool::RefillingPool;
pub use spinners::Spinner;
pub use spinners::Wedge;
pub use spinners::wedges_from_tuples;
pub use spinners::wedges_from_values;
pub use gameerror::CardError;
pub use gameerror::DiceError;
pub use gameerror::DominoError;
pub use gameerror::GameError;
pub use gameerror::GridError;
pub use gameerror::PathfindingError;
pub use gameerror::RefillingPoolError;
pub use gameerror::SpinnerError;
pub use gameerror::ValueError;
pub use grid::Grid;
pub use grid::GridSize;
pub use grid::GridTopology;
pub use grid::Point;
pub use grid::PointDelta;
pub use fov::BlockingRect;
pub use fov::FovMap;
pub use fov::RectangleFov;
pub use fov::perimeter_raycasting;
pub use fov::perimeter_raycasting_into;
pub use fov::rectangle_based_fov;
pub use fov::rectangle_based_fov_into;
pub use fov::recursive_shadowcasting;
pub use fov::recursive_shadowcasting_into;
pub use ordering::AscendingOrder;
pub use ordering::DescendingOrder;
pub use ordering::Max;
pub use ordering::MaxPriorityQ;
pub use ordering::Min;
pub use ordering::MinPriorityQ;
pub use ordering::PriorityQueue;
pub use ordering::RankedOrder;
pub use pathfinding::Cost;
pub use pathfinding::HeuristicWeight;
pub use pathfinding::MoveSet;
pub use pathfinding::Path;
pub use pathfinding::SearchMap;
pub use pathfinding::a_star;
pub use pathfinding::a_star_weighted;
pub use pathfinding::a_star_weighted_with_topology;
pub use pathfinding::a_star_with_topology;
pub use pathfinding::dijkstra_map;
pub use pathfinding::dijkstra_map_with_topology;
pub use pathfinding::path_from_search_map;

Modules§

cards
Cards Toolkit
dice
Dice - types and manipulations commonly needed for die-based games
dominos
Dominos Module
fov
Field-of-view algorithms for point-addressed Grid maps.
gameerror
Shared error types used across the crate.
grid
Grid<T>
metered_resource
MeteredResource
ordering
ordering - types for handling anything in a particular order.
pathfinding
Pathfinding over Grid maps.
refilling_pool
RefillingPool - a randomized pool of items that refills itself when empty.
spinners
Spinners Module

Macros§

ensure
Returns early with the supplied error when a condition is false.

Type Aliases§

GameResult
The crate-wide result type for APIs that can return GameError.