All pastes #1015468 Raw Edit

Sithid

public text v1 · immutable
#1015468 ·published 2008-05-12 06:33 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Text;
using NRobot.Robot;

[assembly:RobotClass( "NRobot.Robots.Sithid" )]
namespace NRobot.Robots
{
    [OwnerEmail( "DemonicUrges05 AT gmail DOT com" )]
    [TeamInfo( Name = "Team Sithid", BodyColor = 0x337788,
        MaxMoveSpeed = TradeOff.Better, BulletDamage = TradeOff.Better, Size = TradeOff.Better, BulletSpeed = TradeOff.Better,
        MaxTurnSpeed = TradeOff.Worse, MaxTurretTurnSpeed = TradeOff.Worse, ShotDelay = TradeOff.Worse, ShotsPermitted = TradeOff.Worse )]
    [RobotInfo(1, Name = "Sithid" )]
    public class Sithid : IRobot
    {
        
        private List<VisibleBot> m_Targets;
        private VisibleBot m_Robot;

        public void Start( StartState state )
        {
            m_Targets = new List<VisibleBot>();  
        }

        public void Tick( TickState state )
        {
            m_Targets.Clear();
            m_Robot = null;

            if ( state.VisibleBots.Count > 0 )
            {
                foreach ( VisibleBot bot in state.VisibleBots )
                {
                    if ( !m_Targets.Contains( bot ) )
                    {
                        m_Targets.Add( bot );
                        PickTarget();
                    }
                    else
                        PickTarget();
                }

                if ( m_Robot == null )
                {
                    m_Robot = (VisibleBot)state.VisibleBots[0];
                }

                if ( m_Robot.Team != state.Team && abs( m_Robot.AngleFromSelf ) * m_Robot.Distance < 250 * m_Robot.Radius )
                {
                    state.Fire();
                    state.Fire();
                }
                else
                    m_Robot = null;

                if ( m_Robot != null )
                {
                    state.TurnSpeed = m_Robot.AngleFromSelf;
                    state.MoveSpeed = state.MaxMoveSpeed;//m_Robot.Distance - 6 * m_Robot.Radius;
                }
                else
                {
                    state.TurnSpeed = state.MaxTurnSpeed;
                    state.MoveSpeed = state.MaxMoveSpeed;
                    state.TurnSpeed = state.MaxTurretTurnSpeed;

                    state.MoveDuration = 5;
                }
            }
            else
            {
                state.TurnSpeed = state.MaxTurnSpeed;
                state.MoveSpeed = state.MaxMoveSpeed;
                state.TurnSpeed = state.MaxTurretTurnSpeed;

                state.MoveDuration = 5;
            }
        }

        private void PickTarget()
        {
            for ( int i = 0; i < m_Targets.Count; ++i )
            {
                if ( m_Robot == null )
                {
                    m_Robot = m_Targets[i];
                }

                if ( m_Robot.Distance > m_Targets[i].Distance )
                    m_Robot = m_Targets[i];
            }
        }

        private int abs( int n )
        {
            return n > 0 ? n : -n;
        }
    }
}