示例#1
0
 public RowDataset8()
 {
     DatatypeSize = sizeof(byte);   // one byte
     data = new ObjList<Narray<byte>>();
     classes = new Intarray();
     nc = -1;
     nf = -1;
 }
示例#2
0
 public RowDataset8(int nsamples)
 {
     DatatypeSize = sizeof(byte);   // one byte
     data = new ObjList<Narray<byte>>();
     data.ReserveTo(nsamples);
     classes = new Intarray();
     classes.ReserveTo(nsamples);
     nc = -1;
     nf = -1;
 }
示例#3
0
 public void printObjsInObjList(ObjList list)
 {
     //int num = 0;
     //while (list != null)
     //{
     //    if (list.obj != null)
     //    ;
     //    list = list.next;
     //    ++num;
     //}
 }
示例#4
0
    public Obj FindObjByUID(Int32 uid)
    {
        ObjList objList = this._context.activeObj;

        while (objList != null && objList.obj.uid != uid)
        {
            objList = objList.next;
        }

        return(objList?.obj);
    }
示例#5
0
 private void printActorsInObjList(ObjList list)
 {
     //int num = 0;
     //while (list != null)
     //{
     //    if ((int)list.obj.cid != 4 || (Actor)list.obj != null)
     //    ;
     //    list = list.next;
     //    ++num;
     //}
 }
    public void Populate(PathQuery pq, Path pqr, float radius)
    {
        if (pqr.mover != null)
        {
            using var objlist = ObjList.ListRadius(pqr.from, locXY.INCH_PER_TILE * 40, ObjectListFilter.OLC_PATH_BLOCKER);
            foreach (var obj in objlist)
            {
                var objFlags = obj.GetFlags();
                var objType  = obj.type;
                if ((objFlags & (ObjectFlag.NO_BLOCK | ObjectFlag.DONTDRAW | ObjectFlag.OFF)) == 0)
                {
                    if (pq.flags.HasFlag(PathQueryFlags.PQF_DOORS_ARE_BLOCKING) || objType != ObjectType.portal)
                    {
                        if (objType.IsCritter())
                        {
                            if (pq.flags.HasFlag(PathQueryFlags.PQF_IGNORE_CRITTERS) ||
                                GameSystems.Critter.IsFriendly(obj, pqr.mover) ||
                                GameSystems.Critter.IsDeadOrUnconscious(obj))
                            {
                                continue;
                            }
                        }

                        if (!pq.flags.HasFlag(PathQueryFlags.PQF_AVOID_AOOS))
                        {
                            Append(obj);
                        }
                        else
                        {
                            var ignoreTarget = pq.critter.ShouldIgnoreTarget(obj);
                            if (!ignoreTarget)
                            {
                                if (obj.HasRangedWeaponEquipped())
                                {
                                    Append(obj);
                                }
                                else
                                {
                                    float objReach  = obj.GetReach();
                                    float objRadius = obj.GetRadius();
                                    Append(obj, objReach + objRadius);
                                }
                            }
                            else
                            {
                                Append(obj);
                            }
                        }
                    }
                }
            }
        }
    }
示例#7
0
    public static bool buff_npc(GameObject attachee, GameObject triggerer)
    {
        SetGlobalVar(761, GetGlobalVar(761) + 1);
        if ((GetGlobalVar(761) == 1))
        {
            attachee.CastSpell(WellKnownSpells.ShieldOfFaith, attachee);
            foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC))
            {
                if ((obj.GetNameId() == 14333 && obj.GetLeader() == null))
                {
                    obj.CastSpell(WellKnownSpells.MageArmor, obj);
                }

                if ((obj.GetNameId() == 14336 && obj.GetLeader() == null))
                {
                    obj.CastSpell(WellKnownSpells.ResistElements, obj);
                }
            }
        }

        if ((GetGlobalVar(761) == 2))
        {
            attachee.CastSpell(WellKnownSpells.OwlsWisdom, attachee);
            foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC))
            {
                if ((obj.GetNameId() == 14333 && obj.GetLeader() == null))
                {
                    obj.CastSpell(WellKnownSpells.MirrorImage, obj);
                }
            }
        }

        if ((GetGlobalVar(761) >= 3))
        {
            foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC))
            {
                if ((obj.GetNameId() == 14333 && obj.GetLeader() == null))
                {
                    obj.CastSpell(WellKnownSpells.Shield, obj);
                }
            }

            foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC))
            {
                if ((obj.GetNameId() == 14334 && obj.GetLeader() == null))
                {
                    attachee.CastSpell(WellKnownSpells.EndureElements, obj);
                }
            }
        }

        return(RunDefault);
    }
