public bool CheckOffer(int[] offer, int turnsLeft) { OfferHolder holder = AnalyzerEngine.TestOffer(m_counts, m_allValues, m_excludedValues, m_myValuesIndex, offer); if (holder == null) // should never happen now { m_log("!!!!Empty offer!!!!"); return(false); } m_log(Utils.Format("[{0}] Checking offer {1}", turnsLeft, holder)); if (holder.MyIncome >= m_maxIncome * AcceptThreshold) // always accept { return(true); } if (turnsLeft <= 1 && holder.MyIncome > 0) // all telepates are French { m_log("I surrender! Give me at least " + holder.MyIncome); return(true); } if (!ValidOffer(holder, true)) { return(false); } if (m_lastOffer != null && holder.MyIncome >= m_lastOffer.MyIncome) // better than my current offer { return(true); } return(false); }
private bool ValidOffer(OfferHolder offer, bool enemyOffers) { if (offer.MyIncome == 0 || offer.EnemyAverage <= 0 || offer.EnemyMedian <= 0) { return(false); } if (!enemyOffers) { if (m_greed != TelepateType.Greed) { if (offer.EnemyAverage < this.m_maxIncome * MinEnemyIncomeThreshold) { return(false); } } if (m_rejectedOffers.Contains(offer.OfferCode)) { return(false); } } return(true); }
public int[] CheckOffer(int[] o) { if (o != null) { m_rounds--; bool accept = CheckOffer(o, m_rounds); if (accept) { m_log(Utils.Format("Accepting offer {0}", Utils.StringJoin(",", o))); return(null); } } m_rounds--; if (m_rounds == 0) { return(m_counts); } OfferHolder offer = MakeOffer(m_rounds); m_log(Utils.Format("[{0}] Sending offer {1}", m_rounds, offer)); return(Utils.ArrayClone(offer.Offer)); }
public OfferHolder MakeOffer(int turnsLeft) { OfferHolder selectedOffer = null; for (int i = 0; i < m_offers.Length; i++) { if (ValidOffer(m_offers[i], false)) { selectedOffer = m_offers[i]; break; } } if (selectedOffer != null) { this.m_log("Selected offer " + selectedOffer); } if (m_greed == TelepateType.Greed) { if (selectedOffer == null) // no offers left, stick with last one { selectedOffer = m_lastOffer; } } else { if (turnsLeft <= 2) { this.m_log("======== Making final offer! ========"); selectedOffer = null; for (var i = 0; i < this.m_offers.Length; i++) { if (this.m_offers[i].EnemyAverage > this.m_maxIncome * MinEnemyIncomeThreshold && this.m_offers[i].MyIncome > 0) { return(this.m_offers[i]); } } } if (selectedOffer == null) // no offers left, try relaxed list { m_log("!!!!!!!!!!!! No meaninful offers left!"); for (int i = 0; i < m_offers.Length; i++) { if (m_offers[i].EnemyAverage > 0 && m_offers[i].MyIncome > 0 && !m_rejectedOffers.Contains(m_offers[i].OfferCode)) // relaxed check: not fairest option, but still good { selectedOffer = m_offers[i]; break; } } if (selectedOffer == null) // no offers left, stick with last one { m_log("No offers left and no relaxed found!"); selectedOffer = m_lastOffer; } } } m_rejectedOffers.Add(selectedOffer.OfferCode); m_lastOffer = selectedOffer; return(selectedOffer); }