diff --git a/AMOEBA3/Ressources/BadContext_solver.xml b/AMOEBA3/Ressources/twoDimensionsLauncher.xml similarity index 100% rename from AMOEBA3/Ressources/BadContext_solver.xml rename to AMOEBA3/Ressources/twoDimensionsLauncher.xml diff --git a/AMOEBA3/src/mas/agents/head/Head.java b/AMOEBA3/src/mas/agents/head/Head.java index 4abe326407a5d4571c7df17db8d883d54cd5f115..f96f0165d6c2696ba3bc12dc334305b75aef03e7 100644 --- a/AMOEBA3/src/mas/agents/head/Head.java +++ b/AMOEBA3/src/mas/agents/head/Head.java @@ -7,7 +7,6 @@ import java.util.HashMap; import mas.ncs.NCS; import mas.kernel.Config; import mas.kernel.Launcher; -import mas.kernel.NCSMemory; import mas.kernel.World; import mas.agents.Agent; import mas.agents.percept.Percept; @@ -167,17 +166,12 @@ public class Head extends AbstractHead implements Cloneable{ */ public void play() { - if(world.getScheduler().getTick() == 119) { - System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TICK 119"); - for(Context ctxt : activatedContexts) { - System.out.println(ctxt.getName()); - } - } + for(Percept pct : this.world.getScheduler().getPercepts()) { currentSituation.put(pct, pct.getValue()); } - System.out.println("HEAD ACTIVATED CONTEXT :" + activatedContexts.size()); + nPropositionsReceived = activatedContexts.size(); newContextWasCreated = false; setContextFromPropositionWasSelected(false); diff --git a/AMOEBA3/src/visualization/view/system/MainTabbedPanel.java b/AMOEBA3/src/visualization/view/system/MainTabbedPanel.java index 6b5a7b67c00afdad0c8a385a5972a78a8c6390a4..e16acf584b5fed64f21e05c78e48c5479862ba3b 100644 --- a/AMOEBA3/src/visualization/view/system/MainTabbedPanel.java +++ b/AMOEBA3/src/visualization/view/system/MainTabbedPanel.java @@ -17,7 +17,6 @@ import visualization.view.global.PanelOneChart; import visualization.view.global.ScatterPlotExample; import visualization.view.global.PanelExoVSEndo; import visualization.view.system.nDim.PanelParallelCoordinates; -import visualization.view.system.twoDim.GrapheTwoDimPanelNCSMemories; import visualization.view.system.twoDim.GrapheTwoDimPanelStandard; import visualization.graphView.TemporalGraph; @@ -38,13 +37,9 @@ public class MainTabbedPanel extends JTabbedPane{ /** The panel chart. */ private PanelChart panelChart; - private PanelExoVSEndo exoVsEndo2CtxtChart; - private PanelExoVSEndo exoVsEndoNCtxtChart; - private PanelExoVSEndo exoVsEndoNCtxtByInfluenceChart; /** The panel two dim standard. */ private GrapheTwoDimPanelStandard panelTwoDimStandard; - private GrapheTwoDimPanelNCSMemories panelTwoDimNCSMemories; /** The panel parallel coordinates. */ private PanelParallelCoordinates panelParallelCoordinates; @@ -86,22 +81,16 @@ public class MainTabbedPanel extends JTabbedPane{ panelChart = new PanelChart(world); //panelTwoDim = new GrapheTwoDimPanel(world); panelTwoDimStandard = new GrapheTwoDimPanelStandard(world); - panelTwoDimNCSMemories = new GrapheTwoDimPanelNCSMemories(world); panelParallelCoordinates = new PanelParallelCoordinates(world); consolePanel = new ConsolePanel(); - exoVsEndo2CtxtChart = new PanelExoVSEndo(world, "Error Endo 2 Ctxt"); - exoVsEndoNCtxtChart = new PanelExoVSEndo(world, "Error Endo N Ctxt"); - exoVsEndoNCtxtByInfluenceChart = new PanelExoVSEndo(world, "Error Endo N Ctxt by Influence"); + world.getScheduler().addScheduledItem(panelChart); - world.getScheduler().addScheduledItem(exoVsEndo2CtxtChart); - world.getScheduler().addScheduledItem(exoVsEndoNCtxtChart); - world.getScheduler().addScheduledItem(exoVsEndoNCtxtByInfluenceChart); //this.addTab("BlackBox", new JScrollPane(blackBoxPanel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS)); //this.addTab("System", systemPanel); @@ -111,10 +100,6 @@ public class MainTabbedPanel extends JTabbedPane{ // this.addTab("TwoDim", new JScrollPane(panelTwoDim,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS)); // this.addTab("TwoDim", panelTwoDim); this.addTab("Console", new JScrollPane(consolePanel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS)); - this.addTab("Exo VS endo 2 ctxt", new JScrollPane(exoVsEndo2CtxtChart,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS)); - this.addTab("Exo VS endo N ctxt by distance", new JScrollPane(exoVsEndoNCtxtChart,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS)); - this.addTab("Exo VS endo N ctxt by influence", new JScrollPane(exoVsEndoNCtxtByInfluenceChart,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS)); - this.addTab("NCS Memories", new JScrollPane(panelTwoDimNCSMemories,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS)); ((Frame) this.getTopLevelAncestor()).pack(); @@ -128,7 +113,6 @@ public class MainTabbedPanel extends JTabbedPane{ // systemPanel.update(); // panelTwoDim.update(); panelTwoDimStandard.update(); - panelTwoDimNCSMemories.updateMemories(); world.getScheduler().setWaitForGUIUpdate(false); } diff --git a/AMOEBA3/src/visualization/view/system/twoDim/GrapheTwoDimPanelStandard.java b/AMOEBA3/src/visualization/view/system/twoDim/GrapheTwoDimPanelStandard.java index f6b850233c008d2bed23d233c35bc2f36c2b5789..0229991115c2ad6bf243c6d2432fd7e47720c7eb 100644 --- a/AMOEBA3/src/visualization/view/system/twoDim/GrapheTwoDimPanelStandard.java +++ b/AMOEBA3/src/visualization/view/system/twoDim/GrapheTwoDimPanelStandard.java @@ -235,6 +235,7 @@ public class GrapheTwoDimPanelStandard extends JPanel implements ViewerListener, private Point3 requestPosition; + /** * Instantiates a new graphe two dim panel standard. * @@ -373,8 +374,10 @@ public class GrapheTwoDimPanelStandard extends JPanel implements ViewerListener, if(contexts.getSelectedItem()!=null) { - Node node = graph.getNode(((Context) contexts.getSelectedItem()).getName()); - node.addAttribute("ui.style", "fill-color: rgba(0,255,0,150);"); + highlightContexts((Context) contexts.getSelectedItem()); + } + else { + update(); } @@ -1074,6 +1077,15 @@ private void startPanelController() { obsEle.setTick(world.getScheduler().getTick()); } + + // Update context comboBox + contexts.removeAllItems(); + contexts.addItem(null); + for(Context ctxt : world.getScheduler().getContextsAsContext()) { + contexts.addItem(ctxt); + } + + // Store values into array list of percept of observation ArrayList<Percept> perceptList = world.getAllPercept(); @@ -1220,7 +1232,7 @@ private void startPanelController() { b = 0.0; } } - else if(coefs.length==3) { + else if(coefs.length>=3) { //System.out.println(coefs[0] + " " + coefs[1] + " " + coefs[2]); r = normalizePositiveValues(255, 5, Math.abs(coefs[0])); g = normalizePositiveValues(255, 5, Math.abs(coefs[1])); @@ -1328,53 +1340,7 @@ private void startPanelController() { return requestHashMap; } - public void highlightContextNeighbours(Context context) { - - - double min = Double.POSITIVE_INFINITY; - double max = Double.NEGATIVE_INFINITY; - - for (String name : world.getAgents().keySet()) { - SystemAgent a = world.getAgents().get(name); - if (a instanceof Context) { - double val = ((Context) a).getActionProposal(); - if (val < min) { - min = val; - } - if (val > max) { - max = val; - } - } - - } - - for (String name : world.getAgents().keySet()) { - SystemAgent a = world.getAgents().get(name); - if (a instanceof Context) { - Context n = (Context)a; - Node node = graph.getNode(name); - - node.addAttribute("ui.class","ContextColorDynamic"); - - - node.setAttribute("ui.color", 0.1 ); - - - if(context.equals(n)) { - node.setAttribute("ui.color", 0.0 ); - } - - - - } - - } - - - - - - } + @@ -1411,7 +1377,7 @@ private void startPanelController() { b = 0.0; } } - else if(coefs.length==3) { + else if(coefs.length>=3) { //System.out.println(coefs[0] + " " + coefs[1] + " " + coefs[2]); r = normalizePositiveValues(255, 5, Math.abs(coefs[0])); g = normalizePositiveValues(255, 5, Math.abs(coefs[1])); @@ -1711,8 +1677,6 @@ private void startPanelController() { public void popupMenuForContextVisualization(String id) { JPopupMenu popup = new JPopupMenu("Visualization"); - JMenuItem itemShowContextNeighbours = new JMenuItem("Neighbours"); - itemShowContextNeighbours.addActionListener(e -> {highlightNeighbours(id);}); JMenuItem itemShow2Dim = new JMenuItem("History of grapgh in 2 Dim"); itemShow2Dim.addActionListener(e -> {popupVisualization2Dim(id);}); JMenuItem itemShowNDim = new JMenuItem("Graph Visualization in N Dim"); @@ -1723,8 +1687,7 @@ private void startPanelController() { JMenuItem itemUdateView = new JMenuItem("Update View"); itemUdateView.addActionListener(e -> {update();}); - itemShowAll.addActionListener( e -> {highlightNeighbours(id); popupVisualization2Dim(id); popupVisualizationNDim(id); recolorAllContexts();}); - popup.add(itemShowContextNeighbours); + itemShowAll.addActionListener( e -> {popupVisualization2Dim(id); popupVisualizationNDim(id); recolorAllContexts();}); popup.add(itemShow2Dim); popup.add(itemShowNDim); popup.add(itemShowAll); @@ -1760,10 +1723,7 @@ private void startPanelController() { // double chartY = plot.getRangeAxis().java2DToValue(p.getY(), plotArea, plot.getRangeAxisEdge()); // } - private void highlightNeighbours(String id) { - highlightContextNeighbours(world.getScheduler().getContextByName(id)); - - } +