Skip to content
Snippets Groups Projects
Commit 6b346a10 authored by Egli Adrian (IT-SCI-API-PFI)'s avatar Egli Adrian (IT-SCI-API-PFI)
Browse files

If agent.position == agent.target -> render only transpartent occupied layer

parent 604f3d86
No related branches found
No related tags found
No related merge requests found
......@@ -79,6 +79,9 @@ class GraphicsLayer(object):
def setAgentAt(self, iAgent, row, col, iDirIn, iDirOut, isSelected=False):
pass
def setCellOccupied(self, iAgent, row, col):
pass
def resize(self, env):
pass
......
......@@ -383,6 +383,9 @@ class PILSVG(PILGL):
station = self.pilFromSvgFile("svg", "Bahnhof_#d50000_target.svg")
self.ltStationColors = self.recolorImage(station, [0, 0, 0], self.ltAgentColors, False)
cellOccupied = self.pilFromSvgFile("svg", "Cell_occupied.svg")
self.ltCellOccupied = self.recolorImage(cellOccupied, [0, 0, 0], self.ltAgentColors, False)
# Merge them with the regular rails.
# https://stackoverflow.com/questions/38987/how-to-merge-two-dictionaries-in-a-single-expression
self.dPilRail = {**dPilRailFiles, **dPilTargetFiles}
......@@ -538,6 +541,10 @@ class PILSVG(PILGL):
self.clear_layer(2, 0)
self.drawImageRC(svgBG, (row, col), layer=2)
def setCellOccupied(self, iAgent, row, col):
occIm = self.ltCellOccupied[iAgent % len(self.ltCellOccupied)]
self.drawImageRC(occIm, (row, col), 1)
def main2():
gl = PILSVG(10, 10)
......
......@@ -673,8 +673,13 @@ class RenderTool(object):
direction = agent.direction
old_direction = agent.direction
# setAgentAt uses the agent index for the color
self.gl.setAgentAt(iAgent, *position, old_direction, direction, iSelectedAgent == iAgent)
if agent.position == agent.target:
# setAgentAt uses the agent index for the color
self.gl.setCellOccupied(iAgent, *(agent.position))
else:
# setAgentAt uses the agent index for the color
self.gl.setCellOccupied(iAgent, *(agent.position))
self.gl.setAgentAt(iAgent, *position, old_direction, direction, iSelectedAgent == iAgent)
if show_observations:
self.renderObs(range(env.get_num_agents()), env.dev_obs_dict)
......
......@@ -70,7 +70,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d0b362c4de2849fe93f505143d04b243",
"model_id": "d1b14568dc1a48ba9ca3eb6afb7f2eff",
"version_major": 2,
"version_minor": 0
},
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Ebene_1"
x="0px"
y="0px"
viewBox="0 0 240 240"
style="enable-background:new 0 0 240 240;"
xml:space="preserve"
sodipodi:docname="Cell_occupied.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"><metadata
id="metadata11"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata>
<defs
id="defs9" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1017"
id="namedview7"
showgrid="false"
inkscape:zoom="2.7812867"
inkscape:cx="24.994769"
inkscape:cy="123.32931"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="Ebene_1" />
<style
type="text/css"
id="style2">
.st0{fill:#9CCB89;}
</style>
<rect
style="fill:#000000;fill-opacity:0.90196079;stroke-width:1.00000226"
id="rect874"
width="240.89569"
height="241.25525"
x="9.5030348e-09"
y="0.18293978" /></svg>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment