Exemple #1
0
 public override DDDEvent ToDDDEvent(int currentTime, DDDAdapter ddd)
 {
     MoveEvent ev = new MoveEvent();
     if(this.Location.Item is T_AbsolutePosition)
     {
         ev.DestinationLocation = ((T_AbsolutePosition)this.Location.Item).ToLocationValue();
     }else if(this.Location.Item is T_RelativePosition)
     {
         //get the relative object location, distance constraint, and/or absolute position
         Console.WriteLine("TODO Implement this!");
         return null;
     }
     else if (this.Location.Item is LocationValue)
     {
         ev.DestinationLocation = (LocationValue)this.Location.Item;
     }
     else
     {
         Console.WriteLine("TODO Fix this!");
         return null;
     }
     ev.ObjectID = this.ID;
     ev.Time = this.TimeAfter + currentTime;
     ev.Throttle = Throttle;
     return ev;
 }
Exemple #2
0
 public MainWindow()
 {
     _items = new Dictionary<string, T_Item>();
     _timelineEvents = new ScheduledItemsList();
     _ddd = new DDDAdapter();
     _ddd.SetTickCallback(new DDDAdapter.TimeTickDelegate(TimeTick));
     InitializeComponent();
 }
Exemple #3
0
 public override DDDEvent ToDDDEvent(int currentTime, DDDAdapter ddd)
 {
     ChangeStateEvent ev = new ChangeStateEvent();
     ev.ObjectID = this.ID;
     ev.StateName = this.State;
     ev.Time = this.TimeAfter + currentTime; //not sure why it parses an int to a string in the first place...
     return ev;
 }
Exemple #4
0
        public override DDDEvent ToDDDEvent(int currentTime, DDDAdapter ddd)
        {
            RevealEvent ev = new RevealEvent();
            if (this.Location.Item is T_AbsolutePosition)
            {
                ev.Location = ((T_AbsolutePosition)this.Location.Item).ToLocationValue();
            }
            else if (this.Location.Item is T_RelativePosition)
            {
                //get the relative object location, distance constraint, and/or absolute position
                Console.WriteLine("TODO Implement this!");
                return null;
            }
            else if (this.Location.Item is LocationValue)
            {
                ev.Location = (LocationValue)this.Location.Item;
            }
            else
            {
                Console.WriteLine("TODO Fix this!");
                return null;
            }
            ev.ObjectID = this.ID;
            ev.State = this.State;
            ev.Time = this.TimeAfter + currentTime;

            //optional params
            if (this.Owner != string.Empty && this.Owner != null)
            {
                ev.OwnerID = this.Owner;
            }
            if (this.Type != String.Empty && this.Type != null)
            {
                ev.ObjectType = this.Type;
            }
            if (this.StartupParameters.Items.Count() > 0)
            {
                for (int x = 0; x < this.StartupParameters.Items.Count() - 1; x += 2)
                {
                    try
                    {
                        ev.StartupParameters.Add(StartupParameters.Items[x], ddd.GetCorrectDataValue(StartupParameters.Items[x], StartupParameters.Items[x + 1])); //this should work
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Exception while parsing a startup parameter. " + ex.Message);
                    }
                }
            }

            return ev;
        }
Exemple #5
0
 private Boolean _readyToSendItems = true;//default to true so we always send the first scheduled item
 public MainWindow()
 {
     _items = new Dictionary<string, T_Item>();
     _ptItems = new Dictionary<string, T_Item>();
     _timelineEvents = new ScheduledItemsList();
     _dmCPEs = new Dictionary<string, CPEPair>();
     _ddd = new DDDAdapter();
     _ddd.SetTickCallback(new DDDAdapter.TimeTickDelegate(TimeTick));
     InitializeComponent();
     LoadCommandLineArgs();
     tbHostname.Text = _dddHostname;
     tbPort.Text = _dddPort.ToString();
     tbShareName.Text = _dddShare;
     _itemSelector = new AdaptiveSelector.AdaptiveSelector(new ChallengeMethod(), "");
 }
Exemple #6
0
        public AmbiguityGenerator(DDDAdapter ddd)
            : base(ddd)
        {

        }
Exemple #7
0
        public CourseGenerator(DDDAdapter ddd)
            : base(ddd)
        {

        }
Exemple #8
0
 public CrossingGenerator(DDDAdapter ddd)
     : base(ddd)
 {
     
 }
Exemple #9
0
 private static bool onlyMerchant(DDDAdapter.SeamateObject vessel)
 {
     return vessel.Owner == "Merchant DM";
 }
