Example #1
0
        public void UpdateBotSetsRotation()
        {
            const int turnLeft  = 100;
            const int turnRight = 350;

            var bot = new Bot
            {
                Orientation = 0
            };

            bot.SetMemory(MemoryAddresses.TurnLeft, turnLeft);
            bot.SetMemory(MemoryAddresses.TurnRight, turnRight);

            RuntimeEngine.UpdateBot(bot);

            bot.Orientation.Should().BeApproximately(AngleHelper.IntToAngle(turnRight - turnLeft), 3);
        }
Example #2
0
        public void UpdateBotRotatesNetForce()
        {
            const int   testX     = 10;
            const float testAngle = (float)Math.PI / 3;

            var bot = new Bot
            {
                Orientation = testAngle,
                Speed       = Vector2.Zero
            };

            bot.SetMemory(MemoryAddresses.MoveUp, testX);

            RuntimeEngine.UpdateBot(bot);

            bot.Force.X.Should().BeApproximately(testX * (float)Math.Cos(testAngle), 3);
            bot.Force.Y.Should().BeApproximately(testX * (float)Math.Sin(testAngle), 3);
        }
Example #3
0
        public void UpdateBotAppliesNetForce()
        {
            const int testUp    = 5;
            const int testDown  = 6;
            const int testLeft  = 9;
            const int testRight = 12;

            var bot = new Bot
            {
                Orientation = 0,
                Speed       = Vector2.Zero
            };

            bot.SetMemory(MemoryAddresses.MoveRight, testRight);
            bot.SetMemory(MemoryAddresses.MoveLeft, testLeft);
            bot.SetMemory(MemoryAddresses.MoveDown, testDown);
            bot.SetMemory(MemoryAddresses.MoveUp, testUp);

            RuntimeEngine.UpdateBot(bot);

            bot.Force.X.Should().Be(testUp - testDown);
            bot.Force.Y.Should().Be(testRight - testLeft);
        }