/** * The main method of the Spatial System that is called on each interaction cycle. Track the * spatial consequences of the current enaction. * * @param enaction The current enaction. */ public void track(Enaction enaction) { Object pie = null; if (m_tracer != null) pie = m_tracer.addEventElement("construct", true); // for (ActInstance p : enaction.getEnactedPlaces()) // p.normalize(3); // Update spatial memory this.spacialMemory.tick(); this.spacialMemory.transform(enaction.getTransform3D()); this.spacialMemory.forgetOldPlaces(); for (ActInstance actInstance : enaction.getEnactedPlaces()) { this.spacialMemory.addPlaceable(actInstance); if (actInstance.getModality() == ActInstance.MODALITY_MOVE) { this.spacialMemory.clearPhenomenonInstanceFront(); } else { PhenomenonInstance phenomenonInstance = this.spacialMemory.getPhenomenonInstance(actInstance.getPosition()); if (phenomenonInstance == null) { // create a new phenomenon type with this act PhenomenonType phenomenonType = PhenomenonTypeImpl.evoke(actInstance.getAspect()); if (phenomenonType == null) { phenomenonType = PhenomenonTypeImpl.createNew(); phenomenonType.setAspect(actInstance.getAspect()); phenomenonType.addPrimitive(actInstance.getPrimitive()); phenomenonInstance = new PhenomenonInstanceImpl(phenomenonType, actInstance.getPosition()); this.spacialMemory.addPlaceable(phenomenonInstance); } else { phenomenonType.addPrimitive(actInstance.getPrimitive()); phenomenonInstance = new PhenomenonInstanceImpl(phenomenonType, actInstance.getPosition()); this.spacialMemory.addPlaceable(phenomenonInstance); } if (m_tracer != null) { phenomenonInstance.trace(m_tracer, pie); m_tracer.addSubelement(pie, "create", actInstance.getDisplayLabel()); } } else { phenomenonInstance.setClock(0); // add this act to the phenomenon type of this place PhenomenonType phenomenonType = phenomenonInstance.getPhenomenonType(); if (!phenomenonType.contains(actInstance.getPrimitive())) { // if (!phenomenonInstance.equals(this.focusPhenomenonInstance)){ // if (m_tracer != null ){ // phenomenonInstance.trace(m_tracer, pie); // m_tracer.addSubelement(pie, "shift", ""); // } // } // } // else{ phenomenonType.addPrimitive(actInstance.getPrimitive()); if (m_tracer != null) { phenomenonInstance.trace(m_tracer, pie); m_tracer.addSubelement(pie, "add", actInstance.getDisplayLabel()); } } } if (actInstance.getModality() == ActInstance.MODALITY_CONSUME || actInstance.getModality() == ActInstance.MODALITY_BUMP) phenomenonInstance .getPhenomenonType() .setAttractiveness(actInstance.getPrimitive().getValue()); // this.focusPhenomenonInstance = phenomenonInstance; } } // The focus phenomenon is the one that has the highest attractiveness or that is the closest or // with which there is an interaction PhenomenonInstance phenomenonInstance = PhenomenonInstance.EMPTY; if (enaction.getSalientActInstance() != null) { PhenomenonInstance salientPhenomenonInstance = this.spacialMemory.getPhenomenonInstance(enaction.getSalientActInstance().getPosition()); if (salientPhenomenonInstance != null) phenomenonInstance = salientPhenomenonInstance; } float distance = 10000; int attractiveness = -200; for (PhenomenonInstance p : this.spacialMemory.getPhenomenonInstances()) if (p.getPhenomenonType().getAttractiveness() > attractiveness && p.getClock() == 0) { phenomenonInstance = p; distance = phenomenonInstance.getDistance(); attractiveness = phenomenonInstance.getPhenomenonType().getAttractiveness(); } else if (p.getDistance() < distance && p.getClock() == 0) { phenomenonInstance = p; distance = phenomenonInstance.getDistance(); attractiveness = phenomenonInstance.getPhenomenonType().getAttractiveness(); } if (!this.focusPhenomenonInstance.equals(phenomenonInstance)) { this.focusPhenomenonInstance = phenomenonInstance; if (m_tracer != null) { phenomenonInstance.trace(m_tracer, pie); m_tracer.addSubelement(pie, "shift", ""); } } // Merge phenomenon types // this.mergePhenomenonTypes(enaction.getSalientPlace()); }