10.07.2015 Views

pdf - 395 K - Ecole des mines de Nantes

pdf - 395 K - Ecole des mines de Nantes

pdf - 395 K - Ecole des mines de Nantes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}DirectoryFacilitator.GetDF().Unregister(GetId());// Abort all <strong>de</strong>pen<strong>de</strong>nt threadsfor (int i = 0; i < threads.Count; i++){WeakReference wr = (WeakReference) threads[i];Thread t = (Thread) wr.Target;if (t != null)t.Abort();}}}public overri<strong>de</strong> String ToString(){return "[Agent:" + GetType().Name + "]";//return "[Agent:" + GetId() + "]";}11. Class MAP.Activityusing System;using System.Threading;using System.Collections;namespace MAP{/// /// Defines a piece of behaviour for an Agent./// It is aimed at providing modularity in the implementation of anAgent's/// behaviour. An Activity can have its own data, allowing for aclear/// separation between activity-<strong>de</strong>pen<strong>de</strong>nt data and the Agent's mentalstate./// If work involves multithreading, Threads should be created viathe NewThread/// method for allowing the Agent to keep control over its behaviour./// public abstract class Activity{// The Agent this belongs to.protected readonly Agent agent;// The Thread that executes thisprotected Thread mainThread;protected Activity(Agent ag){agent = ag;mainThread = null;}/// /// Defines the work performed by this when its main thread isstarted./// Default implementation does nothing (thread finishesimmediately)./// public virtual void Execute() {}MSc EMOOSE Thesis – http://www.emn.fr/EMOOSE 89

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!