//[Test]
        public void SingleUpdate_RecievedGetAllPercepts_PickUpPerceptsAndReturnThemThroughWriter()
        {
            ActionManager manager = new ActionManager(new EventManager());
            TileWorldBuilder worldBuilder = new TileWorldBuilder(new Size(4, 4));

            Agent agent = new Agent("testagent");
            worldBuilder.AddEntity(() => agent, new TileSpawnInformation(new TilePosition(new Point(0, 0))));

            XmasFactory fact = new XmasFactory(manager);
            TileWorld world = (TileWorld)worldBuilder.Build();
            agent.ActionManager = manager;
            agent.World = world;
            agent.Factory = fact;

            Thread thread1 = new Thread(test2);
            thread1.Name = "TCP Server";
            thread1.Start();

            while (lock1)
            {
            }
            TcpClient client = new TcpClient("localhost", 6661);
            Stream stream = client.GetStream();

            StringBuilder sb = new StringBuilder();

            EisConversionTool ctool = new EisConversionTool();
            ctool.AddConverter(new GetAllPerceptsActionConverter());
            ctool.AddConverter(new EISPerceptCollectionSerializer());
            ctool.AddConverter(new EisTileVisionSerializer());
            ctool.AddConverter(new EISSingleNumeralSerializer());

            IILActionParser parser = new IILActionParser();

            XmlReaderSettings set = new XmlReaderSettings();
            set.ConformanceLevel = ConformanceLevel.Fragment;
            XmlReader xreader = XmlReader.Create(new StreamReader(stream, Encoding.UTF8));
            XmlWriterSettings wset = new XmlWriterSettings();
            wset.OmitXmlDeclaration = true;
            XmlWriter xwriter = XmlWriter.Create(sb, wset);
            controller = new EISAgentController(agent, client, manager, new PacketStream(stream), new StreamReader(stream), new StreamWriter(stream), ctool, parser);

            Thread thread2 = new Thread(test1);
            thread2.Name = "Controller";
            thread2.Start();

            while (manager.ExecuteActions() == 0) ;
            string returned = null;
            do
            {
                try
                {
                    returned = sb.ToString();
                }
                catch
                {
                }
            } while (String.IsNullOrEmpty(returned));
        }
Esempio n. 2
0
        public EISAgentController(Agent agent, TcpClient client, ActionManager actman, PacketStream packetstream, StreamReader sreader, StreamWriter swriter, EisConversionTool tool,
		                          IILActionParser actionparser)
            : base(agent)
        {
            this.client = client;
            this.packetstream = packetstream;
            this.sreader = sreader;
            this.swriter = swriter;
            PerceptsRecieved += EISAgentController_PerceptsRecieved;
            this.tool = tool;
            this.actionparser = actionparser;
            this.actman = actman;
        }
Esempio n. 3
0
 public EISAgentServer(TcpListener listener, EisConversionTool tool, IILActionParser parser)
 {
     this.listener = listener;
     this.tool = tool;
     this.parser = parser;
 }