Exemple #10
0
 private bool IsMerchant(DDDAdapter.SeamateObject vessel)
 {
     return vessel.Owner == "Merchant DM";
 }
Exemple #11
0
 /// <summary>
 /// Returns a boolean value expressing whether or not a new vessel can be added to an existing group while fulfilling 
 /// grouping constraints.
 /// One grouping: Every item in the group must be within the one-grouping parameter of each other.
 /// Two grouping: At least one pair in the group must be separated by the two-grouping parameter.
 /// </summary>
 /// <param name="oneOrTwo">Must be "One" or "Two" for a one- or two-grouping</param>
 /// <param name="newVessel">Vessel to be added to the group</param>
 /// <param name="otherVessels">Existing group of vessels</param>
 /// <returns></returns>
 private bool MatchesGroupingCriteria(T_Groupings grouping, DDDAdapter.SeamateObject newVessel, List<DDDAdapter.SeamateObject> otherVessels) {
     if (otherVessels.Contains(newVessel))
         return false;
     if (grouping == T_Groupings.One) {
         foreach (DDDAdapter.SeamateObject vessel in otherVessels) {
             double distance = new Vec2D(vessel.Location).ScalerDistanceTo(new Vec2D(newVessel.Location));
             if (distance > oneGroupingDistance)
                 return false;
         }
         return true;
     } else {
         foreach (DDDAdapter.SeamateObject vessel in otherVessels) {
             double distance = new Vec2D(vessel.Location).ScalerDistanceTo(new Vec2D(newVessel.Location));
             if (distance > twoGroupingDistance)
                 return true;
         }
         return false;
     } 
 }
Exemple #12
0
 /// <summary>
 /// Returns a boolean value expressing whether or not a vessel is suitable to be chosen to express a stimuli.
 /// </summary>
 /// <param name="vessel"></param>
 /// <returns></returns>
 private bool IsReusable(DDDAdapter.SeamateObject vessel)
 {
     //merchants may be attacked by multiple pirates, so it's ok to choose them even if they
     //already have an intent.
     bool isMerchantOrNotOnAttackCourse = ((vessel.Owner == "Merchant DM") || (vessel.Intent == "")); 
     return (vessel.Owner == owner && Polygon2D.IsPointInside(domain, new Vec2D(vessel.Location)) && isMerchantOrNotOnAttackCourse);
 }
Exemple #13
0
 public PirateGenerator(DDDAdapter ddd)
     : base(ddd)
 {
 }
Exemple #14
0
 public GroupingGenerator(DDDAdapter ddd)
     : base(ddd)
 {
     
 }
Exemple #15
0
 public virtual DDDEvent ToDDDEvent(int currentTime, DDDAdapter ddd)
 { return null; }
Exemple #16
0
        public override DDDEvent ToDDDEvent(int currentTime, DDDAdapter ddd)
        {
            InteractionEvent ev = new InteractionEvent();
            ev.CapabilityName = this.Capability;
            ev.ObjectID = this.Instigator;
            ev.TargetID = this.Target;
            ev.Time = this.TimeAfter + currentTime;

            return ev;
        }
Exemple #17
0
 public MerchantGenerator(DDDAdapter ddd)
     : base(ddd)
 {
     
 }
Exemple #18
0
 public override DDDEvent ToDDDEvent(int currentTime, DDDAdapter ddd)
 {
     //this currently does not send out an actual DDD event, it correlates to once which is already scripted.
     return null;
 }
Exemple #19
0
        /// <summary>
        /// Determines whether a merchant is within grouping constraints of previously chosen pirates.
        /// </summary>
        /// <param name="vessel">Merchant</param>
        /// <returns>Boolean</returns>
        private bool MatchesGroupingConstraints(DDDAdapter.SeamateObject vessel)
        {
            if (vessel.Intent != "")
                return false;

            if (grouping == T_Groupings.One)
            {
                foreach (T_Move key in dict.Keys)
                {
                    Vec2D otherVesselLocation = new Vec2D(GetLocation(key, dict[key]));
                    double distance = new Vec2D(vessel.Location).ScalerDistanceTo(otherVesselLocation);
                    if (distance > oneGroupingDistance) return false;
                }
                return true;
            }
            else 
            {
                return true;
            }      
        }
Exemple #20
0
 public ThreatTypeGenerator(DDDAdapter ddd)
     : base(ddd)
 {
     
 }
Exemple #21
0
 public InterceptGenerator(DDDAdapter ddd)
     : base(ddd)
 {
     
 }