Skip to content
Snippets Groups Projects
Commit 044f7d98 authored by shinedday's avatar shinedday
Browse files

try to pickle a single agent

parent 708502e0
Branches
No related tags found
No related merge requests found
No preview for this file type
...@@ -16,12 +16,6 @@ class SimpleAgent(Agent): ...@@ -16,12 +16,6 @@ class SimpleAgent(Agent):
self.i += 1 self.i += 1
class SimpleAmas(Amas): class SimpleAmas(Amas):
def on_initial_agents_creation(self) -> None:
for i in range(10):
self.add_agent(SimpleAgent(self))
def on_cycle_begin(self) -> None: def on_cycle_begin(self) -> None:
if self.get_cycle() == 0: if self.get_cycle() == 0:
self.save() self.save()
...@@ -39,10 +33,18 @@ class SimpleAmas(Amas): ...@@ -39,10 +33,18 @@ class SimpleAmas(Amas):
class SimpleEnv(Environment): class SimpleEnv(Environment):
pass pass
"""
env = SimpleEnv()
amas = SimpleAmas(env)
amas.put_token() amas.put_token()
amas.start() amas.start()
"""
env = SimpleEnv()
amas = SimpleAmas(env)
agent = SimpleAgent(amas)
with open('filename.pickle', 'wb') as handle:
pickle.dump(agent.get_id(), handle, protocol=pickle.HIGHEST_PROTOCOL)
pickle.dump(agent.get_neighbour(), handle, protocol=pickle.HIGHEST_PROTOCOL)
pickle.dump(agent.get_phase(), handle, protocol=pickle.HIGHEST_PROTOCOL)
pickle.dump(agent.get_criticality(), handle, protocol=pickle.HIGHEST_PROTOCOL)
pickle.dump(agent.get_environment(), handle, protocol=pickle.HIGHEST_PROTOCOL)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment