Exemplo n.º 1
0
        public static NeuralNetwork CreateElmanNN(int inputCount, int outputCount)
        {
            NeuralNetwork network = new NeuralNetwork();
            Layer         input   = new Layer();
            Layer         output  = new Layer();

            for (int i = 0; i < inputCount; i++)
            {
                input.AddUnit(new NetworkUnit(ActFuncs.Identity));
            }
            for (int i = 0; i < outputCount; i++)
            {
                NetworkUnit memoryUnit = new NetworkUnit(ActFuncs.Identity);
                NetworkUnit biasUnit   = NetworkUnit.CreateBias();
                NetworkUnit outUnit    = new NetworkUnit(ActFuncs.Sigmoid, biasUnit)
                {
                    MemoryUnit = memoryUnit
                };
                input.AddUnit(memoryUnit);
                output.AddUnit(outUnit);
            }
            network.AddLayer(input);
            network.AddLayer(output);

            return(network);
        }
Exemplo n.º 2
0
    public void SendSync()
    {
        // From Server Only
        if (state.isServer == false)
        {
            return;
        }

        SyncUnits          syncData = new SyncUnits();
        List <NetworkUnit> netUnits = new List <NetworkUnit> ();

        // add all existing units to the list
        foreach (Transform gameUnits in state.gameUnits.transform)
        {
            if (gameUnits.name.Split('-') [0].Equals("GU"))
            {
                // get all the units in this GO
                foreach (Transform unit in gameUnits)
                {
                    var   networkUnit = new NetworkUnit();
                    short ownerID     = short.Parse(gameUnits.name.Split('-') [1]);
                    networkUnit.ownerID  = ownerID;
                    networkUnit.id       = unit.name;
                    networkUnit.unitType = unit.gameObject.GetComponent <UnitController> ().type;
                    netUnits.Add(networkUnit);
                }
            }
            else if (gameUnits.name.Split('-') [0].Equals("IO"))
            {
                foreach (Transform unit in gameUnits)
                {
                    if (unit.gameObject.GetComponent <FlagActions> () == null)
                    {
                        var   networkUnit = new NetworkUnit();
                        short ownerID     = short.Parse(gameUnits.name.Split('-') [1]);
                        networkUnit.ownerID  = ownerID;
                        networkUnit.id       = unit.name;
                        networkUnit.unitType = unit.gameObject.GetComponent <Interactable> ().type;
                        netUnits.Add(networkUnit);
                    }
                }
            }
        }

        syncData.units = netUnits.ToArray();
        // send the new unit to connections
        SendMessage(syncData);
    }
Exemplo n.º 3
0
    public static Player GetPlayer(this NetworkBehaviour nb)
    {
        NetworkUnit unit = nb.gameObject.GetComponent <NetworkUnit>();

        return(unit == null ? null : unit.player);
    }
Exemplo n.º 4
0
 public Minesweeper()
 {
     networkUnit = new NetworkUnit(this);
     blockMode   = false;
 }
Exemplo n.º 5
0
 public AbstractAgent(string initialGameIpAddress, int initialGamePort)
 {
     networkUnit          = new NetworkUnit(this);
     CurrentGameIpAddress = initialGameIpAddress;
     CurrentGamePort      = initialGamePort;
 }
Exemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     unit = this.GetComponent <NetworkUnit>();
 }