public Dictionary<int, ITrade> ProposeTrade(Player player, List<List<Resource>> give, List<List<Resource>> take) { var trade = new Trade(give, take); var dict = new Dictionary<int, Trade>(); //Reversed trades var replyDict = new Dictionary<int, ITrade>(); Log(new ProposeTradeLogEvent(player.Id, trade.Give, trade.Take)); var state = CurrentGamestate(); foreach (var other in players) { if (other.Id == player.Id) continue; //No need to propose a trade with yourself dict[other.Id] = (Trade)other.Agent.HandleTrade(state, trade.Reverse(), player.Id); if (dict[other.Id].Status == TradeStatus.Countered) { replyDict[other.Id] = dict[other.Id].Reverse(); //Note, take and give are swapped since dict[other.Id] is as seen from the opponent var giveLog = dict[other.Id].Take.Where(c => c.Count > 0).Select(r => r[0]).ToList(); var takeLog = dict[other.Id].Give.Where(c => c.Count > 0).Select(r => r[0]).ToList(); Log(new CounterTradeLogEvent(other.Id, giveLog, takeLog)); break; } } proposedTrades[player.Id] = dict; return replyDict; }