score
A calculus for scoreboard optimization.
Optimizations
set
fusion
scoreboard players set a _ 1
scoreboard players set a _ 2
scoreboard players add b _ 1
scoreboard players set b _ 2
scoreboard players remove c _ 1
scoreboard players set c _ 2
scoreboard players reset d _
scoreboard players set d _ 2
scoreboard players set a _ 2
scoreboard players set b _ 2
scoreboard players set c _ 2
scoreboard players set d _ 2
add
/remove
fusion
scoreboard players add a _ 2
scoreboard players remove a _ 3
scoreboard players add a _ 2
scoreboard players add a _ 1
Strength reduction
scoreboard players set _ _ 2
scoreboard players operation a _ *= _ _
scoreboard players operation a _ += a _
Batch operation
scoreboard players set a_0 A 0
scoreboard players set a_1 A 0
scoreboard players set b_0 B 0
scoreboard players set b_1 B 0
observe a_0 A
observe a_1 A
observe b_0 B
observe b_1 B
scoreboard players set b_0 B 1
scoreboard players set b_1 B 1
scoreboard players set a_0 A 1
scoreboard players set a_0 A 0
scoreboard players set a_1 A 0
scoreboard players set b_0 B 0
scoreboard players set b_1 B 0
observe a_0 A
observe a_1 A
observe b_0 B
observe b_1 B
scoreboard players set * B 1
scoreboard players reset a_1 B
Algebraic simplification
scoreboard players set a _ 1
scoreboard players operation a _ += b _
scoreboard players operation a _ -= b _
scoreboard players set a _ 1
Dataflow analysis
scoreboard players set a _ 0
execute if score b _ matches 0 run function
execute unless score b _ matches 0 run scoreboard players operation a _ += b _
scoreboard players operation a _ += b _
scoreboard players set b _ 1
execute unless score b _ matches 0 run scoreboard players operation a _ += b _
scoreboard players set _ _ 2
scoreboard players operation a _ /= _ _
scoreboard players set _ _ 2
scoreboard players operation b _ %= _ _
scoreboard players set a _ 0
execute if score b _ matches 0 run function
scoreboard players add a _ 1
scoreboard players set _ _ 2
scoreboard players operation a _ /= _ _
scoreboard players operation b _ %= _ _