示例#8
0
    public static bool all_run_off(GameObject attachee, GameObject triggerer)
    {
        foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC))
        {
            if ((obj.GetLeader() == null && !((SelectedPartyLeader.GetPartyMembers()).Contains(obj))))
            {
                obj.RunOff();
            }
        }

        return(RunDefault);
    }
示例#9
0
    public override bool OnDying(GameObject attachee, GameObject triggerer)
    {
        StartTimer(86400000,
                   () => RemoveDead(PartyLeader, attachee)); // remove the familiar from the party in 24 hours
        // identify familiar dying and match to familiar inventory icon
        var familiar_proto = FindFamiliarInvType(attachee);

        if ((familiar_proto == 0))
        {
            return(SkipDefault); // not a valid familiar type
        }

        // search for familiar inventory icon in all PCs' inventory
        foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_CRITTERS))
        {
            var inv_familiar = obj.FindItemByProto(familiar_proto);
            if ((inv_familiar != null))
            {
                // check for correct ID number
                if ((get_ID(inv_familiar) == get_ID(attachee)))
                {
                    // destroys familiar in owner's inventory and removes experience from owner
                    inv_familiar.Destroy();
                    var curxp      = obj.GetStat(Stat.experience);
                    var ownerlevel = GetLevel(obj);
                    int xploss;
                    if ((!obj.SavingThrow(15, SavingThrowType.Fortitude, D20SavingThrowFlag.NONE, attachee)))
                    {
                        xploss = ownerlevel * 200;
                    }
                    else
                    {
                        xploss = ownerlevel * 100;
                    }

                    int newxp;
                    if ((curxp >= xploss))
                    {
                        newxp = curxp - xploss;
                    }
                    else
                    {
                        newxp = 0;
                    }

                    obj.SetBaseStat(Stat.experience, newxp);
                    return(SkipDefault);
                }
            }
        }

        return(RunDefault);
    }
示例#10
0
 private void EnterBattleEnd()
 {
     for (ObjList objList = this._context.activeObj; objList != null; objList = objList.next)
     {
         Obj obj = objList.obj;
         if (obj.uid != 0)
         {
             obj.state0 = obj.state;
             obj.state  = EventEngine.stateSuspend;
         }
     }
 }
示例#11
0
    public static void run_off(GameObject npc, GameObject pc)
    {
        foreach (var obj in ObjList.ListVicinity(npc.GetLocation(), ObjectListFilter.OLC_NPC))
        {
            if ((obj.GetLeader() == null && !((SelectedPartyLeader.GetPartyMembers()).Contains(obj))))
            {
                obj.RunOff();
            }
        }

        return;
    }
示例#12
0
 // Kill unfriendlies
 public static void kuf(int c_name)
 {
     foreach (var moshe in ObjList.ListVicinity(SelectedPartyLeader.GetLocation(), ObjectListFilter.OLC_NPC))
     {
         if ((moshe.GetReaction(PartyLeader) <= 0 || !moshe.IsFriendly(PartyLeader)) && (!((GameSystems.Party.PartyMembers).Contains(moshe.GetLeader())) && (moshe.GetObjectFlags() & ObjectFlag.DONTDRAW) == 0) && (moshe.GetNameId() == c_name || c_name == -1))
         {
             // moshe.critter_kill_by_effect()
             var damage_dice = Dice.Parse("50d50");
             moshe.Damage(PartyLeader, DamageType.Bludgeoning, damage_dice);
         }
     }
 }
