Skip to content

Use * for multiple dice rolls and @ for value scaling#7

Merged
koaning merged 4 commits into
mainfrom
cursor/matmul-multiple-dice-mul-7666
Jun 17, 2026
Merged

Use * for multiple dice rolls and @ for value scaling#7
koaning merged 4 commits into
mainfrom
cursor/matmul-multiple-dice-mul-7666

Conversation

@koaning

@koaning koaning commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Fixes #3

Summary

Changes dice multiplication semantics to match tabletop notation:

  • d6 * 3 (or 3 * d6) now rolls three six-sided dice and sums the results — equivalent to d6 + d6 + d6
  • d6 @ 3 (or 3 @ d6) scales each face value by a scalar — the previous behavior of *

Multiplying two Dice objects with * still computes the product of independent rolls.

Examples

from dicekit import Dice, exp

d6 = Dice.from_sides(6)

# 3d6: sum of three rolls
three_d6 = d6 * 3
exp(three_d6)  # 10.5

# Scale face values (old * behavior)
scaled = d6 @ 3
exp(scaled)  # 10.5 for a fair d6, but distribution differs from 3d6

Testing

  • Updated test_dice_reflected_operations to use @ for scalar scaling
  • Added test_dice_mul_counts_rolls and test_dice_matmul_scales_values
  • All 17 tests pass
Open in Web Open in Cursor 

cursoragent and others added 3 commits June 9, 2026 08:20
Dice multiplication by an integer now sums that many independent rolls,
matching tabletop notation like 3d6. Scalar value scaling moves to @
(matmul), so d6 @ 3 multiplies each face value by 3.

Fixes #3

Co-authored-by: vincent d warmerdam  <koaning@users.noreply.github.com>
Co-authored-by: vincent d warmerdam  <koaning@users.noreply.github.com>
Co-authored-by: vincent d warmerdam  <koaning@users.noreply.github.com>
@koaning
koaning marked this pull request as ready for review June 9, 2026 10:07
…e-dice-mul-7666

# Conflicts:
#	dicekit/__init__.py
#	nbs/__init__.py
@koaning
koaning merged commit c0a1fd1 into main Jun 17, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

matmul for same dice with values times "k"

2 participants