protected virtual void CompareOffer(NegotiationOffer offer, Boolean sendReject = true) { if (offer == null) { return; } if (RoundsPassed == 0) { if (offer.Equals(CurrentOffer)) { AcceptOffer(); return; } } else if (RoundsPassed < Domain.NumberOfRounds - 1) { if (AllOptions[offer].Utility >= BestFScoreUtilityOffers.Values.Min(x => x.Utility)) { AcceptOffer(); return; } } else { if (AllOptions[offer].Utility >= BestCombinedUtilityOffers.Values.Min(x => x.Utility)) { AcceptOffer(); return; } } if (sendReject) Client.RejectOffer(); }
public void OpponentOfferReceived(NegotiationOffer offer) { if (OfferReceivedEvent != null) { OfferReceivedEvent(this, new OfferEventArgs(offer)); } }
protected void SendOffer(NegotiationOffer offer, Boolean sendIdentical = true) { if (offer != null) { if (sendIdentical || !CurrentOffer.Equals(offer)) { CurrentOffer = offer; Client.SendOffer(CurrentOffer); } } }
protected void RoundRobinOffer(ICollection <OfferUtility> offers, TimeSpan remainingTime) { CompareOffer(OpponentOffer, false); int roundPart = (int)(Domain.RoundLength.TotalSeconds / offers.Count); int offerIndex = Math.Min( offers.Count - 1, (Math.Max(0, (int)remainingTime.TotalSeconds - 1) / roundPart) % offers.Count ); NegotiationOffer offer = offers.ElementAtOrDefault(offerIndex).Offer; SendOffer(offer, false); }
protected virtual void CompareOffer(NegotiationOffer offer, Boolean sendReject = true) { if (offer == null) { return; } if (RoundsPassed >= 0 && RoundsPassed <= 7) { if (offer.Equals(BestOffer)) { AcceptOffer(); return; } } else if (RoundsPassed >= 8 && RoundsPassed <= 11) { if (AllOptions[offer].Utility >= FScoreOffersByUtility[0].Utility) { AcceptOffer(); return; } } else if (RoundsPassed >= 12 && RoundsPassed <= 13) { if (AllOptions[offer].Utility >= FScoreOffersByUtility[1].Utility) { AcceptOffer(); return; } } else if (RoundsPassed == 14) { if (AllOptions[offer].Utility >= FScoreOffersByUtility[2].Utility) { AcceptOffer(); return; } } if (sendReject) { Client.RejectOffer(); } }
public ActionResult SendOffer(String negotiationId, NegotiationOffer offer) { NegotiationEngine engine; if (negotiationId == null || !NegotiationManager.OnGoingNegotiations.TryGetValue(negotiationId, out engine)) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest)); } if (!engine.NegotiationActive) { return(NegotiationEnd(negotiationId)); } engine.HumanChannel.SendOffer(offer); return(new EmptyResult()); }
protected virtual void CompareOffer(NegotiationOffer offer, Boolean sendReject = true) { if (offer == null) { return; } if (RoundsPassed == 0) { if (offer.Equals(CurrentOffer)) { AcceptOffer(); return; } } else if (RoundsPassed < Domain.NumberOfRounds - 1) { if (AllOptions[offer].Utility >= BestFScoreUtilityOffers.Values.Min(x => x.Utility)) { AcceptOffer(); return; } } else { if (AllOptions[offer].Utility >= BestCombinedUtilityOffers.Values.Min(x => x.Utility)) { AcceptOffer(); return; } } if (sendReject) { Client.RejectOffer(); } }
public NegotiationViewModel() { Actions = new List<NegotiationActionModel>(); Offer = new NegotiationOffer(); OpponentOffer = new NegotiationOffer(); }
public ActionResult SendOffer(String negotiationId, NegotiationOffer offer) { NegotiationEngine engine; if (negotiationId == null || !NegotiationManager.OnGoingNegotiations.TryGetValue(negotiationId, out engine)) return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest); if (!engine.NegotiationActive) { return NegotiationEnd(negotiationId); } engine.HumanChannel.SendOffer(offer); return new EmptyResult(); }
public void SendOffer(NegotiationOffer offer) { if (NewOfferEvent != null) { NewOfferEvent(this, new OfferEventArgs(offer)); } }