示例#13
0
    public override bool OnUse(GameObject attachee, GameObject triggerer)
    {
        foreach (var npc in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC))
        {
            if ((npc.GetLeader() == null))
            {
                npc.Attack(triggerer);
            }
        }

        return(RunDefault);
    }
    public static bool get_sick(GameObject attachee, GameObject triggerer)
    {
        foreach (var obj in ObjList.ListVicinity(triggerer.GetLocation(), ObjectListFilter.OLC_PC))
        {
            obj.AddCondition("Poisoned", 15, 0);
            obj.AddCondition("Poisoned", 32, 0);
            obj.AddCondition("Poisoned", 18, 0);
            obj.AddCondition("Poisoned", 29, 0);
        }

        return(RunDefault);
    }
示例#15
0
    public static bool all_run_off(GameObject attachee, GameObject triggerer)
    {
        foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC))
        {
            if ((obj.GetLeader() == null))
            {
                obj.RunOff();
            }
        }

        return(RunDefault);
    }
示例#16
0
    public static void run_off(GameObject npc, GameObject pc)
    {
        foreach (var obj in ObjList.ListVicinity(npc.GetLocation(), ObjectListFilter.OLC_NPC))
        {
            if ((obj.GetLeader() == null))
            {
                obj.RunOff();
            }
        }

        return;
    }
示例#17
0
    public static GameObject find_container_near(GameObject obj, int name)
    {
        foreach (var container in ObjList.ListVicinity(obj.GetLocation(), ObjectListFilter.OLC_CONTAINER))
        {
            if ((container.GetNameId() == name))
            {
                return(container);
            }
        }

        return(null);
    }
示例#18
0
    public static GameObject find_npc_near(GameObject obj, int name)
    {
        foreach (var npc in ObjList.ListVicinity(obj.GetLocation(), ObjectListFilter.OLC_NPC))
        {
            if ((npc.GetNameId() == name))
            {
                return(npc);
            }
        }

        return(null);
    }
示例#19
0
    public override bool OnHeartbeat(GameObject attachee, GameObject triggerer)
    {
        if ((GetGlobalFlag(525) && !GetGlobalFlag(526)))
        {
            if ((GetGlobalFlag(527)))
            {
                foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC))
                {
                    if ((is_better_to_talk(attachee, obj)))
                    {
                        StartTimer(1500, () => wakefield_talk(attachee, triggerer));
                        SetGlobalFlag(526, true);
                    }
                }
            }
            else
            {
                foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC))
                {
                    if ((is_better_to_talk(attachee, obj)))
                    {
                        StartTimer(1500, () => suspicious_talk(attachee, triggerer));
                        SetGlobalFlag(526, true);
                    }
                }
            }
        }
        else if ((GetGlobalVar(501) == 3 && Utilities.find_npc_near(attachee, 14496) != null && !GetGlobalFlag(503)))
        {
            foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC))
            {
                if ((is_better_to_talk(attachee, obj)))
                {
                    StartTimer(1500, () => talkie_talkie(attachee, triggerer));
                    SetGlobalFlag(503, true);
                }
            }
        }
        else if ((!PartyLeader.HasReputation(52) && GetGlobalVar(505) == 2 && attachee.GetLeader() == null))
        {
            foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC))
            {
                if ((is_better_to_talk(attachee, obj)))
                {
                    StartTimer(1500, () => bad_news(attachee, triggerer));
                    SetGlobalVar(505, 3);
                }
            }
        }

        return(RunDefault);
    }
