Announcement

Collapse
No announcement yet.

IMPROVED version of DIPLOMOD

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Originally posted by Peter Triggs
    It seems to me that the above code is consistent with these instructions and I can't see why an AI civ will send one of the above proposals to the Human but not another AI.
    Maybe AI sends proposals, but other AI never responds to them.

    Comment


    • #17
      I don't think so. I had another handler that supposedly deals with the AI's responses:

      Code:
      int_t NP_FIRST_TYPE;
      
      HandleEvent(NewProposal) 'AcceptWarAndAllianceProposals' pre {
      
      int_t first_type; //initial proposal
      
          first_type = GetLastNewProposalType(player[0], player[1], 0);
          NP_FIRST_TYPE=first_type;
          message(1,'proptype');
      
          if(!IsHumanPlayer(player[1]) && !IsHumanPlayer(player[0]) ) {
               if ( first_type==32 ) {
               //WHENEVER an AI civ offers a cease fire to another
      	      ConsiderResponse(player[1], player[0], 3000, 2);//2=accept
                    ConsiderResponse(player[0], player[1], 3000, 2);//2=accept
                    Event:EstablishEmbassy(player[0], player[1]);//cease fires entail diplomatic relations
                    Event:EstablishEmbassy(player[1], player[0]);
               }
               if ( first_type==33 ) {//WHENEVER an AI civ offers a peace treaty to another    
      	      ConsiderResponse(player[1], player[0], 2000, 2);//2=accept
      	 }
               if(AtWarWith(player[0],1) && AtWarWith(player[1],1) && !AtWarWith(player[0],player[1]) ){ 
      	 // Whenever two AI civs are at war with the Human
                    if (first_type==38) {
          
                       ConsiderResponse(player[0], player[1], 2000, 2);//2=accept
                    }
               }
          }
      }
      messagebox 'proptype' {
      show();
      Text (ID_M_proptype) ;
      // M_proptype "sender={player[0]} receiver={player[1]} type={NP_FIRST_TYPE}"
      }
      The message 'proptype' should pick up any proposal that any civ sends to any other one. But I only got proposals to and from the Human: no AI-AI diplomacy at all. This doesn't seem reasonable because they must at least exchange maps occasionally. Hmm, I wonder if it had anything to do with the fact that I was working in the Cradle mod and all the AI civs either were at war or at least hated each other. What MOD are you using? How about putting:

      Code:
      int_t NP_FIRST_TYPE;
      
      HandleEvent(NewProposal) 'AcceptWarAndAllianceProposals' pre {
      
      int_t first_type; //initial proposal
      
          first_type = GetLastNewProposalType(player[0], player[1], 0);
          NP_FIRST_TYPE=first_type;
          message(1,'proptype');
      }
      
      messagebox 'proptype' {
      show();
      Text (ID_M_proptype) ;
      // M_proptype "sender={player[0]} receiver={player[1]} type={NP_FIRST_TYPE}"
      }
      into it to see what you get.

      Comment


      • #18
        I was thinking about this over the weekend, and did a bit of testing. After running some tests through the AI I got the picture that the AI will not respond during its own turn. IE: the AI will propose, but the AI will not respond. Effectively this means that the responding routines are only active during the AI's turn. This could be design as it would speed up the AI's turns. However, we all know for sure that the AI will respond during the Human's turn.

        What I'm going to try is the following:
        Instead of making the AI propose to other AI's during its own turns, write a routine to make the AI propose to other AI's during the Human turn. We can setup the handler to trigger "pre" so the Human doesn't even notice it happening.

        I'll get back to you on this one after I test it.

        Comment


        • #19
          Interesting idea, Dale!

          Comment


          • #20
            Originally posted by Peter Triggs
            The message 'proptype' should pick up any proposal that any civ sends to any other one. But I only got proposals to and from the Human: no AI-AI diplomacy at all. This doesn't seem reasonable because they must at least exchange maps occasionally.
            In fact, map exchange between AIs is done by forcing AIs to exchage them through slic ( Event:GiveMap(player[0],player[1]) ).

            Comment


            • #21
              Originally posted by Dale
              I'll get back to you on this one after I test it.
              Hmm?
              Dale,
              10 days have passed, have you tested your idea?

              Comment


              • #22
                Bad News Abounds......

                Hey guys. I got a string of bad luck the last few days.

                I was ready to start testing my theory, and suddenly my display card died. I got a new one and found that it'd blown my motherboard too. I'm still waiting for the company to send me a new motherboard (it's on a lease agreement) so I have no PC at home to try this out. But if anyone wants to give it a try, here's what I believe should make the AI's consider proposing to other AI's during the Human's turn. Just modify DIPLOMOD.SLC or whatever version CRA_*, APOL_* or MM2_*.

                Code:
                ///////////////////////////////////
                // Main routine
                ///////////////////////////////////
                
                HandleEvent(BeginTurn) 'DIP_MainRoutine' post {
                     if(g.player == 1) {
                          DIP_turns = DIP_turns + 1;
                     }
                ///////////////////////////////
                /////     NEW NEW NEW   
                ///////////////////////////////
                     if(IsHumanPlayer(g.player)) {
                          int_t DIP_otherciv;
                          for(DIP_otherciv = 0; DIP_otherciv < DIP_NumOfPlayers; DIP_otherciv = DIP_otherciv + 1) {
                               player[0] = DIP_otherciv;
                               if(!(IsHumanPlayer(player[0]))) {
                ///////////////////////////////
                /////     NEW NEW NEW    
                ///////////////////////////////
                          for(DIP_civ = 0; DIP_civ < DIP_NumOfPlayers; DIP_civ = DIP_civ + 1) {
                               player[1] = DIP_civ;
                
                // Rest of Main routine in here......
                
                                         if(DIP_request == 36) {
                                              ConsiderNewProposal(blahblahblah);
                                         }
                                    }
                               }
                          }
                ///////////////////////////////
                /////     NEW NEW NEW    
                ///////////////////////////////
                          }
                          }
                     }
                ///////////////////////////////
                /////     NEW NEW NEW   
                ///////////////////////////////
                     }
                }

                Comment


                • #23
                  Err, Umm, Success?

                  OK, it is possible to get AI-AI diplomacy, but it ain't all that pretty. It's the motivation settings in the strategies in combination with the priorities for the proposal in diplomacy.txt that should determine whether or not a New Proposal is sent. But this happens in the three motivation events: FearMotivation, DesireMotivation, and ReactionMotivation. Each of these has a player[0] (the sender) and a player[1] (the receiver) parameter and no matter what I tried I couldn't get the events occur with anything other than the human as player[1].

                  So, as they say, here's a workaround. Just prior to these motivation events the NextDiplomaticState event occurs, again with player[0] and player[1] parameters, and here the game does take player[1] in a loop through all the other players that player[0] has contact with. There's two tricks involved: first, you work in this event rather than the motivation events we're supposed to be working in, and second, immediately after telling the sender to consider a new proposal you generate a NewProposal event. Here's an example test handler:

                  Code:
                  HandleEvent(NextDiplomaticState)'Test_AI_AI_Diplomacy' pre {
                  
                      if (!IsHumanPlayer(player[0]) && !IsHumanPlayer(player[1])) {
                           if (TurnsAtWar(player[0],player[1])>25 ) {// 0 for test
                  	      // offer cease-fire	    
                  	      LogRegardEvent(player[0],player[1], 500, 0, ID_NONE, 0);
                  	      ConsiderNewProposal(player[0],player[1], 2000,32,0,ID_NONE,ID_NONE,ID_NONE);     
                  	      Event:NewProposal(player[0],player[1]);	      
                           }
                           if (HasAgreement(player[0], player[1],32) && !HasAgreement(player[0], player[1],33) ) {
                  	 //if they have a cease-fire but not a peace treaty, offer one
                  	      LogRegardEvent(player[0],player[1], 500, 0, ID_NONE, 0);
                  	      ConsiderNewProposal(player[0], player[1], 2000, 33, 0,ID_NONE,ID_NONE,ID_NONE);
                  	      Event:NewProposal(player[0], player[1]);
                           }
                           if(AtWarWith(player[0],1) && AtWarWith(player[1],1)){// 1 being the Human
                  	 //if both sender and recipient are at war with the Human
                                if (!HasAgreement(player[0], player[1],33) ) {//are these mutual?
                  	      //if they don't have a peace treaty, offer one
                  	           ConsiderNewProposal(player[0], player[1], 2000, 33, 0,ID_NONE,ID_NONE,ID_NONE);
                  		     Event:NewProposal(player[0], player[1]);        
                                }
                                if(HasAgreement(player[0], player[1],33) && !HasAgreement(player[0], player[1],38)){
                  	      //if they have a peace treaty but not an alliance, offer one 
                                     ConsiderNewProposal(player[0], player[1], 2000, 38, 0,ID_NONE,ID_NONE,ID_NONE);
                  		        Event:NewProposal(player[0], player[1]);          
                                }
                           }
                      }
                  }
                  I doubt that anyone would really want to use this as it stands. It might be called 'The_Second_Coming_Handler': I've only tested it over a short term but it's effect is to establish World Peace amongst AI civs quite rapidly. On the other hand, I think it does show the route towards getting AI-AI diplomacy.

                  Oh, and you also have to have a handler like the 'AcceptWarAndAllianceProposals' one I posted above to get them to accept the proposals.

                  Comment


                  • #24
                    Originally posted by Peter Triggs
                    it's effect is to establish World Peace amongst AI civs quite rapidly.
                    World AI Peace, I would rather like AI alliance against other AIs or the human. And AIs should offer each other scince and trade pacts.

                    And another question would it the effect of this line:

                    Code:
                    if(AtWarWith(player[0],1) && AtWarWith(player[1],1)){// 1 being the Human
                    equal to this line:

                    Code:
                    if(AtWarWith(player[0],(IsHumanPlayer(g.player))) && AtWarWith(player[1],(IsHumanPlayer(g.player)))){// 1 being the Human
                    That would make the the human player more common and not ristricted to player 1. So far I didn't see any case yet but it could be possible. To give me a part of the answer on myself: It is shure that this line has the same effect during the human turn.

                    Here is an example of my city capture option:

                    Code:
                    HandleEvent(CaptureCity) 'MG_KillCityOption' post {
                    	if (city[0].population>1) {
                    		if(IsHumanPlayer(g.player)){
                    			if(CityIsValid(city[0])) {
                    				message((IsHumanPlayer(g.player)), 'DestroyCityMSG');
                    				city[0] = DestroyCity;
                    			}
                    		}
                    	}
                    }
                    From my experience this message will only send to the human player. I change the player via cheat editor and I gotn't this message also I playerd one turn with the AI.

                    So Dale's main rotine would also work if it looks like:

                    Code:
                    ///////////////////////////////////
                    // Main routine
                    ///////////////////////////////////
                    
                    HandleEvent(BeginTurn) 'DIP_MainRoutine' post {
                         if(IsHumanPlayer(g.player)) {
                              DIP_turns = DIP_turns + 1;
                         }
                    So far this improved version of DiploMod will be a part of GoodMod, when the alliance trigger is finished.

                    -Martin
                    Civ2 military advisor: "No complaints, Sir!"

                    Comment


                    • #25
                      I would rather like AI alliance against other AIs or the human
                      The last part of the handler should give the result that any two AI's that are at war with the human will enter into an alliance, but I didn't test it that far.

                      And another question would it the effect of this line:

                      Code:
                      
                      if(AtWarWith(player[0],1) && AtWarWith(player[1],1)){// 1 being the Human
                      equal to this line:

                      Code:
                      
                      if(AtWarWith(player[0],(IsHumanPlayer(g.player))) && AtWarWith(player[1],(IsHumanPlayer(g.player)))){// 1 being the Human
                      Yes, provided the human player is player 1, so it's not really what you're after. A better way of doing it (I think this was Wombat's idea) is:

                      Code:
                      int_t THE_HUMAN;
                      
                      HandleEvent(BeginTurn)'NumofPlayers' pre {
                      
                      int_t i;
                      
                          NUM_PLAYERS= preference("NumPlayers");
                      
                          for(i=1; i
                      
                      so that you can use 'THE_HUMAN' instead of '1'.

                      message((IsHumanPlayer(g.player)), 'DestroyCityMSG');
                      The trouble is that 'IsHumanPlayer(g.player)' will return either 1 or 0, so this message will either go to player 1 (who's usually the human) or the Barbarians. If you use 'THE_HUMAN' you should get the generality you want.

                      So Dale's main rotine would also work if it looks like:
                      When you go to test this, I strongly recommend that for testing purposes you put the following handler into your file:
                      Code:
                      int_t NP_FIRST_TYPE;
                      
                      HandleEvent(NewProposal)'TestNewProposal' pre {
                      int_t first_type;
                      
                          first_type = GetLastNewProposalType(player[0], player[1], 0);
                          NP_FIRST_TYPE=first_type;
                          message(1,'proptype');  
                          
                      }
                      messagebox 'proptype' {
                      show();
                      Text (ID_M_proptype) ;
                      // M_proptype "sender={player[0]} receiver={player[1]} type={NP_FIRST_TYPE}" 
                      }
                      This will pick up any pick up any message that any player sends to any other player and tell you about it. So you can see what kind of diplomacy is going on all the time.

                      Comment


                      • #26
                        Here's the bit that got missed out above:

                        Yes, provided the human player is player 1, so it's not really what you're after. A better way of doing it (I think this was Wombat's idea) is:

                        Code:
                        int_t THE_HUMAN;
                        
                        HandleEvent(BeginTurn)'NumofPlayers' pre {
                        
                        int_t i;
                        
                            NUM_PLAYERS= preference("NumPlayers");
                            for(i=1; i < NUM_PLAYERS; i=i+1){
                                 if (IsHumanPlayer(i)) {
                        	      THE_HUMAN=i;
                                 }
                            }
                        }
                        so that you can use 'THE_HUMAN' instead of '1'.

                        [ Did you know that if you try to print "i<", it won't print the next few lines?]

                        Comment


                        • #27
                          Originally posted by Peter Triggs
                          Here's the bit that got missed out above:

                          Yes, provided the human player is player 1, so it's not really what you're after. A better way of doing it (I think this was Wombat's idea) is:

                          Code:
                          int_t THE_HUMAN;
                          
                          HandleEvent(BeginTurn)'NumofPlayers' pre {
                          
                          int_t i;
                          
                              NUM_PLAYERS= preference("NumPlayers");
                              for(i=1; i < NUM_PLAYERS; i=i+1){
                                   if (IsHumanPlayer(i)) {
                          	      THE_HUMAN=i;
                                   }
                              }
                          }
                          so that you can use 'THE_HUMAN' instead of '1'.
                          I came up with it independantly, but I think I saw it somewhere else first. Diplomod or Frenzy perhaps

                          [ Did you know that if you try to print "i<", it won't print the next few lines?]
                          lol, yeah, it assumes you're using html code and ignores it. Very useful for inserting null html code into swearwords to avoid the autocensor
                          Concrete, Abstract, or Squoingy?
                          "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

                          Comment


                          • #28
                            YEEEEEEEEEES!!!!!!!!

                            Comment


                            • #29
                              YEEEEEEEEEES!!!!!!!!
                              Petter Triggis script WORKS!!!

                              After 10 mounths of playng CTP2 I've seen for FIRST TIME
                              AI's players DOing ANY kind of diplomacy!

                              Now, is there any way to CONVERT Dale's Diplomod, so AIs would use
                              their proposals.
                              Or we should do AI's logic from scratch? I hope not!
                              Last edited by player1; October 13, 2001, 14:26.

                              Comment


                              • #30
                                I ment:
                                Do we need to create AI logic for EVRY sending & receving of proposal, treaty and threat from SCRATCH, or we can by using combination of our scripts & INTERNAL CODE make unbelevabe diplomacy for CIV type game.

                                Comment

                                Working...
                                X