Initial commit

implemented the game of life variation with hexagonal grid
This commit is contained in:
2025-12-16 11:33:00 +00:00
commit ea5b5c4e75
17 changed files with 1229 additions and 0 deletions

39
math/ops.go Normal file
View File

@@ -0,0 +1,39 @@
package math
import (
"math"
)
type SignedNumber interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~float32 | ~float64
}
type Float interface {
~float32 | ~float64
}
func Abs[T SignedNumber](i T) T {
var zero T
if i < zero {
return -i
}
return i
}
func Round[T Float](n T, precision int) T {
if precision == 0 {
return T(math.Round(float64(n)))
}
ratio := math.Pow(10, float64(precision))
f := math.Round(float64(n)*ratio) / ratio
return T(f)
}
func RoundInt[T Float](n T) int {
return int(Round(n, 0))
}
func Sqrt[T Float](n T) T {
return T(math.Sqrt(float64(n)))
}