예제 #1
0
파일: Dessinateur.cs 프로젝트: Omybot/GoBot
        public static void Start()
        {
            PositionCurseur = new RealPoint();

            _linkDisplay      = ThreadManager.CreateThread(link => DisplayLoop());
            _linkDisplay.Name = "Affichage de la table";
            _linkDisplay.StartThread();
        }
예제 #2
0
        private void DoFingersGrab()
        {
            ThreadLink left  = ThreadManager.CreateThread(link => Actionneur.FingerLeft.DoGrabColor(Buoy.Red));
            ThreadLink right = ThreadManager.CreateThread(link => Actionneur.FingerRight.DoGrabColor(Buoy.Green));

            left.StartThread();
            right.StartThread();

            left.WaitEnd();
            right.WaitEnd();
        }
예제 #3
0
        private void DoElevatorsDropoff(int level)
        {
            Color colorLeft = Color.Transparent, colorRight = Color.Transparent;
            bool  okColorLeft, okColorRight;

            ThreadLink left  = ThreadManager.CreateThread(link => colorLeft = Actionneur.ElevatorLeft.DoSequenceDropOff());
            ThreadLink right = ThreadManager.CreateThread(link => colorRight = Actionneur.ElevatorRight.DoSequenceDropOff());

            while (_zone.LoadsOnGreen < 4 && _zone.LoadsOnRed < 4 && Actionneur.ElevatorLeft.CountTotal > 0 && Actionneur.ElevatorRight.CountTotal > 0)
            {
                left.StartThread();
                right.StartThread();

                left.WaitEnd();
                right.WaitEnd();

                if (colorLeft != Color.Transparent)
                {
                    _zone.SetBuoyOnRed(colorLeft, level);
                    okColorLeft      = (colorLeft == Buoy.Red);
                    GameBoard.Score += (1 + (okColorLeft ? 1 : 0));
                }
                else
                {
                    okColorLeft = false;
                }

                if (colorRight != Color.Transparent)
                {
                    _zone.SetBuoyOnGreen(colorRight, level);
                    okColorRight     = (colorRight == Buoy.Green);
                    GameBoard.Score += (1 + (okColorRight ? 1 : 0));
                }
                else
                {
                    okColorRight = false;
                }

                if (okColorLeft && okColorRight)
                {
                    GameBoard.Score += 2;
                }

                level++;

                Robot.Move(-85);
            }

            // Pour ranger à la fin :
            Actionneur.ElevatorLeft.DoPushInsideFast();
            Actionneur.ElevatorRight.DoPushInsideFast();
        }
예제 #4
0
 private void switchBouton_ValueChanged(object sender, bool value)
 {
     if (value)
     {
         trackBar.Min = _currentPositionnable.Minimum;
         trackBar.Max = _currentPositionnable.Maximum;
         _linkPolling = ThreadManager.CreateThread(link => PollingLoop());
         _linkPolling.StartThread();
     }
     else
     {
         _linkPolling.Cancel();
     }
 }
예제 #5
0
 private void btnFingerRight_Click(object sender, EventArgs e)
 {
     if (_linkFingerRight == null)
     {
         _linkFingerRight = Threading.ThreadManager.CreateThread(link => Actionneurs.Actionneur.FingerRight.DoDemoGrab(link));
         _linkFingerRight.StartThread();
     }
     else
     {
         _linkFingerRight.Cancel();
         _linkFingerRight.WaitEnd();
         _linkFingerRight = null;
     }
 }
예제 #6
0
파일: Strategy.cs 프로젝트: Omybot/GoBot
        /// <summary>
        /// Execute le match
        /// </summary>
        public void ExecuteMatch()
        {
            Robots.MainRobot.Historique.Log("DEBUT DU MATCH", TypeLog.Strat);

            StartingDateTime = DateTime.Now;

            GameBoard.StartMatch();

            endMatchTimer          = new System.Timers.Timer();
            endMatchTimer.Elapsed += new ElapsedEventHandler(endMatchTimer_Elapsed);
            endMatchTimer.Interval = MatchDuration.TotalMilliseconds;
            endMatchTimer.Start();

            _linkMatch = ThreadManager.CreateThread(link => Execute());
            _linkMatch.StartThread();
        }
