Start on Implementing PIPs
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
package koboldsim
|
||||
|
||||
import "math"
|
||||
import (
|
||||
"math"
|
||||
|
||||
"golang.org/x/exp/constraints"
|
||||
)
|
||||
|
||||
// Generic helper functions not directly attached to Card Sim Engine mechanics.
|
||||
|
||||
@ -20,3 +24,13 @@ func Mean(vals ...float64) float64 {
|
||||
}
|
||||
return total / float64(len(vals))
|
||||
}
|
||||
|
||||
func clamp[T constraints.Ordered](val, low, high T) T {
|
||||
if val < low {
|
||||
return low
|
||||
}
|
||||
if val > high {
|
||||
return high
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
Reference in New Issue
Block a user