コード例 #1
0
ファイル: Player.cs プロジェクト: Gabino3/socAI
    // Returns a TradeOffer if the trade is valid (an identical request has not recently been made); If this is not true, returns null
    public TradeOffer generateAITradeRequest(int currentTurn, AIEngine.Objective objective)
    {
        TradeOffer trade = BuildFairTrade (currentTurn, objective.GetCardDifferential ());

        if(trade.TotalGetResources() > 1 && trade.TotalGiveResources() > 1)
        {
            trade.RandomUnequalizeTrade ();	// Introduces an element of randomness to the trade algorithm
        }

        if(debugMessages)
        {
            GameEngine.print ("PLAYER HAND: \n" +
                              hand.brick + " BRICK\n" +
                              hand.ore + " ORE\n" +
                              hand.wood + " WOOD\n" +
                              hand.grain + " GRAIN\n" +
                              hand.sheep + " SHEEP");

            GameEngine.print ("CARDS NEEDED: \n" +
                              objective.GetCardsNeeded().brick + " BRICK\n" +
                              objective.GetCardsNeeded ().ore + " ORE\n" +
                              objective.GetCardsNeeded ().wood + " WOOD\n" +
                              objective.GetCardsNeeded ().grain + " GRAIN\n" +
                              objective.GetCardsNeeded ().sheep + " SHEEP");

            GameEngine.print ("CARD DIFFERENTIAL: \n" +
                              objective.GetCardsNeeded().GetHandSize() + " CARDS NEEDED\n" +
                              objective.GetCardDifferential ().brick + " BRICK\n" +
                              objective.GetCardDifferential ().ore + " ORE\n" +
                              objective.GetCardDifferential ().wood + " WOOD\n" +
                              objective.GetCardDifferential ().grain + " GRAIN\n" +
                              objective.GetCardDifferential ().sheep + " SHEEP");
        }

        if(GetPermissionToRetryTradeRequest (currentTurn, trade))
        {
            return trade;
        }

        return null;
    }