示例#20
0
    public Obj(Int32 sid, Int32 uid, Int32 size, Int32 stackn)
    {
        EventEngine instance = PersistenSingleton <EventEngine> .Instance;

        if (sid < 0 || sid >= instance.sSourceObjN)
        {
        }
        if (uid == 0)
        {
            uid = sid;
        }
        Obj obj = PersistenSingleton <EventEngine> .Instance.FindObjByUID(uid);

        if (obj != null)
        {
            PersistenSingleton <EventEngine> .Instance.DisposeObj(obj);
        }
        size = size + 3 >> 2;
        Int32 num = instance.sObjTable[sid].varn + 3 >> 2;

        this.AllocObj(size + num + stackn);
        this.Clear();
        ObjList freeObjList = instance.GetFreeObjList();

        instance.SetFreeObjList(freeObjList.next);
        ObjList activeObjTailList = instance.GetActiveObjTailList();
        ObjList activeObjList     = instance.GetActiveObjList();

        if (activeObjTailList != null)
        {
            activeObjTailList.next = freeObjList;
            instance.SetActiveObjTailList(freeObjList);
        }
        else
        {
            instance.SetActiveObjTailList(freeObjList);
            instance.SetActiveObjList(freeObjList);
        }
        freeObjList.next = (ObjList)null;
        freeObjList.obj  = this;
        this.sid         = (Byte)sid;
        this.uid         = (Byte)uid;
        this.cid         = 0;
        this.ebData      = instance.allObjsEBData[sid];
        this.ip          = instance.GetIP(sid, 0, this.ebData);
        this.vofs        = (Byte)size;
        this.sofs        = (Byte)(size + num);
        this.sn          = (Byte)stackn;
        this.state       = EventEngine.stateNew;
        this.winnum      = Byte.MaxValue;
        this.currentByte = this.ebData;
    }
示例#21
0
    // Start is called before the first frame update
    void Awake()
    {
        Terrain     = FindObjectOfType <Terrain>();
        terrainData = Terrain.terrainData;

        //todo Set In Outside File
        //json parser ***all data commeing from json file
        var confFile = FileFinder.Find(Application.streamingAssetsPath, "InitialScene" + ".json");  //todo Set In Outside File

        Debug.Log("Found file:" + confFile);
        var m_JsonString = File.ReadAllText(confFile);

        ObjectList = JsonUtility.FromJson <ObjList>(m_JsonString);

        var objListLen = ObjectList.Objects.Count;

        Debug.Log("Found " + objListLen.ToString() + " objects");


        foreach (var obj in ObjectList.Objects)

        {
            RaycastHit hit;

            Vector3 ShootRayFrom = new Vector3(obj.Position.x, 1000, obj.Position.z);
            Ray     ray          = new Ray(ShootRayFrom, Vector3.down);

            if (Physics.Raycast(ray, out hit, Mathf.Infinity))
            {
                GameObject go = Instantiate(Resources.Load(obj.Name) as GameObject);

                if (obj.Name == "BobCat")
                {
                    Target.ExaminedObjects = go.transform;
                    Target.Center();
                }

                go.name = obj.Id;

                go.transform.position   = new Vector3(obj.Position.x, hit.point.y + 0.3f, obj.Position.z);
                go.transform.rotation   = obj.Rotation;
                go.transform.localScale = obj.Scale;
                Debug.Log("The given " + obj.Name + " position point is here: " + go.transform.position);
            }
            else
            {
                Debug.LogError("The given " + obj.Name + " postion point is out of boundary, please try diffrent position ");
            }
        }

        // GenerateTerrain(Terrain, hm);// RAndom Terrain
    }
示例#22
0
    public static GameObject fpn(string name)
    {
        foreach (var pc in ObjList.ListVicinity(SelectedPartyLeader.GetLocation(), ObjectListFilter.OLC_PC))
        {
            var pcName = GameSystems.MapObject.GetDisplayName(pc);
            if (pcName.Contains(name, StringComparison.CurrentCultureIgnoreCase))
            {
                return(pc);
            }
        }

        return(null);
    }
示例#23
0
    public override bool OnTrap(TrapSprungEvent trap, GameObject triggerer)
    {
        AttachParticles(trap.Type.ParticleSystemId, trap.Object);
        foreach (var obj in ObjList.ListVicinity(triggerer.GetLocation(), ObjectListFilter.OLC_CRITTERS))
        {
            foreach (var dmg in trap.Type.Damage)
            {
                obj.Damage(trap.Object, dmg.Type, dmg.Dice);
            }
        }

        return(SkipDefault);
    }