예제 #7
0
파일: PathFinder.cs 프로젝트: Omybot/GoBot
        public static Trajectory ChercheTrajectoire(Graph graph, IEnumerable <IShape> obstacles, IEnumerable <IShape> opponents, Position startPos, Position endPos, double rayonSecurite, double distanceSecuriteCote)
        {
            Stopwatch sw        = Stopwatch.StartNew();
            bool      pathFound = false;

            Trajectory output = DirectTrajectory(obstacles.Concat(opponents), startPos, endPos, rayonSecurite);

            if (output != null)
            {
                pathFound = true;
            }
            else
            {
                _linkResetRadius = null;

                double distance;
                bool   raccordable = false;

                output            = new Trajectory();
                output.StartAngle = startPos.Angle;
                output.EndAngle   = endPos.Angle;

                PointsTrouves = new List <RealPoint>();
                PointsTrouves.Add(new RealPoint(startPos.Coordinates));
                output.AddPoint(new RealPoint(startPos.Coordinates));

                lock (graph)
                {
                    Console.WriteLine("Cherche trajectoire début");
                    int nbPointsDepart  = 0;
                    int nbPointsArrivee = 0;

                    Node debutNode = null, finNode = null;
                    Node nodeProche = graph.ClosestNode(startPos.Coordinates, out distance);
                    if (distance != 0)
                    {
                        debutNode      = new Node(startPos.Coordinates);
                        nbPointsDepart = graph.AddNode(debutNode, obstacles, rayonSecurite);
                    }
                    else
                    {
                        debutNode      = nodeProche;
                        nbPointsDepart = debutNode.OutgoingArcs.Count;
                    }

                    //TODO2018 phase d'approche finale pourrie, l'angle final peut se faire à la fin au lieu de à la fin du path finding avant l'approche finale
                    if (nbPointsDepart == 0)
                    {
                        // On ne peut pas partir de là où on est

                        Position positionTestee = new Position(startPos);
                        bool     franchissable  = true;

                        // Boucle jusqu'à trouver un point qui se connecte au graph jusqu'à 1m devant
                        int i;
                        for (i = 0; i < 100 && !raccordable; i += 1)
                        {
                            positionTestee.Move(10);

                            debutNode   = new Node(positionTestee.Coordinates);
                            raccordable = graph.Raccordable(debutNode, obstacles, rayonSecurite);
                        }

                        // Le point à i*10 mm devant nous est reliable au graph, on cherche à l'atteindre
                        if (raccordable)
                        {
                            Segment segmentTest = new Segment(new RealPoint(positionTestee.Coordinates), new RealPoint(startPos.Coordinates));

                            // Test des obstacles

                            foreach (IShape obstacle in obstacles)
                            {
                                if (obstacle.Distance(segmentTest) < distanceSecuriteCote)
                                {
                                    franchissable = false;

                                    // Si l'obstacle génant est un adversaire, on diminue petit à petit son rayon pour pouvoir s'échapper au bout d'un moment
                                    if (opponents.Contains(obstacle) && GameBoard.OpponentRadius > 50)
                                    {
                                        Robots.MainRobot.Historique.Log("Adversaire au contact, impossible de s'enfuir, réduction du périmètre adverse", TypeLog.PathFinding);
                                        GameBoard.OpponentRadius -= 10;
                                        _linkResetRadius?.Cancel();
                                    }
                                }
                            }

                            // Si le semgent entre notre position et le graph relié au graph est parcourable on y va !
                            if (franchissable)
                            {
                                PointsTrouves.Add(new RealPoint(positionTestee.Coordinates));
                                output.AddPoint(new RealPoint(positionTestee.Coordinates));

                                debutNode      = new Node(positionTestee.Coordinates);
                                nbPointsDepart = graph.AddNode(debutNode, obstacles, rayonSecurite);
                            }
                        }
                        else
                        {
                            franchissable = false;
                        }

                        // Si toujours pas, on teste en marche arrière
                        if (!franchissable)
                        {
                            franchissable  = true;
                            raccordable    = false;
                            nbPointsDepart = 0;
                            positionTestee = new Position(startPos);
                            for (i = 0; i > -100 && !raccordable; i--)
                            {
                                positionTestee.Move(-10);

                                debutNode   = new Node(positionTestee.Coordinates);
                                raccordable = graph.Raccordable(debutNode, obstacles, rayonSecurite);
                            }

                            // Le point à i*10 mm derrière nous est reliable au graph, on cherche à l'atteindre
                            if (raccordable)
                            {
                                Segment segmentTest = new Segment(new RealPoint(positionTestee.Coordinates), new RealPoint(startPos.Coordinates));

                                // Test des obstacles
                                foreach (IShape obstacle in obstacles)
                                {
                                    if (obstacle.Distance(segmentTest) < distanceSecuriteCote)
                                    {
                                        franchissable = false;

                                        // Si l'obstacle génant est un adversaire, on diminue petit à petit son rayon pour pouvoir s'échapper au bout d'un moment
                                        if (opponents.Contains(obstacle) && GameBoard.OpponentRadius > 50)
                                        {
                                            Robots.MainRobot.Historique.Log("Adversaire au contact, impossible de s'enfuir, réduction du périmètre adverse", TypeLog.PathFinding);
                                            GameBoard.OpponentRadius -= 10;
                                            _linkResetRadius?.Cancel();
                                        }
                                    }
                                }

                                // Si le semgent entre notre position et le graph relié au graph est parcourable on y va !
                                if (franchissable)
                                {
                                    PointsTrouves.Add(new RealPoint(positionTestee.Coordinates));
                                    output.AddPoint(new RealPoint(positionTestee.Coordinates));

                                    debutNode      = new Node(positionTestee.Coordinates);
                                    nbPointsDepart = graph.AddNode(debutNode, obstacles, rayonSecurite);
                                }
                            }
                        }
                    }

                    if (nbPointsDepart > 0)
                    {
                        finNode = graph.ClosestNode(endPos.Coordinates, out distance);
                        if (distance != 0)
                        {
                            finNode         = new Node(endPos.Coordinates);
                            nbPointsArrivee = graph.AddNode(finNode, obstacles, rayonSecurite);
                        }
                        else
                        {
                            nbPointsArrivee = 1;
                        }
                        if (nbPointsArrivee == 0)
                        {
                            Console.WriteLine("Blocage arrivée");
                            // On ne peut pas arriver là où on souhaite aller
                            // On teste si on peut faire une approche en ligne
                            // teta ne doit pas être nul sinon c'est qu'on ne maitrise pas l'angle d'arrivée et on ne connait pas l'angle d'approche

                            Position positionTestee = new Position(endPos);
                            bool     franchissable  = true;
                            raccordable = false;

                            // Boucle jusqu'à trouver un point qui se connecte au graph jusqu'à 1m devant
                            int i;
                            for (i = 0; i < 100 && !raccordable; i++)
                            {
                                positionTestee.Move(10);
                                raccordable = graph.Raccordable(new Node(positionTestee.Coordinates), obstacles, rayonSecurite);
                            }

                            // Le point à i*10 mm devant nous est reliable au graph, on cherche à l'atteindre
                            if (raccordable)
                            {
                                Segment segmentTest = new Segment(new RealPoint(positionTestee.Coordinates), new RealPoint(endPos.Coordinates));

                                // Test des obstacles
                                foreach (IShape obstacle in obstacles)
                                {
                                    if (obstacle.Distance(segmentTest) < distanceSecuriteCote)
                                    {
                                        franchissable = false;
                                    }
                                }
                            }
                            else
                            {
                                franchissable = false;
                            }

                            // Si toujours pas, on teste en marche arrière
                            if (!franchissable)
                            {
                                positionTestee  = new Position(endPos);
                                nbPointsArrivee = 0;

                                for (i = 0; i > -100 && !raccordable; i--)
                                {
                                    positionTestee.Move(-10);
                                    raccordable = graph.Raccordable(new Node(positionTestee.Coordinates), obstacles, rayonSecurite);
                                }

                                if (raccordable)
                                {
                                    franchissable = true;
                                    Segment segmentTest = new Segment(new RealPoint(positionTestee.Coordinates), new RealPoint(endPos.Coordinates));

                                    // Test des obstacles
                                    foreach (IShape obstacle in obstacles)
                                    {
                                        if (obstacle.Distance(segmentTest) < distanceSecuriteCote)
                                        {
                                            franchissable = false;
                                        }
                                    }
                                }
                            }

                            // Si le semgent entre notre position et le node relié au graph est parcourable on y va !
                            if (franchissable)
                            {
                                finNode         = new Node(positionTestee.Coordinates);
                                nbPointsArrivee = graph.AddNode(finNode, obstacles, rayonSecurite);
                            }
                        }
                    }

                    if (nbPointsDepart > 0 && nbPointsArrivee > 0)
                    {
                        // Teste s'il est possible d'aller directement à la fin sans passer par le graph
                        bool    toutDroit = true;
                        Segment segment   = new Segment(debutNode.Position, finNode.Position);

                        foreach (IShape forme in obstacles)
                        {
                            if (segment.Distance(forme) < rayonSecurite)
                            {
                                toutDroit = false;
                                break;
                            }
                        }

                        if (toutDroit)
                        {
                            Robots.MainRobot.Historique.Log("Chemin trouvé : ligne droite", TypeLog.PathFinding);
                            pathFound = true;

                            PointsTrouves.Add(finNode.Position);
                            output.AddPoint(finNode.Position);
                            if (endPos.Coordinates.Distance(finNode.Position) > 1)
                            {
                                PointsTrouves.Add(new RealPoint(endPos.Coordinates));
                                output.AddPoint(new RealPoint(endPos.Coordinates));
                            }
                        }

                        // Sinon on passe par le graph
                        else
                        {
                            AStar aStar = new AStar(graph);
                            aStar.DijkstraHeuristicBalance = 0;

                            //Console.WriteLine("Avant pathFinding : " + (DateTime.Now - debut).TotalMilliseconds + "ms");

                            if (aStar.SearchPath(debutNode, finNode))
                            {
                                //Console.WriteLine("PathFinding trouvé : " + (DateTime.Now - debut).TotalMilliseconds + "ms");

                                List <Node> nodes = aStar.PathByNodes.ToList <Node>();

                                Robots.MainRobot.Historique.Log("Chemin trouvé : " + (nodes.Count - 2) + " noeud(s) intermédiaire(s)", TypeLog.PathFinding);

                                CheminEnCoursNoeuds = new List <Node>();
                                CheminEnCoursArcs   = new List <Arc>();

                                //Console.WriteLine("Début simplification : " + (DateTime.Now - debut).TotalMilliseconds + "ms");

                                // Simplification du chemin
                                // On part du début et on essaie d'aller au point du plus éloigné au moins éloigné en testant si le passage est possible
                                // Si c'est possible on zappe tous les points entre les deux
                                for (int iNodeDepart = 0; iNodeDepart < nodes.Count - 1; iNodeDepart++)
                                {
                                    if (iNodeDepart != 0)
                                    {
                                        PointsTrouves.Add(nodes[iNodeDepart].Position);
                                        output.AddPoint(nodes[iNodeDepart].Position);
                                    }

                                    CheminEnCoursNoeuds.Add(nodes[iNodeDepart]);

                                    bool raccourciPossible = true;
                                    for (int iNodeArrivee = nodes.Count - 1; iNodeArrivee > iNodeDepart; iNodeArrivee--)
                                    {
                                        raccourciPossible = true;

                                        Segment racourci = new Segment(nodes[iNodeDepart].Position, nodes[iNodeArrivee].Position);
                                        //Arc arcRacourci = new Arc(nodes[iNodeDepart], nodes[iNodeArrivee]);
                                        CheminTest = racourci;
                                        //arcRacourci.Passable = false;

                                        for (int i = obstacles.Count() - 1; i >= 4; i--) // > 4 pour ne pas tester les bordures
                                        {
                                            IShape forme = obstacles.ElementAt(i);
                                            ObstacleTeste    = forme;
                                            ObstacleProbleme = null;

                                            if (racourci.Distance(forme) < rayonSecurite)
                                            {
                                                ObstacleProbleme = forme;

                                                raccourciPossible = false;
                                                break;
                                            }
                                            //else if(Config.CurrentConfig.AfficheDetailTraj > 0)
                                            //    Thread.Sleep(Config.CurrentConfig.AfficheDetailTraj);
                                        }

                                        if (Config.CurrentConfig.AfficheDetailTraj > 0)
                                        {
                                            Thread.Sleep(Config.CurrentConfig.AfficheDetailTraj);
                                        }

                                        ObstacleTeste = null;

                                        if (raccourciPossible)
                                        {
                                            //CheminEnCoursArcs.Add(arcRacourci);
                                            iNodeDepart = iNodeArrivee - 1;
                                            break;
                                        }
                                    }
                                    CheminTest = null;
                                    if (!raccourciPossible)
                                    {
                                        //Arc arc = new Arc(nodes[iNodeDepart], nodes[iNodeDepart + 1]);
                                        //CheminEnCoursArcs.Add(arc);
                                    }
                                }

                                CheminEnCoursNoeuds.Add(nodes[nodes.Count - 1]);
                                PointsTrouves.Add(nodes[nodes.Count - 1].Position);
                                output.AddPoint(nodes[nodes.Count - 1].Position);
                                Robots.MainRobot.Historique.Log("Chemin optimisé : " + (CheminEnCoursNoeuds.Count - 2) + " noeud(s) intermédiaire(s)", TypeLog.PathFinding);
                                pathFound = true;

                                if (endPos.Coordinates.Distance(finNode.Position) > 1)
                                {
                                    PointsTrouves.Add(new RealPoint(endPos.Coordinates));
                                    output.AddPoint(new RealPoint(endPos.Coordinates));
                                }
                            }
                            else
                            {
                                CheminEnCoursNoeuds = null;
                                CheminEnCoursArcs   = null;
                                pathFound           = false;
                            }
                        }
                    }

                    graph.CleanNodesArcsAdd();
                }
            }

            Dessinateur.CurrentTrack = null;
            //CheminEnCoursNoeuds = null;

            Console.WriteLine("Cherche trajectoire fin : " + sw.ElapsedMilliseconds + "ms");

            PointsTrouves    = null;
            ObstacleProbleme = null;
            ObstacleTeste    = null;

            //Console.WriteLine("PathFinding en " + (DateTime.Now - debut).TotalMilliseconds + " ms");

            if (!pathFound)
            {
                Robots.MainRobot.Historique.Log("Chemin non trouvé", TypeLog.PathFinding);
                return(null);
            }
            else
            {
                if (GameBoard.OpponentRadius < GameBoard.OpponentRadiusInitial)
                {
                    _linkResetRadius = ThreadManager.CreateThread(link => ResetOpponentRadiusLoop());
                    _linkResetRadius.StartThread();
                }

                if (output.Lines.Count > 1)
                {
                    output = ReduceLines(output, obstacles.Concat(opponents), rayonSecurite);
                }

                return(output);
            }
        }
