refactor(pet): 重构宠物经验计算逻辑,引入种族值参数并优化进化条件判断

This commit is contained in:
1
2025-09-22 15:47:07 +00:00
parent 9dbc0fb051
commit a05219c6ae
3 changed files with 37 additions and 91 deletions

View File

@@ -9,63 +9,8 @@ import (
"github.com/apcera/termtables"
"github.com/gogf/gf/v2/os/glog"
"github.com/pointernil/bitset32"
)
func TestThree(t *testing.T) {
fmt.Printf("! \n")
var b bitset32.BitSet32
var a bitset32.BitSet32
// play some Go Fish
// for i := 0; i < 100; i++ {
// card1 := uint(rand.Intn(52))
// card2 := uint(rand.Intn(52))
// b.Set(card1)
// if b.Test(card2) {
// fmt.Println("Go Fish!")
// }
// b.Clear(card1)
// }
// Chaining
b.Set(10).Set(11)
a = *bitset32.New(50)
for i, e := b.NextSet(0); e; i, e = b.NextSet(i + 1) {
fmt.Println("The b bit is set:", i)
}
a.Set(10).Set(9)
f := b.Union(&a)
for i, e := f.NextSet(0); e; i, e = f.NextSet(i + 1) {
fmt.Println("The b+ bit is set:", i)
}
fmt.Println(b.Bytes())
}
func TestMap(t *testing.T) {
// 使用 SyncMap 存储字符串 -> int 类型的键值对
sm1 := &SyncMap[string, int]{}
sm1.Store("apple", 5)
sm1.Store("banana", 10)
// 加载并打印值
if value, ok := sm1.Load("apple"); ok {
fmt.Println("apple:", value)
}
if value, ok := sm1.Load("banana"); ok {
fmt.Println("banana:", value)
}
// 使用 SyncMap 存储 int -> string 类型的键值对
sm2 := &SyncMap[int, string]{}
sm2.Store(1, "one")
sm2.Store(2, "two")
// 遍历所有键值对
sm2.Range(func(key int, value string) bool {
fmt.Printf("%d: %s\n", key, value)
return true
})
}
func TestInit(t *testing.T) {
table := termtables.CreateTable()