示例#24
0
 public override void OnBeginRound(SpellPacketBody spell)
 {
     Logger.Info("Detect Evil OnBeginRound");
     // get all targets in a 90' cone, apply magical_aura particle systems
     foreach (var obj in ObjList.ListCone(spell.caster, ObjectListFilter.OLC_CRITTERS, spell.spellRange, -45, 90))
     {
         if ((obj.GetAlignment().IsEvil()))
         {
             // HTN - WIP! check "power"
             AttachParticles("sp-Detect Alignment Evil", obj);
         }
     }
 }
示例#25
0
    public static bool run_off(GameObject npc, GameObject pc)
    {
        SetQuestState(99, QuestState.Completed);
        foreach (var obj in ObjList.ListVicinity(npc.GetLocation(), ObjectListFilter.OLC_NPC))
        {
            if (obj.GetNameId() == 8090) // Amii
            {
                obj.RunOff();
            }
        }

        return(RunDefault);
    }
示例#26
0
 // Use this for initialization
 void Awake()
 {
     m_List           = GetComponent <ObjList>();
     m_SpwanedObjects = new Draggable[m_ListOfSpots.childCount];
     for (int i = 0; i < m_List.m_ListOfObjects.Count; i++)
     {
         if (m_List.m_ListOfObjects[i] == null)
         {
             Debug.LogError("One of the ListOfObjects items are null");
         }
     }
     m_LastSpwanTime = -m_TimeBetweenNewItems * 2;
 }
示例#27
0
 // Kill unfriendlies
 public static void kuf(string c_name)
 {
     foreach (var moshe in ObjList.ListVicinity(SelectedPartyLeader.GetLocation(), ObjectListFilter.OLC_NPC))
     {
         var name = GameSystems.MapObject.GetDisplayName(moshe);
         if ((moshe.GetReaction(PartyLeader) <= 0 || !moshe.IsFriendly(PartyLeader)) && (!((GameSystems.Party.PartyMembers).Contains(moshe.GetLeader())) && (moshe.GetObjectFlags() & ObjectFlag.DONTDRAW) == 0) && name.Contains(c_name, StringComparison.CurrentCultureIgnoreCase))
         {
             // moshe.critter_kill_by_effect()
             var damage_dice = Dice.Parse("50d50");
             moshe.Damage(PartyLeader, DamageType.Bludgeoning, damage_dice);
         }
     }
 }
示例#28
0
 /// <summary>
 /// 获取当前对象及当前对象的所有子对象
 /// </summary>
 /// <param name="father">当前对象</param>
 /// <param name="ObjList">用来存储当前对象及所有子对象的List</param>
 /// <returns>返回存储对象的List</returns>
 public static List <Transform> GetAllChildren(Transform father, List <Transform> ObjList)
 {
     if (ObjList == null)
     {
         ObjList = new List <Transform>();
     }
     ObjList.Add(father);
     foreach (Transform item in father)
     {
         GetAllChildren(item, ObjList);
     }
     return(ObjList);
 }
示例#29
0
    public static GameObject fcnc(int xx, int yy, int name)
    {
        // Find container near coordinate
        foreach (var container in ObjList.ListVicinity(new locXY(xx, yy), ObjectListFilter.OLC_CONTAINER))
        {
            if ((container.GetNameId() == name))
            {
                return(container);
            }
        }

        return(null);
    }
示例#30
0
    public static bool disappear(GameObject attachee, GameObject triggerer)
    {
        foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC))
        {
            if ((attachee.HasLineOfSight(obj)))
            {
                attachee.StealFrom(obj);
            }
        }

        attachee.SetObjectFlag(ObjectFlag.OFF);
        return(RunDefault);
    }