예제 #8
0
        protected override void SequenceBegin()
        {
            // TODOEACHYEAR Actions fixes au lancement du match

            Robot robot = Robots.MainRobot;

            fixedMovements = new List <Movement>();

            // Ajouter les points fixes au score (non forfait, elements posés etc)
            int initScore = 0;

            initScore      += 2;  // Phare posé
            initScore      += 15; // 2 manches à air
            GameBoard.Score = initScore;

            // Sortir ICI de la zonde de départ
            robot.UpdateGraph(GameBoard.ObstaclesAll);

            // codé en bleu avec miroir
            Elevator left  = GameBoard.MyColor == GameBoard.ColorLeftBlue ? (Elevator)Actionneur.ElevatorLeft : Actionneur.ElevatorRight;
            Elevator right = GameBoard.MyColor == GameBoard.ColorLeftBlue ? (Elevator)Actionneur.ElevatorRight : Actionneur.ElevatorLeft;

            ThreadManager.CreateThread(link =>
            {
                left.DoGrabOpen();
                Thread.Sleep(750);
                left.DoGrabClose();
            }).StartThread();

            robot.MoveForward((int)(850 - 120 - Robots.MainRobot.LenghtBack + 50)); // Pour s'aligner sur le centre de l'écueil

            left.DoGrabOpen();

            robot.MoveBackward(50);

            right.DoGrabOpen();

            if (GameBoard.MyColor == GameBoard.ColorLeftBlue)
            {
                GameBoard.Elements.FindBuoy(new RealPoint(450, 510)).IsAvailable = false;
            }
            else
            {
                GameBoard.Elements.FindBuoy(new RealPoint(3000 - 450, 510)).IsAvailable = false;
            }

            robot.GoToAngle(-90);
            robot.SetSpeedSlow();
            robot.MoveForward(50);

            ThreadLink grabLink = ThreadManager.CreateThread(l => right.DoSequencePickupColor(GameBoard.MyColor == GameBoard.ColorLeftBlue ? Buoy.Green : Buoy.Red));

            grabLink.StartThread();
            Thread.Sleep(1000);

            Actionneur.ElevatorLeft.DoGrabOpen();
            Actionneur.ElevatorRight.DoGrabOpen();
            robot.MoveForward(450);
            grabLink.WaitEnd();



            //robot.MoveForward((int)(850 - 120 - Robots.MainRobot.LenghtBack)); // Pour s'aligner sur le centre de l'écueil

            //robot.GoToAngle(-90);
            //robot.SetSpeedSlow();
            //Actionneur.ElevatorLeft.DoGrabOpen();
            //Actionneur.ElevatorRight.DoGrabOpen();
            //robot.MoveForward(500);

            Threading.ThreadManager.CreateThread(link => { Actionneur.ElevatorLeft.DoSequencePickupColor(Buoy.Red); }).StartThread();
            Threading.ThreadManager.CreateThread(link => { Actionneur.ElevatorRight.DoSequencePickupColor(Buoy.Green); }).StartThread();

            List <Buoy> taken = GameBoard.Elements.Buoys.Where(b => b.Position.X <robot.Position.Coordinates.X + 200 && b.Position.X> robot.Position.Coordinates.X - 200 && b.Position.Y < 1000 && b.Position.Y > 0).ToList();

            taken.ForEach(b => b.IsAvailable = false);

            Thread.Sleep(500);

            robot.MoveBackward(35);
            robot.SetSpeedFast();
            robot.Pivot(180);

            // Ajouter ICI l'ordre de la strat fixe avant détection d'adversaire

            if (GameBoard.MyColor == GameBoard.ColorLeftBlue)
            {
                fixedMovements.Add(new MovementGroundedZone(GameBoard.Elements.GroundedZones[2]));
                fixedMovements.Add(new MovementBuoy(GameBoard.Elements.FindBuoy(new RealPoint(300, 400))));
                fixedMovements.Add(new MovementLightHouse(GameBoard.Elements.LightHouses[0]));
                fixedMovements.Add(new MovementGreenDropoff(GameBoard.Elements.RandomDropoffs[0]));
                fixedMovements.Add(new MovementGroundedZone(GameBoard.Elements.GroundedZones[0]));
                fixedMovements.Add(new MovementRedDropoff(GameBoard.Elements.RandomDropoffs[0]));
            }
            else
            {
                fixedMovements.Add(new MovementGroundedZone(GameBoard.Elements.GroundedZones[1]));
                fixedMovements.Add(new MovementBuoy(GameBoard.Elements.FindBuoy(new RealPoint(2700, 400))));
                fixedMovements.Add(new MovementLightHouse(GameBoard.Elements.LightHouses[1]));
                fixedMovements.Add(new MovementGreenDropoff(GameBoard.Elements.RandomDropoffs[1]));
                fixedMovements.Add(new MovementGroundedZone(GameBoard.Elements.GroundedZones[3]));
                fixedMovements.Add(new MovementRedDropoff(GameBoard.Elements.RandomDropoffs[1]));
            }
        }
