Ejemplo n.º 1
0
        public static bool CollideWithArena(ref Vec a, bool verb)
        {
            double rimbalzo;

            if (a.r == 1)
            {
                rimbalzo = rules.ROBOT_ARENA_E;
            }
            else
            {
                rimbalzo = rules.BALL_ARENA_E;
            }

            Dan    dta   = a.DanToArena();
            double penet = a.r - dta.distance;

            if (penet <= 0)
            {
                return(false);
            }
            if (verb)
            {
                De("penet=" + penet);
            }

            a.DoAdd(dta.normal.Mul(penet));

            double vel = a.VelocityVec().Dot(dta.normal) - a.rcs;

            if (vel < 0)
            {
                Vec zs = dta.normal.Mul(-vel * (1 + rimbalzo));
                if (verb)
                {
                    De("vel added " + zs.x + " " + zs.y + " " + zs.z);
                }
                a.AddVelocity(zs);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public void Act(Robot me, Rules rulese, Game gamee, Action action)
        {
            if ((turn == 0) && (robotsDone == 0))
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
                rules = rulese;
                ar    = rulese.arena;
                InitConstants();
                firstrobot = me.id;
                if (me.id == 1)
                {
                    firstenemyrobot = robotsPerPlayer + 1;
                }
                else
                {
                    firstenemyrobot = 1;
                }
            }
            //
            if (robotsDone == 0)
            {
                start = Timenow();
                if (turn > 0)
                {
                    bool iscored = false, hescored = false;
                    if (game.players[0].score != gamee.players[0].score)
                    {
                        iscored = true;
                    }
                    if (game.players[1].score != gamee.players[1].score)
                    {
                        hescored = true;
                    }
                    if (hescored || iscored)
                    {
                        //GOAL RESET
                        pause = 1;
                        //De("score");
                    }
                }

                game = new Sgame(gamee);
                if (game.ball.m != rules.BALL_MASS)
                {
                    Re("nno!");
                }
                Sgame g3 = new Sgame(game, false);


                Advance(ref g3, 0.25);
                if (g3.ball.m != rules.BALL_MASS)
                {
                    Re("nno2!");
                }
                //for (int i = 0; i < 10; i++) Tick(ref g3,false);
                afterball1 = new Vec(g3.ball);
                Advance(ref g3, 0.35);
                //for (int i = 0; i < 10; i++) Tick(ref g3,false);
                afterball = new Vec(g3.ball);



                bal = new Vec(game.ball);
                dw  = bal.DanToArena();
                Re("time is " + (Timenow() - start));
                acts = ChooseMoves();
            }

            if (me.id - firstrobot < acts.Length)
            {
                if (me.id - firstrobot >= 0)
                {
                    action.target_velocity_x = acts[me.id - firstrobot].target_velocity_x;
                    action.target_velocity_y = acts[me.id - firstrobot].target_velocity_y;
                    action.target_velocity_z = acts[me.id - firstrobot].target_velocity_z;
                    action.jump_speed        = acts[me.id - firstrobot].jump_speed;
                }
            }
            robotsDone++;

            if (robotsDone == 2)
            {
                turn++;
                robotsDone = 0;
            }
            //int k = -9999999;
            //while (Timenow() - start < 20) if (k < 99999) k++; else k = -999999;
        }