Archived
0
0

重新实现对象系统

This commit is contained in:
2025-10-18 00:01:56 +08:00
parent 76b715d8d2
commit e77210efc6
6 changed files with 115 additions and 90 deletions

View File

@@ -1,13 +1,20 @@
class Nucleon:
""": 材料元数据"""
"""原子核: 材料元数据"""
def __init__(self, content: str, data: dict):
self.metadata = data
self.content = content
def __init__(self, ident: str, metadata: dict):
"""初始化原子核 (记忆内容)
Args:
ident: 唯一标识符
metadata: 记忆内容信息
orbital: 记忆策略信息 (电子轨道)
"""
self.metadata = metadata
self.ident = ident
def __getitem__(self, key):
if key == "content":
return self.content
if key == "ident":
return self.ident
if key in self.metadata:
return self.metadata[key]
else:
@@ -20,8 +27,9 @@ class Nucleon:
return len(self.metadata)
def __hash__(self):
return hash(self.content)
return hash(self.ident)
@staticmethod
def placeholder():
"""生成一个占位原子核"""
return Nucleon("核子对象样例内容", {})