From ca53a867c09e6cb87978d56773eea62205e61821 Mon Sep 17 00:00:00 2001 From: Spartan-71 Date: Sat, 23 Nov 2024 17:56:50 +0530 Subject: [PATCH] Refactor: Remove step/agent_act function from MoneyAgent class --- docs/tutorials/intro_tutorial.ipynb | 30 +++++------------------------ 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/docs/tutorials/intro_tutorial.ipynb b/docs/tutorials/intro_tutorial.ipynb index 5b4a0052a44..3398612bcb7 100644 --- a/docs/tutorials/intro_tutorial.ipynb +++ b/docs/tutorials/intro_tutorial.ipynb @@ -682,17 +682,6 @@ " self.wealth -= 1\n", "```\n", "\n", - "And with those two methods, the agent's ``agent_act`` method becomes:\n", - "\n", - "```python\n", - "class MoneyAgent(mesa.Agent):\n", - " # ...\n", - " def agent_act(self):\n", - " self.move()\n", - " if self.wealth > 0:\n", - " self.give_money()\n", - "```\n", - "\n", "Now, putting that all together should look like this:" ] }, @@ -725,11 +714,6 @@ " other_agent.wealth += 1\n", " self.wealth -= 1\n", "\n", - " def agent_act(self):\n", - " self.move()\n", - " if self.wealth > 0:\n", - " self.give_money()\n", - "\n", "\n", "class MoneyModel(mesa.Model):\n", " \"\"\"A model with some number of agents.\"\"\"\n", @@ -748,7 +732,8 @@ " self.grid.place_agent(a, (x, y))\n", "\n", " def step(self):\n", - " self.agents.shuffle_do(\"agent_act\")" + " self.agents.shuffle_do(\"move\")\n", + " self.agents.do(\"give_money\")" ] }, { @@ -867,13 +852,7 @@ " other = self.random.choice(cellmates)\n", " other.wealth += 1\n", " self.wealth -= 1\n", - "\n", - " # There are several ways in which one can combine functions to execute the model\n", - " def agent_act(self):\n", - " self.move()\n", - " if self.wealth > 0:\n", - " self.give_money()\n", - "\n", + " \n", "\n", "class MoneyModel(mesa.Model):\n", " \"\"\"A model with some number of agents.\"\"\"\n", @@ -898,7 +877,8 @@ "\n", " def step(self):\n", " self.datacollector.collect(self)\n", - " self.agents.shuffle_do(\"agent_act\")" + " self.agents.shuffle_do(\"move\")\n", + " self.agents.do(\"give_money\")" ] }, {