public void SetEnemyData(int [] values) { m_log("Enemy items: " + String.Join(",", values)); for (int j = 0; j < m_allValues.Length; j++) { if (!Utils.ArrayEquals(m_allValues[j], values)) { m_excludedValues.Add(j); } } m_offers = AnalyzerEngine.FindBestOffers(m_counts, m_allValues, m_excludedValues, m_myValuesIndex); if (m_greed == TelepateType.Greed) { Array.Sort(m_offers, (x, y) => x.MyIncome - x.EnemyAverage * 0.1f > y.MyIncome - y.EnemyAverage * 0.1f ? -1 : 1); } else if (m_greed == TelepateType.Benevolent) { Array.Sort(m_offers, (x, y) => x.MyIncome * 1.1f + x.EnemyAverage > y.MyIncome * 1.1f + y.EnemyAverage ? -1 : 1); } //else //Array.Sort(m_offers, (x, y) => x.MyIncome + x.EnemyAverage * 0.1f > y.MyIncome + y.EnemyAverage * 0.1f ? -1 : 1); #if LOG_OFFERS m_log("Initial list of offers"); for (int i = 0; i < m_offers.Length; i++) { m_log(Utils.Format("{0}: valid: {1}", m_offers[i], ValidOffer(m_offers[i], false))); } #endif }
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); }