示例#31
0
    public static bool zuggtmoy_pillar_gone(GameObject zuggtmoy, GameObject pc)
    {
        foreach (var obj in ObjList.ListVicinity(zuggtmoy.GetLocation(), ObjectListFilter.OLC_SCENERY))
        {
            if ((obj.GetNameId() == 1619))
            {
                obj.SetObjectFlag(ObjectFlag.OFF);
                return(RunDefault);
            }
        }

        return(RunDefault);
    }
示例#32
0
    public override void OnBeginRound(SpellPacketBody spell)
    {
        Logger.Info("Acid Fog OnBeginRound");
        var damage_dice = Dice.Parse("2d6");

        foreach (var obj in ObjList.ListVicinity(spell.Targets[0].Object.GetLocation(), ObjectListFilter.OLC_NPC))
        {
            if ((spell.Targets[0].Object.DistanceTo(obj) <= 20))
            {
                obj.DealSpellDamage(spell.caster, DamageType.Acid, damage_dice, D20AttackPower.UNSPECIFIED, D20ActionType.CAST_SPELL, spell.spellId);
            }
        }
    }
示例#33
0
 public OcroFSTImpl(int max_size)
 {
     m_targets = new ObjList<Intarray>(max_size);
     m_inputs = new ObjList<Intarray>(max_size);
     m_outputs = new ObjList<Intarray>(max_size);
     m_costs = new ObjList<Floatarray>(max_size);
     m_heuristics = new Floatarray();
     accept_costs = new Floatarray(max_size);
     // init sub arrays
     if (max_size > 0)
     {
         for (int i = 0; i < max_size; i++)
         {
             m_targets[i] = new Intarray();
             m_inputs[i] = new Intarray();
             m_outputs[i] = new Intarray();
             m_costs[i] = new Floatarray();
         }
     }
     start = 0;
     flags = 0;
 }
示例#34
0
 private int DataMin(ObjList<Narray<byte>> data)
 {
     int min = byte.MaxValue;
     for (int io = 0; io < data.Length(); io++)
     {
         for (int n = 0; n < data[io].Length1d(); n++)
         {
             byte val = data[io].At1d(n);
             if (val >= min) continue;
             min = val;
         }
     }
     return min;
 }
示例#35
0
 private int DataMax(ObjList<Narray<byte>> data)
 {
     int max = byte.MinValue;
     for (int io = 0; io < data.Length(); io++)
     {
         for (int n = 0; n < data[io].Length1d(); n++)
         {
             byte val = data[io].At1d(n);
             if (val <= max) continue;
             max = val;
         }
     }
     return max;
 }
