Пример #1
0
 public Memory(string tag, ERespawn reason, Action.Kind solve, float score)
 {
     last_tag    = tag;
     this.reason = reason;
     this.solve  = solve;
     this.score  = score;
 }
Пример #2
0
        void IRespawn.OnRespawn(ERespawn reason)
        {
            Motor.active.stopAll();
            startEngine();

            if (Time.time < time_wait + last_solve_time) //SOLVE BAŞARISIZ
            {
                //if (last_solve != null)
                // {
                learn.Remove(last_solve);
                last_solve.score--;
                learn.Add(last_solve);
                sendEvent(1, last_solve);                           // EVET SENDER 1

                if (last_solve.score <= 0)
                {
                    Action.Kind[] solves = notTried(reason);
                    if (solves.Length != 0)
                    {
                        Memory newMem = new Memory(last_tag, reason, solves[0], 1);
                        learn.Add(newMem);
                        sendEvent(0, newMem);                           // EVET SENDER 0 _ YENİ SİNAPS
                    }
                    else
                    {
                        //ERespawn[] kinds = (ERespawn[])Enum.GetValues(typeof(Action.Kind));
                        Memory m = rememberByTag(last_tag);     // rememberLow(reason);
                        removeAllSolve(last_tag);
                        m.score++;
                        learn.Add(new Memory(last_tag, m.reason, Action.Kind.Ateş, 1));
                        sendEvent(0, m);                           // EVET SENDER 0 _ YENİ SİNAPS
                    }
                }
                //}
            }
            else // SOLVE BAŞARILI
            {
                if (Time.time < time_wait + last_time && last_tag != null)
                {
                    Action.Kind[] solves = notTried(reason);
                    if (solves.Length != 0)
                    {
                        Memory newMem = new Memory(last_tag, reason, solves[0], 1);
                        learn.Add(newMem);
                        sendEvent(0, newMem);                       // EVET SENDER 0 _ YENİ NEURON
                    }
                }
                else
                {
                }
            }


            //  if (Time.time < time_wait + last_time) Debug.Log("Object: "+ last_tag + " | Left Time: "+((time_wait + last_time)-Time.time)+" | Reason: "+reason.ToString() );
            //  else Debug.Log("Object: NuLL"  + " | Left Time: " + ((time_wait + last_time) - Time.time) + " | Reason: " + reason.ToString());
        }
Пример #3
0
        public Memory rememberLow(ERespawn reason)
        {
            Memory m = null;

            foreach (Memory mem in learn)
            {
                if (mem.reason == reason)
                {
                    m = mem;
                }
            }
            return(m);
        }
Пример #4
0
 public void Damage(float damage, ERespawn reason)
 {
     health -= damage;
     if (health <= 0)
     {
         health = 10;
         foreach (IRespawn res in listener)
         {
             res.OnRespawn(reason);
         }
         respawn();
         //Debug.Log(reason);
     }
 }
Пример #5
0
        public Memory rememberByReason(ERespawn reason)
        {
            Memory m     = null;
            float  score = 0f;

            foreach (Memory mem in learn)
            {
                if (mem.reason == reason)
                {
                    if (score < mem.score)
                    {
                        m = mem;
                    }
                }
            }
            return(m);
        }
Пример #6
0
        public Action.Kind[] notTried(ERespawn reason)
        {
            int size = Enum.GetNames(typeof(Action.Kind)).Length;

            int[] finded = new int[size];
            for (int i = 0; i < size; i++)
            {
                finded[i] = i;
            }
            foreach (Memory m in learn)
            {
                if (m.reason == reason)
                {
                    finded[(int)m.solve] = 0;
                }
            }
            int size_last = 0;

            foreach (int i in finded)
            {
                if (i != 0)
                {
                    size_last++;
                }
            }
            int[] newFinded = new int[size_last];
            int   count     = 0;

            for (int i = 0; i < finded.Length; i++)
            {
                if (finded[i] != 0)
                {
                    newFinded[count] = finded[i]; count++;
                }
            }
            Array en = Enum.GetValues(typeof(Action.Kind));

            Action.Kind[] last = new Action.Kind[size_last];
            for (int i = 0; i < last.Length; i++)
            {
                last[i] = (Action.Kind)en.GetValue(newFinded[i]);
            }
            return(last);
        }