Skip to content

Commit

Permalink
Merge pull request #60 from srajan-kiyotaka/sracho
Browse files Browse the repository at this point in the history
Bug Fixed
  • Loading branch information
srajan-kiyotaka authored Jun 20, 2024
2 parents 659274f + e9cfccb commit 70c7815
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='TraverseCraft',
version='0.8.5',
version='0.9.5',
author='Srajan Chourasia, Varun Patrikar',
author_email='[email protected], [email protected]',
maintainer='Srajan Chourasia, Varun Patrikar',
Expand Down
19 changes: 11 additions & 8 deletions src/traverseCraft/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class GraphAgent():
_heatMapBaseColor (str): The base color of the heat map.
_heatGradient (float): The gradient value for the heat map.
_currentNode (GraphNode): The current node the agent is on.
_graphRoot (GraphNode): The root node of the graph.
_startState (GraphNode): The start node of the graph.
algorithmCallBack (function): Callback function for the agent's algorithm.
_startTime (float): The start time of the agent.
_endTime (float): The end time of the agent.
Expand All @@ -590,8 +590,8 @@ def __init__(self, world, agentName:str, agentColor:str="blue", startNodeId = No
self._currentNode = self._worldObj.getNode(startNodeId)
else:
self._currentNode = self._worldObj.nodeMap[list(self._worldObj.nodeMap.keys())[0]]
self._graphRoot = self._currentNode
self._worldObj.changeNodeColor(self._graphRoot.id, self._agentColor)
self._startState = self._currentNode
self._worldObj.changeNodeColor(self._startState.id, self._agentColor)
# ~~~~~~~~~~ Base Heat Map Color ~~~~~~~~~~ #
if self._heatMapView:
BR, BG, BB = int(self._heatMapColor[1:3], 16), int(self._heatMapColor[3:5], 16), int(self._heatMapColor[5:7], 16)
Expand Down Expand Up @@ -635,7 +635,7 @@ def aboutAgent(self):
about.add_row(["Agent Color", self._agentColor])
about.add_row(["World Name", self._worldObj._worldName])
about.add_row(["World ID", self._worldID])
about.add_row(["Start Node ID", self._graphRoot.id])
about.add_row(["Start Node ID", self._startState.id])
return str(about)

def summary(self):
Expand Down Expand Up @@ -666,10 +666,13 @@ def setStartState(self, nodeId):
"""
if nodeId in self._worldObj._position.keys():
self._worldObj.changeNodeColor(self._graphRoot.id, self._worldObj._nodeColor)
if self._startState.isGoalState:
self._worldObj.changeNodeColor(self._startState.id, self._worldObj._goalColor)
else:
self._worldObj.changeNodeColor(self._startState.id, self._worldObj._nodeColor)
self._currentNode = self._worldObj.getNode(nodeId)
self._graphRoot = self._currentNode
self._worldObj.root = self._graphRoot
self._startState = self._currentNode
self._worldObj.root = self._startState
self._worldObj.changeNodeColor(nodeId, self._agentColor)
else:
raise ValueError("Invalid start state!")
Expand All @@ -695,7 +698,7 @@ def runAlgorithm(self):
"""
if self.algorithmCallBack is None:
raise ValueError("Algorithm Call Back Function not set!")
self._graphRoot._heatMapValue = 1
self._startState._heatMapValue = 1
self._startTime = time.time()
self.algorithmCallBack()
self._endTime = time.time()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_graph_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_check_goal_state(self):
def test_set_start_state(self):
self.agent.setStartState("B")
self.assertEqual(self.agent._currentNode.id, "B")
self.assertEqual(self.agent._graphRoot.id, "B")
self.assertEqual(self.agent._startState.id, "B")
self.assertEqual(self.graphWorld.root.id, "B")

def test_set_start_state_invalid(self):
Expand Down
10 changes: 5 additions & 5 deletions tutorials/Tree World/advance.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@
"metadata": {},
"outputs": [],
"source": [
"# First let's Create a grid world object!\n",
"# First let's Create a tree world object!\n",
"treeWorld = CreateTreeWorld(worldName=\"Custom Tree World\", worldInfo=treeWorldInfo, radius=25, nodeColor='green', rootColor='red', goalColor=\"gray\", width=720, height=720)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Compile our Grid World\n",
"## Compile our Tree World\n",
"Since, we are sure that we don't want to do any more changes in the world, thus we will compile our world.\n",
"\n",
"> **Note:** *Once you compile the world you can't change the structure of the world. So make sure that you do all the changes before compiling the world.*"
Expand Down Expand Up @@ -222,14 +222,14 @@
}
],
"source": [
"# Normal cell\n",
"# Normal node\n",
"normalNode = treeWorld.nodeMap['B']\n",
"print(\"Information of node B\")\n",
"print(normalNode)\n",
"\n",
"print(\"-\"*30)\n",
"\n",
"# Goal cell\n",
"# Goal node\n",
"goalNode = treeWorld.nodeMap['K']\n",
"print(\"Information of node K\")\n",
"print(goalNode)"
Expand Down Expand Up @@ -503,7 +503,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Let's see some basic information about our `tree Agent`.\n",
"## Let's see some basic information about our Tree Agent.\n",
"you can use a simple `print()` statement or you can use the builtin function `aboutAgent()` to get the agent information as a string."
]
},
Expand Down
2 changes: 1 addition & 1 deletion tutorials/Tree World/beginner.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@
"outputs": [],
"source": [
"def whatToDo():\n",
" print(\"I am a Grid Agent and I am going to move around the world!\")\n",
" print(\"I am a Tree Agent and I am going to move around the world!\")\n",
" treeAgent.moveAgent('B')\n",
" treeAgent.moveAgent('D')\n",
" treeAgent.moveAgent('B')\n",
Expand Down

0 comments on commit 70c7815

Please sign in to comment.