示例#36
0
        public virtual void TrainBatch(IDataset ds, IDataset ts)
        {
            Stopwatch sw = Stopwatch.StartNew();
            bool parallel = PGetb("parallel");
            float eta_init = PGetf("eta_init"); // 0.5
            float eta_varlog = PGetf("eta_varlog"); // 1.5
            float hidden_varlog = PGetf("hidden_varlog"); // 1.2
            int hidden_lo = PGeti("hidden_lo");
            int hidden_hi = PGeti("hidden_hi");
            int rounds = PGeti("rounds");
            int mlp_noopt = PGeti("noopt");
            int hidden_min = PGeti("hidden_min");
            int hidden_max = PGeti("hidden_max");
            CHECK_ARG(hidden_min > 1 && hidden_max < 1000000, "hidden_min > 1 && hidden_max < 1000000");
            CHECK_ARG(hidden_hi >= hidden_lo, "hidden_hi >= hidden_lo");
            CHECK_ARG(hidden_max >= hidden_min, "hidden_max >= hidden_min");
            CHECK_ARG(hidden_lo >= hidden_min && hidden_hi <= hidden_max, "hidden_lo >= hidden_min && hidden_hi <= hidden_max");
            int nn = PGeti("nensemble");
            ObjList<MlpClassifier> nets = new ObjList<MlpClassifier>();
            nets.Resize(nn);
            for (int i = 0; i < nn; i++)
                nets[i] = new MlpClassifier(i);
            Floatarray errs = new Floatarray(nn);
            Floatarray etas = new Floatarray(nn);
            Intarray index = new Intarray();
            float best = 1e30f;
            if (PExists("%error"))
                best = PGetf("%error");
            int nclasses = ds.nClasses();

            /*Floatarray v = new Floatarray();
            for (int i = 0; i < ds.nSamples(); i++)
            {
                ds.Input1d(v, i);
                CHECK_ARG(NarrayUtil.Min(v) > -100 && NarrayUtil.Max(v) < 100, "min(v)>-100 && max(v)<100");
            }*/
            CHECK_ARG(ds.nSamples() >= 10 && ds.nSamples() < 100000000, "ds.nSamples() >= 10 && ds.nSamples() < 100000000");

            for (int i = 0; i < nn; i++)
            {
                // nets(i).init(data.dim(1),logspace(i,nn,hidden_lo,hidden_hi),nclasses);
                if (w1.Length() > 0)
                {
                    nets[i].Copy(this);
                    etas[i] = ClassifierUtil.rLogNormal(eta_init, eta_varlog);
                }
                else
                {
                    nets[i].InitData(ds, (int)(logspace(i, nn, hidden_lo, hidden_hi)), c2i, i2c);
                    etas[i] = PGetf("eta");
                }
            }
            etas[0] = PGetf("eta");     // zero position is identical to itself

            Global.Debugf("info", "mlp training n {0} nc {1}", ds.nSamples(), nclasses);
            for (int round = 0; round < rounds; round++)
            {
                Stopwatch swRound = Stopwatch.StartNew();
                errs.Fill(-1);
                if (parallel)
                {
                    // For each network i
                    Parallel.For(0, nn, i =>
                    {
                        nets[i].PSet("eta", etas[i]);
                        nets[i].TrainDense(ds);     // было XTrain
                        errs[i] = ClassifierUtil.estimate_errors(nets[i], ts);
                    });
                }
                else
                {
                    for (int i = 0; i < nn; i++)
                    {
                        nets[i].PSet("eta", etas[i]);
                        nets[i].TrainDense(ds);     // было XTrain
                        errs[i] = ClassifierUtil.estimate_errors(nets[i], ts);
                        //Global.Debugf("detail", "net({0}) {1} {2} {3}", i,
                        //       errs[i], nets[i].Complexity(), etas[i]);
                    }
                }
                NarrayUtil.Quicksort(index, errs);
                if (errs[index[0]] < best)
                {
                    best = errs[index[0]];
                    cv_error = best;
                    this.Copy(nets[index[0]]);
                    this.PSet("eta", etas[index[0]]);
                    Global.Debugf("info", "  best mlp[{0}] update errors={1} {2}", index[0], best, crossvalidate ? "cv" : "");
                }
                if (mlp_noopt == 0)
                {
                    for (int i = 0; i < nn / 2; i++)
                    {
                        int j = i + nn / 2;
                        nets[index[j]].Copy(nets[index[i]]);
                        int n = nets[index[j]].nHidden();
                        int nm = Math.Min(Math.Max(hidden_min, (int)(ClassifierUtil.rLogNormal(n, hidden_varlog))), hidden_max);
                        nets[index[j]].ChangeHidden(nm);
                        etas[index[j]] = ClassifierUtil.rLogNormal(etas[index[i]], eta_varlog);
                    }
                }
                Global.Debugf("info", " end mlp round {0} err {1} nHidden {2}", round, best, nHidden());
                swRound.Stop();
                int totalTest= ts.nSamples();
                int errCnt = Convert.ToInt32(best * totalTest);
                OnTrainRound(this, new TrainEventArgs(
                    round, best, totalTest - errCnt, totalTest, best, swRound.Elapsed, TimeSpan.Zero
                    ));
            }

            sw.Stop();
            Global.Debugf("info", String.Format("          training time: {0} minutes, {1} seconds",
                (int)sw.Elapsed.TotalMinutes, sw.Elapsed.Seconds));
            PSet("%error", best);
            int nsamples = ds.nSamples() * rounds;
            if (PExists("%nsamples"))
                nsamples += PGeti("%nsamples");
            PSet("%nsamples", nsamples);
        }