deterministic-math-guidelines

Enforce deterministic math methods and fixed-point arithmetic in Swift StateTree game logic.

1|Updated Nov 22, 2025
One-click install
npx skills add https://github.com/gmliao/swift-state-tree --skill deterministic-math-guidelines
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: deterministic-math-guidelines
Source: https://github.com/gmliao/swift-state-tree/tree/main/.agent/skills/SwiftStateTree/deterministic-math-guidelines
Command: npx skills add https://github.com/gmliao/swift-state-tree --skill deterministic-math-guidelines

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Deterministic math across platforms is essential for consistent gameplay and synchronization in SwiftStateTree. This skill provides guidelines to avoid platform-dependent math pitfalls and ensures consistent results.

Core Features & Use Cases

  • Enforces use of deterministic math methods and semantic types
  • Provides rules for fixed-point arithmetic, vector operations, and collision-related calculations
  • Helps teams maintain cross-platform consistency in physics, movement, and angle calculations

Quick Start

Use the deterministic-math-guidelines skill to ensure cross-platform deterministic behavior in physics and movement calculations. For example, replace platform-dependent math calls with DeterministicMath methods and apply semantic types for positions and vectors.

Frequently Asked Questions about deterministic-math-guidelines

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I ensure cross-platform deterministic math in Swift game logic?

To ensure cross-platform deterministic math in Swift game logic, replace platform-dependent math calls with DeterministicMath methods and apply semantic types for positions and vectors. This enforces fixed-point arithmetic to avoid platform-dependent math pitfalls.

Why does floating point math cause desync across macOS, Linux, and iOS?

Floating point math causes desync across macOS, Linux, and iOS due to platform-dependent math functions. Enforcing fixed-point arithmetic and deterministic methods ensures consistent results for physics and movement calculations across these targets.

What is the best way to handle collision detection deterministically in Swift?

The best way to handle collision detection deterministically in Swift is by using semantic types and fixed-point arithmetic for vector operations. This maintains cross-platform consistency and avoids direct Int64 returns.

Can I use standard Swift math functions for physics calculations across iOS and Linux?

No, standard Swift math functions are platform-dependent and cause non-deterministic results for physics calculations across iOS and Linux. You must use DeterministicMath methods and fixed-point arithmetic to maintain synchronization.

When do I need fixed-point arithmetic for game logic?

You need fixed-point arithmetic for game logic when performing physics, movement, distances, vectors, and collision detection across macOS, Linux, and iOS. It enforces cross-platform determinism by avoiding platform-dependent math functions.