evador_behave Find_target(List <evador_behave> t)
    {
        int min_reward = 0;
        int reward;

        evador_behave target_now = null;

        foreach (evador_behave eb in t)
        {
            reward = 0;
            if ((int)previous_step[eb] >= current_step[eb])
            {
                reward         = -30 * rf_factor[eb];
                rf_factor[eb] += 1;
            }
            else
            {
                rf_factor[eb] = 1;
            }                                 //clear target threat;
            reward += Manhattan(current_node.grid_position, eb.current_node.grid_position);
            if (target_now == null)
            {
                target_now = eb;
                min_reward = reward;
            }
            else
            {
                target_now = reward < min_reward?eb:target_now;
            }
        }
        if (target_now)
        {
            target_now.SendMessage("flash_me");
        }
        return(target_now);
    }
    void Update()
    {
        //manually update the stages.
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Stage_switch();
        }

        switch (current_stage)
        {
        case stage.Player_moving:
            GameObject[] ev_instance = GameObject.FindGameObjectsWithTag("evador");
            if (ev_instance.Length == 0)
            {
                //NNprocessor.instance.update_weights(NNprocessor.instance.current_index,(float)score_evador);
                NNprocessor.instance.print_results();
                Application.LoadLevel(0);
            }
            GridsGenerator.instance.player_instance.SendMessage("move");
            return;

        case stage.Robot_moving:

            //this will be controlled all together
            //so I will change this one to a robot-controller.
            if (!stage_processed)
            {
                stage_processed = true;

                /*
                 * GameObject[] robot_instance=GameObject.FindGameObjectsWithTag("robot");
                 * foreach(GameObject rb in robot_instance)
                 * rb.SendMessage("guess_and_move");
                 *
                 * StartCoroutine("stage_yield");*/
                GameObject[]  evador_instance = GameObject.FindGameObjectsWithTag("evador");
                evador_behave target          = target_list[NNprocessor.instance.order_index[NNprocessor.instance.current_index][index_in_list]];
                if (!target)
                {
                    index_in_list++;
                }
                Robots_controller.instance.update_state(Robots_controller.robot_state.defeat, target);
                // Robots_controller.instance.update_state(Robots_controller.robot_state.cooperate);
                if (target)
                {
                    target.SendMessage("flash_me");
                }
            }
            return;

        case stage.Evador_moving:

            //Add more protection method for time-consumption for computing
            if (!stage_processed)
            {
                stage_processed = true;
                GameObject[] evador_instance = GameObject.FindGameObjectsWithTag("evador");
                foreach (GameObject ev in evador_instance)
                {
                    evador_behave eb = ev.GetComponent <evador_behave>();
                    if (cornered(eb))
                    {
                        Debug.Log("I am cornerd");
                        eb.SendMessage("explode", Color.red);
                        eb.current_node.occupied = false;
                        DestroyImmediate(eb.gameObject);
                    }
                }


                foreach (GameObject ev in evador_instance)
                {
                    if (ev)
                    {
                        ev.SendMessage("IQ2_move");
                    }
                }
                //modify this to change method

                StartCoroutine("stage_yield");
            }
            return;

        default:
            return;
        }
    }