コード例 #1
0
        public bool CanIGoThere()
        {
            Vector v  = SetFirstField();
            Vector v1 = new Vector();
            Vector v2 = new Vector();
            Vector u  = new Vector();
            int    i  = 4;

            u.x = positionAPCBig.x + i * (v.y - positionAPC.y); //prehozeny direction
            u.y = positionAPCBig.y + i * (v.x - positionAPC.x); //prehozeny direction
            v1  = FixIndexesForTurning(u);
            i   = 1;
            u.x = positionAPCBig.x + i * (v.y - positionAPC.y); //prehozeny direction
            u.y = positionAPCBig.y + i * (v.x - positionAPC.x); //prehozeny direction
            v2  = FixIndexesForTurning(u);

            WindowOfGame.Log("My values: " + positionAPCBig.x + ", " + positionAPCBig.y);
            if (WindowOfGame.GetApcMapBig().GetFieldValue((int)v1.x, (int)v1.y) == 1 || WindowOfGame.GetApcMapBig().GetFieldValue((int)v2.x, (int)v2.y) == 1)
            {
                WindowOfGame.Log("false");
                return(false);
            }

            return(true);
        }
コード例 #2
0
        private void FindNextStepAI()
        {
            MapAPC    map    = WindowOfGame.GetApcMap();
            MapAPCBig mapBig = WindowOfGame.GetApcMapBig();

            GetInputReady(map, mapBig);
            so.SetSoftmaxOutput(neurons[0].W.Length, neurons);

            /*
             * pouze pokud chci trenovat neurnovou sit:
             * TrainingCounter++;
             * if (TrainingCounter%5 == 0)
             * {
             *  TrainWs(so.GetDeltaWs());
             * }*/

            if (!CanIGoThereRunning)
            {
                CanIGoThereRunning = true;
                WindowOfGame.Log("FindNextStepAI, can i go there?");

                if (!CanIGoThere())
                {
                    WindowOfGame.Log("FindNextStepAI, i cant go there");
                    if (!CanIGoToRight())
                    {
                        TurningState = 1;
                    }
                    else
                    {
                        TurningState = -1;
                    }
                    TurningCounter = 10;
                }
                else
                {
                    switch (so.GetTheHighestOutput())
                    {
                    case 0:     //nonturning, puvodne "hodne doleva"
                        TurningState   = 0;
                        TurningCounter = 5;
                        break;

                    case 1:    //nonturning, puvodne "stredne doleva"
                        TurningState   = 0;
                        TurningCounter = 5;
                        break;

                    case 2:    //short left
                        TurningState   = -1;
                        TurningCounter = 4;
                        break;

                    case 3:    //nonturning
                        TurningState   = 0;
                        TurningCounter = 5;
                        break;

                    case 4:    //short right
                        TurningState   = 1;
                        TurningCounter = 4;
                        break;

                    case 5:    //nonturning, puvodne "stredne doprava"
                        TurningState   = 0;
                        TurningCounter = 5;
                        break;

                    case 6:    //nonturning, puvodne "hodne doprava"
                        TurningState   = 0;
                        TurningCounter = 5;
                        break;
                    }
                }
            }
            recalculationRunning = false;
            CanIGoThereRunning   = false;
        }