Esempio n. 1
0
        public InboxController(UIInbox view, IClientDataService dataService, IDatabaseService database, Network.Network net)
        {
            this.View            = view;
            this.DataService     = dataService;
            this.DatabaseService = database;
            this.Network         = net;

            this.InboxStore = UIMessageStore.Store;
            try
            {
                InboxStore.Load((int)net.MyCharacter);
            } catch
            {
                //oops, we couldnt load the local data...
                //assuming it failed anywhere, it will download from server as if timestamp were 0.
            }

            this.Network.CityClient.AddSubscriber(this);

            Network.CityClient.Write(new MailRequest
            {
                Type        = MailRequestType.POLL_INBOX, //we're ready to recieve any pending roommate requests
                TimestampID = InboxStore.LastMessageTime
            });

            GameThread.NextUpdate(x =>
            {
                View.UpdateInbox();
            });
        }
Esempio n. 2
0
        public UIGridSlot(Network.Network network, Item item)
        {
            Width = Height = (40, 0);

            Network = network;
            Item    = item;
        }
Esempio n. 3
0
        public NetworkAPIDemo(Mode mode)
        {
            switch (mode)
            {
            case Mode.BASIC_CLA: _network = CreateBasicNetworkCla(); break;

            case Mode.BASIC_SDR: _network = CreateBasicNetworkSdr(); break;

            case Mode.MULTILAYER: _network = CreateMultiLayerNetwork(); break;

            case Mode.MULTIREGION: _network = CreateMultiRegionNetwork(); break;
            }

            _network.Observe().Subscribe(GetSubscriber());
            try
            {
                _outputFile = new FileInfo("c:\\temp\\napi_hotgym_demo_output_" + mode + ".txt");
                Debug.WriteLine("Creating output file: " + _outputFile);
                _pw = new StreamWriter(_outputFile.OpenWrite());
                _pw.WriteLine("RecordNum,Actual,Predicted,Error,AnomalyScore");
            }
            catch (IOException e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 4
0
        public GenericActionRegulator(Network.Network network)
        {
            Network = network;
            Network.CityClient.AddSubscriber(this);

            AddState("Idle").Transition().Default()
            .OnData(typeof(T))
            .TransitionTo("StartAction");

            AddState("StartAction").OnlyTransitionFrom("Idle");
            //if action needs validation, transitions to ValidateAction.
            //otherwise, if action needs further input, transition to ActionInput
            //otherwise, transtion directly to PerformAction.
            AddState("GenericFailure");


            AddState("ValidateAction").OnlyTransitionFrom("StartAction")
            .OnData(typeof(T2))
            .TransitionTo("ValidateActionResponse");

            AddState("ValidateActionResponse").OnlyTransitionFrom("ValidateAction");
            //if failed, branch into GenericFailure
            AddState("ActionInput").OnlyTransitionFrom("ValidateActionResponse", "StartAction")
            .OnData(typeof(T))
            .TransitionTo("PerformAction");

            AddState("PerformAction").OnlyTransitionFrom("ActionInput", "StartAction")
            .OnData(typeof(T2))
            .TransitionTo("PerformActionResponse");

            AddState("PerformActionResponse").OnlyTransitionFrom("PerformAction");

            AddState("ActionSuccess").OnlyTransitionFrom("PerformActionResponse");
        }
Esempio n. 5
0
        private static List <Layer> GetBackwardLayers(Network.Network network)
        {
            var backwardLayers = network.Layers.ToList();

            backwardLayers.Reverse();
            return(backwardLayers);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            var ip1                 = ConfigurationManager.AppSettings["IpV4Filter1"] == string.Empty ? null : ConfigurationManager.AppSettings["IpV4Filter1"];
            var ip2                 = ConfigurationManager.AppSettings["IpV4Filter2"] == string.Empty ? null : ConfigurationManager.AppSettings["IpV4Filter2"];
            var ip3                 = ConfigurationManager.AppSettings["IpV4Filter3"] == string.Empty ? null : ConfigurationManager.AppSettings["IpV4Filter3"];
            var ip4                 = ConfigurationManager.AppSettings["IpV4Filter4"] == string.Empty ? null : ConfigurationManager.AppSettings["IpV4Filter4"];
            var port                = ConfigurationManager.AppSettings["IpV4Port"] == string.Empty ? "6666" : ConfigurationManager.AppSettings["IpV4Port"];
            var pluginPath          = ConfigurationManager.AppSettings["PluginPath"] == string.Empty ? null : ConfigurationManager.AppSettings["PluginPath"];
            var msiFilePath         = ConfigurationManager.AppSettings["MsiFilePath"] == string.Empty ? null : ConfigurationManager.AppSettings["MsiFilePath"];
            var serverUrl           = ConfigurationManager.AppSettings["ServerUrl"] == string.Empty ? null : ConfigurationManager.AppSettings["ServerUrl"];
            var msiFileServerUrl    = ConfigurationManager.AppSettings["MsiFileServerUrl"] == string.Empty ? null : ConfigurationManager.AppSettings["MsiFileServerUrl"];
            var dllFileServerUrl    = ConfigurationManager.AppSettings["DllFileServerUrl"] == string.Empty ? null : ConfigurationManager.AppSettings["DllFileServerUrl"];
            var ConfgiFileServerUrl = ConfigurationManager.AppSettings["ConfigFileServerUrl"] == string.Empty ? null : ConfigurationManager.AppSettings["ConfigFileServerUrl"];
            //ConfigFileServerUrl
            var network = new Network.Network(new IpV4Filter()
            {
                Ip1 = ip1, Ip2 = ip2, Ip3 = ip3, Ip4 = ip4
            },
                                              new Models.Configs.HttpServerConfigs()
            {
                PluginPath          = pluginPath,
                MsiFilePath         = msiFilePath,
                Port                = port,
                ServerUrl           = serverUrl,
                MsiFileServerUrl    = msiFilePath,
                DllFileServerUrl    = dllFileServerUrl,
                ConfigFileServerUrl = ConfgiFileServerUrl
            });

            network.StartHttpServer();

            Console.ReadLine();
        }
Esempio n. 7
0
 public void Initialize(Logik.Player.Player p1, Logik.IBrettDarsteller bdar, Logik.Fields.Field field, Network.Network client)
 {
     this.client = client;
     if (p1.Symbol != 'X')
     {
         PlayerChange();
     }
 }
Esempio n. 8
0
 public void Initialize(Logik.Player.Player p1, Logik.IBrettDarsteller bdar, Logik.Fields.Field field, Network.Network client)
 {
     this.client = client;
     if (p1.Symbol != 'X')
     {
         PlayerChange();
     }
 }
Esempio n. 9
0
        public GizmoController(UIGizmo view, Network.Network network, IClientDataService dataService)
        {
            this.Gizmo       = view;
            this.Network     = network;
            this.DataService = dataService;

            Initialize();
        }
Esempio n. 10
0
 public void EndGame()
 {
     Graphics.GraphicsFacade.mode = GraphicsFacade.Mode.MENU;
     board = null;
     net = null;
     manager = null;
     players = null;
     scheduledEvents.Clear();
 }
Esempio n. 11
0
        public PersonPageController(UIPersonPage view, IClientDataService dataService, Network.Network network)
        {
            this.View        = view;
            this.DataService = dataService;
            this.Network     = network;
            Topic            = dataService.CreateTopicSubscription();

            Network.CityClient.AddSubscriber(this);
        }
Esempio n. 12
0
        public BookmarksController(UIBookmarks view, IClientDataService dataService, Network.Network network)
        {
            this.Network     = network;
            this.DataService = dataService;
            this.View        = view;
            this.Binding     = new Binding <Avatar>().WithMultiBinding(x => { RefreshResults(); }, "Avatar_BookmarksVec");

            Init();
        }
Esempio n. 13
0
 public LotAdmitController(UIAdmitBanPanel view, IClientDataService dataService, Network.Network network)
 {
     Network     = network;
     DataService = dataService;
     View        = view;
     Binding     = new Binding <Lot>().WithBinding(View, "Mode", "Lot_LotAdmitInfo.LotAdmitInfo_AdmitMode")
                   .WithMultiBinding(x => { RefreshResults(); }, "Lot_LotAdmitInfo.LotAdmitInfo_AdmitList", "Lot_LotAdmitInfo.LotAdmitInfo_BanList");
     Init();
 }
        public MessagingController(CoreGameScreenController game, UIMessageTray messageTray, Network.Network network, IClientDataService dataService)
        {
            this.Game = game;
            this.Tray = messageTray;
            this.Tray.SetController(this);
            this.Network     = network;
            this.DataService = dataService;

            this.Network.CityClient.AddSubscriber(this);
        }
        //private Binding<Avatar> Binding;

        public RelationshipDialogController(UIRelationshipDialog view, IClientDataService dataService, Network.Network network, IDatabaseService database)
        {
            Network         = network;
            DataService     = dataService;
            View            = view;
            DatabaseService = database;
            //this.Binding = new Binding<Avatar>().WithMultiBinding(x => { RefreshResults(); }, "Avatar_BookmarksVec");

            //Init();
        }
Esempio n. 16
0
        public void TestCreateBasicNetwork()
        {
            NetworkAPIDemo demo = new NetworkAPIDemo(NetworkAPIDemo.Mode.BASIC);

            Network.Network n = demo.CreateBasicNetwork();
            Assert.AreEqual(1, n.GetRegions().Count);
            Assert.IsNotNull(n.GetRegions().First().Lookup("Layer 2/3"));
            Assert.IsNull(n.GetRegions().First().Lookup("Layer 4"));
            Assert.IsNull(n.GetRegions().First().Lookup("Layer 5"));
        }
Esempio n. 17
0
        //private Binding<Avatar> Binding;

        public BulletinDialogController(UIBulletinDialog view, IClientDataService dataService, Network.Network network)
        {
            this.Network     = network;
            this.DataService = dataService;
            this.View        = view;
            //this.Binding = new Binding<Avatar>().WithMultiBinding(x => { RefreshResults(); }, "Avatar_BookmarksVec");

            this.Actions = UIScreen.Current.FindController <CoreGameScreenController>()?.BulletinProtocol;

            //Init();
        }
Esempio n. 18
0
        public RoommateRequestController(CoreGameScreenController game, Network.Network network, IClientDataService dataService)
        {
            this.Game        = game;
            this.Network     = network;
            this.DataService = dataService;

            this.Network.CityClient.AddSubscriber(this);

            Network.CityClient.Write(new ChangeRoommateRequest
            {
                Type = ChangeRoommateType.POLL, //we're ready to recieve any pending roommate requests
            });
        }
Esempio n. 19
0
        public void create_simple_network()
        {
            var network = new Network.Network();
            network.Layers = new List<ILayer>();
            var inputLayer = new Mock<ILayer>().Object;
            inputLayer.Type = LayerType.Input;
            var hiddenLayer = new Mock<ILayer>().Object;
            hiddenLayer.Type = LayerType.Hidden;
            var outputLayer = new Mock<ILayer>().Object;
            outputLayer.Type = LayerType.Output;

            network.AddLayer(inputLayer, hiddenLayer, outputLayer);

            network.Layers.Count.Should().Be.EqualTo(3);
        }
Esempio n. 20
0
        public void can_be_only_one_output_layer()
        {
            var network = new Network.Network();
            network.Layers = new List<ILayer>();
            var outputLayer1 = new Mock<ILayer>().Object;
            outputLayer1.Type = LayerType.Output;
            var outputLayer2 = new Mock<ILayer>().Object;
            outputLayer2.Type = LayerType.Output;

            network.AddLayer(outputLayer1, outputLayer2);

            Executing.This(network.StartTrain).Should().Throw();
            Executing.This(network.StartTrain).Should().Throw<ApplicationException>();
            Executing.This(network.StartTrain).Should().Throw<ApplicationException>()
                                        .Exception.Message.Should().Be.EqualTo("There can be only one input layer and one output");
        }
Esempio n. 21
0
        public CoreGameScreenController(CoreGameScreen view, Network.Network network, IClientDataService dataService, IKernel kernel, LotConnectionRegulator joinLotRegulator)
        {
            this.Screen           = view;
            this.Network          = network;
            this.DataService      = dataService;
            this.Chat             = new MessagingController(this, view.MessageTray, network, dataService);
            this.JoinLotRegulator = joinLotRegulator;
            this.RoommateProtocol = new RoommateRequestController(this, network, dataService);

            joinLotRegulator.OnTransition += JoinLotRegulator_OnTransition;

            var shard = Network.MyShard;

            Terrain = kernel.Get <TerrainController>(new ConstructorArgument("parent", this));
            view.Initialize(shard.Name, int.Parse(shard.Map), Terrain);
        }
Esempio n. 22
0
        public void Train(Network.Network network, List <double[]> x, List <double[]> y, double trainDataRatio)
        {
            var toBeTaken = (int)(x.Count * trainDataRatio);

            var trainX = x.Take(toBeTaken).ToList();
            var devX   = DenseMatrix.OfColumnArrays(x.Skip(toBeTaken));

            var trainY = y.Take(toBeTaken).ToList();
            var devY   = DenseMatrix.OfColumnArrays(y.Skip(toBeTaken));

            for (int i = 0; i < _epochs; i++)
            {
                _logger.Log($"Epoch {i:D4} started.");
                var(randomTrainX, randomTrainY) = Shuffler.Shuffle(_randomSeed, trainX, trainY);

                var trainXBatches = SplitList(randomTrainX, _minibatch).ToList();
                var trainYBatches = SplitList(randomTrainY, _minibatch).ToList();

                for (var j = 0; j < trainXBatches.Count; j++)
                {
                    var xBatch = trainXBatches[j];
                    var yBatch = trainYBatches[j];

                    var xBatchMatrix = DenseMatrix.OfColumnArrays(xBatch);
                    var yBatchMatrix = DenseMatrix.OfColumnArrays(yBatch);

                    var inBatchPred = network.Forward(xBatchMatrix);

                    if (j % 500 == 0 || j + 1 == trainXBatches.Count)
                    {
                        var inBatchmse       = _costFunction.Get(yBatchMatrix, inBatchPred).RowSums().Sum();
                        var inBatchprecision = Metrics.GetPrecision(yBatchMatrix, inBatchPred);
                        _logger.Log($"                   Batch: {j + 1:D4}/{trainXBatches.Count()}, #Samples: {xBatch.Count} Cost: {inBatchmse:F3}, Precision: {inBatchprecision:P0}");
                    }

                    Backward(network, yBatchMatrix);
                }

                var pred = network.Forward(devX);

                var mse       = _costFunction.Get(devY, pred).RowSums().Sum();
                var precision = Metrics.GetPrecision(devY, pred);

                _logger.Log($"Epoch {i:D4} finished: Cost: {mse:F3}, Precision: {precision:P0}");
                _logger.Log();
            }
        }
Esempio n. 23
0
        public PurchaseLotRegulator(Network.Network network)
        {
            Network = network;
            Network.CityClient.AddSubscriber(this);

            AddState("Idle").Transition().Default()
            .OnData(typeof(PurchaseLotRequest))
            .TransitionTo("StartPurchase");

            AddState("StartPurchase").OnlyTransitionFrom("Idle");
            AddState("SendPurchaseRequest").OnlyTransitionFrom("StartPurchase")
            .OnData(typeof(Server.Protocol.Electron.Packets.PurchaseLotResponse))
            .TransitionTo("ReceivedPurchaseResponse");

            AddState("ReceivedPurchaseResponse").OnlyTransitionFrom("SendPurchaseRequest");
            AddState("PurchaseComplete").OnlyTransitionFrom("ReceivedPurchaseResponse");
        }
Esempio n. 24
0
        public TerrainController(CoreGameScreenController parent, IClientDataService ds, Network.Network network, IRealestateDomain domain, PurchaseLotRegulator purchaseRegulator)
        {
            this.Parent            = parent;
            this.DataService       = ds;
            this.PurchaseRegulator = purchaseRegulator;
            Network = network;

            PurchaseRegulator.OnError      += PurchaseRegulator_OnError;
            PurchaseRegulator.OnTransition += PurchaseRegulator_OnTransition;
            PurchaseRegulator.OnPurchased  += PurchaseRegulator_OnPurchased;
            Realestate = domain.GetByShard(network.MyShard.Id);

            CurrentHoverLot = new Binding <Lot>()
                              .WithMultiBinding(RefreshTooltip, "Lot_Price", "Lot_IsOnline", "Lot_Name", "Lot_NumOccupants", "Lot_LeaderID");

            CurrentCity = new Binding <City>().WithMultiBinding(RefreshCity, "City_ReservedLotInfo", "City_SpotlightsVector");
        }
Esempio n. 25
0
        private void Backward(Network.Network network, DenseMatrix y)
        {
            var backwardLayers = GetBackwardLayers(network);

            var gradient = _costFunction.GetFirstDerivative(backwardLayers.First().Activation, y);

            foreach (var layer in backwardLayers)
            {
                var sp = layer.Z.Map(layer.ActivationFunction.GetFirstDerivative);

                var δ = gradient.PointwiseMultiply(sp);

                var δ_biases  = δ.RowSums();
                var δ_weights = (δ * layer.Input.Transpose());

                gradient = layer.Weights.Transpose() * δ;

                layer.Biases  -= _η * δ_biases;
                layer.Weights -= _η * δ_weights;
            }
        }
Esempio n. 26
0
        public AsyncResponse(JSONObject message, Network.Network network)
        {
            try
            {
                var type = message["type"].AsInt;
                if (type == 4 || type == 5)
                {
                    var receivers = new JSONArray();
                    receivers.Add(message["senderId"].AsInt);
                    _sendData.Add("receivers", receivers);
                    _sendData.Add("messageId", message["id"].AsInt);
                    _canSend = true;
                }
            }
            catch (Exception e)
            {
                Debug.LogError("Exception: " + e.Message);
            }

            this._network = network;
        }
Esempio n. 27
0
 /// <summary>
 /// This method is required for Windows Forms designer support.
 /// Do not change the method contents inside the source code editor. The Forms designer might
 /// not be able to load this method if it was changed manually.
 /// </summary>
 private void InitializeComponent()
 {
     this.calculatemenu = new System.Windows.Forms.Button();
     this.cryptomenu    = new System.Windows.Forms.Button();
     this.networkmenu   = new System.Windows.Forms.Button();
     this.network1      = new Network.Network();
     this.calculate1    = new Calculate.Calculate();
     this.crypto1       = new Crypto.Crypto();
     this.SuspendLayout();
     //
     // calculatemenu
     //
     this.calculatemenu.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
     this.calculatemenu.Location  = new System.Drawing.Point(15, 16);
     this.calculatemenu.Name      = "calculatemenu";
     this.calculatemenu.Size      = new System.Drawing.Size(87, 38);
     this.calculatemenu.TabIndex  = 0;
     this.calculatemenu.Text      = "Calculate";
     this.calculatemenu.UseVisualStyleBackColor = false;
     this.calculatemenu.Click += new System.EventHandler(this.CalculatemenuClick);
     //
     // cryptomenu
     //
     this.cryptomenu.BackColor = System.Drawing.Color.MintCream;
     this.cryptomenu.Location  = new System.Drawing.Point(124, 16);
     this.cryptomenu.Name      = "cryptomenu";
     this.cryptomenu.Size      = new System.Drawing.Size(87, 38);
     this.cryptomenu.TabIndex  = 2;
     this.cryptomenu.Text      = "Crypto";
     this.cryptomenu.UseVisualStyleBackColor = false;
     this.cryptomenu.Click += new System.EventHandler(this.CryptomenuClick);
     //
     // networkmenu
     //
     this.networkmenu.BackColor = System.Drawing.Color.PaleGoldenrod;
     this.networkmenu.Location  = new System.Drawing.Point(231, 16);
     this.networkmenu.Name      = "networkmenu";
     this.networkmenu.Size      = new System.Drawing.Size(87, 38);
     this.networkmenu.TabIndex  = 5;
     this.networkmenu.Text      = "Network";
     this.networkmenu.UseVisualStyleBackColor = false;
     this.networkmenu.Click += new System.EventHandler(this.NetworkmenuClick);
     //
     // network1
     //
     this.network1.BackColor = System.Drawing.Color.CadetBlue;
     this.network1.Location  = new System.Drawing.Point(26, 90);
     this.network1.Name      = "network1";
     this.network1.Size      = new System.Drawing.Size(813, 570);
     this.network1.TabIndex  = 7;
     //
     // calculate1
     //
     this.calculate1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
     this.calculate1.Location  = new System.Drawing.Point(26, 90);
     this.calculate1.Name      = "calculate1";
     this.calculate1.Size      = new System.Drawing.Size(813, 570);
     this.calculate1.TabIndex  = 8;
     //
     // crypto1
     //
     this.crypto1.BackColor = System.Drawing.Color.LightSalmon;
     this.crypto1.Location  = new System.Drawing.Point(26, 90);
     this.crypto1.Name      = "crypto1";
     this.crypto1.Size      = new System.Drawing.Size(813, 570);
     this.crypto1.TabIndex  = 9;
     //
     // MainForm
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.BackColor           = System.Drawing.Color.Bisque;
     this.ClientSize          = new System.Drawing.Size(867, 682);
     this.Controls.Add(this.crypto1);
     this.Controls.Add(this.calculate1);
     this.Controls.Add(this.network1);
     this.Controls.Add(this.networkmenu);
     this.Controls.Add(this.cryptomenu);
     this.Controls.Add(this.calculatemenu);
     this.Name = "MainForm";
     this.Text = "EucliwoodBox";
     this.ResumeLayout(false);
 }
Esempio n. 28
0
 public NetworkInfo(Network.Network net, object statsCollectors)
 {
     this.net            = net;
     this.statCollectors = statsCollectors;
 }
Esempio n. 29
0
 public void Initialize(Service service, Network.Network network, JSONObject matchData)
 {
     this._service = service;
     this._network = network;
     Init(matchData);
 }
 public RatingSummaryController(IUIAbstractRating view, IClientDataService dataService, Network.Network network)
 {
     this.Network     = network;
     this.DataService = dataService;
     this.View        = view;
 }
Esempio n. 31
0
 public SecureTradeController(IClientDataService dataService, Network.Network network)
 {
     this.Network     = network;
     this.DataService = dataService;
 }
Esempio n. 32
0
 public RatingListController(UIRatingList view, IClientDataService dataService, Network.Network network)
 {
     this.Network     = network;
     this.DataService = dataService;
     this.View        = view;
 }
        public DisconnectController(TransitionScreen view, CityConnectionRegulator cityRegulator, LotConnectionRegulator lotRegulator, LoginRegulator logRegulator, Network.Network network)
        {
            View = view;
            View.ShowProgress = false;

            network.LotClient.Disconnect();
            network.CityClient.Disconnect();
            CityConnectionRegulator = cityRegulator;
            CityConnectionRegulator.OnTransition += CityConnectionRegulator_OnTransition;
            LotConnectionRegulator       = lotRegulator;
            LoginRegulator               = logRegulator;
            LoginRegulator.OnError      += LoginRegulator_OnError;
            LoginRegulator.OnTransition += LoginRegulator_OnTransition;
        }
Esempio n. 34
0
 public MessagingWindowController(UIMessageWindow view, Network.Network network, IClientDataService dataService)
 {
     this.View        = view;
     this.Network     = network;
     this.DataService = dataService;
 }