예제 #9
0
        protected override bool MovementCore()
        {
            // TODO : Attrapage (avec test) des bouées exterieures, d'ailleurs prévoir de la place pour les attraper

            ThreadLink link1 = ThreadManager.CreateThread(link => Actionneur.ElevatorRight.DoSequencePickupColor(GameBoard.MyColor == GameBoard.ColorLeftBlue ? Buoy.Green : Buoy.Red));
            ThreadLink link2 = ThreadManager.CreateThread(link => Actionneur.ElevatorLeft.DoSequencePickupColor(GameBoard.MyColor == GameBoard.ColorLeftBlue ? Buoy.Red : Buoy.Green));

            link1.StartThread();
            link2.StartThread();

            link1.WaitEnd();
            link2.WaitEnd();

            if (_zone.HasOutsideBuoys)
            {
                Robot.SetSpeedSlow();
                Actionneur.ElevatorLeft.DoGrabOpen();
                Actionneur.ElevatorRight.DoGrabOpen();
                Robot.Move(250);
                Robot.SetSpeedFast();
                //ThreadManager.CreateThread(link => { Actionneur.ElevatorLeft.DoSequencePickupColor(Buoy.Red); }).StartThread();
                //ThreadManager.CreateThread(link => { Actionneur.ElevatorRight.DoSequencePickupColor(Buoy.Green); }).StartThread();
                Actionneur.ElevatorLeft.DoTakeLevel0(Buoy.Red);
                Actionneur.ElevatorRight.DoTakeLevel0(Buoy.Green);
                _zone.TakeOutsideBuoys();
                Thread.Sleep(500);
                Robot.PivotRight(180);
                Robot.Move(-150);
            }
            else
            {
                Robot.Move(-400);
            }

            Robot.SetSpeedSlow();

            if (_zone.HasInsideBuoys)
            {
                Robot.Recalibration(SensAR.Arriere, true, true);
                // TODO recallage X et Y tant qu'à faire ?
                DoFingersGrab(); // Attrapage des bouées initialement contre la bordure avec les fingers
                _zone.TakeInsideBuoys();
                Robot.SetSpeedFast();
                Robot.Move(150);
                Robot.PivotLeft(180);
                Robot.Move(125);
                Robot.SetSpeedSlow();
                DoElevatorsDropoff(0);
            }
            else
            {
                // TODO, y'a surement des bouées posées, donc pas de recallage et avancer moins
            }

            bool hasLeft  = Actionneur.FingerLeft.Loaded;
            bool hasRight = Actionneur.FingerRight.Loaded;

            if (hasLeft || hasRight)
            {
                Color cLeft  = Actionneur.FingerLeft.Load;
                Color cRight = Actionneur.FingerRight.Load;

                Robot.MoveBackward(90);
                Robot.PivotLeft(82);
                _zone.SetPendingRight(cRight, new RealPoint(Robot.Position.Coordinates.X + 193.5, Robot.Position.Coordinates.Y + 86.5).Rotation(Robot.Position.Angle.InPositiveDegrees + 90, Robot.Position.Coordinates));
                Actionneur.FingerRight.DoRelease();
                Robot.PivotRight(164);
                _zone.SetPendingLeft(cLeft, new RealPoint(Robot.Position.Coordinates.X - 193.5, Robot.Position.Coordinates.Y + 86.5).Rotation(Robot.Position.Angle.InPositiveDegrees + 90, Robot.Position.Coordinates));
                Actionneur.FingerLeft.DoRelease();
                Robot.PivotLeft(82);

                int score = 0;
                int level = _zone.GetAvailableLevel();
                if (hasLeft)
                {
                    _zone.SetBuoyOnGreen(cRight, level);
                    score += 2;
                }
                if (hasRight)
                {
                    _zone.SetBuoyOnRed(cLeft, level);
                    score += 2;
                }

                _zone.RemovePending();

                if (hasLeft && hasRight)
                {
                    score += 2;
                }

                GameBoard.Score += score;
            }

            if (_zone.LoadsOnGreen > 4 || _zone.LoadsOnRed > 4)
            {
                Actionneur.ElevatorLeft.DoGrabOpen();
                Actionneur.ElevatorRight.DoGrabOpen();
                Thread.Sleep(150);
                Robot.SetSpeedVerySlow();
                Robot.MoveForward(170);
                Robot.SetSpeedFast();
                Robot.MoveBackward(170);
            }
            else
            {
                Robot.MoveBackward(100);
            }

            Actionneur.ElevatorLeft.DoGrabClose();
            Actionneur.ElevatorRight.DoGrabClose();

            Robot.SetSpeedFast();

            return(true);
        }
예제 #10
0
        private void btnTestAsser_Click(object sender, EventArgs e)
        {
            ThreadLink th = ThreadManager.CreateThread(link => TestAsser(link));

            th.StartThread();
        }