Thread Tools
Old September 26, 2001, 03:39   #1
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
IMPROVED version of DIPLOMOD
Here:

IMPROVED BY: player1
Added:
-WarOver script: AI vs AI wars end after 50 turns
-Embassies more often (3x times)
-Diplomatic personality chage 30% more often

Thanks to Dale for original diplomod.slc

EDIT:

Version 1.1
Added:
-WarOver script: AI vs AI wars end after some time
11-20 turns in war: 2% end war chance (per turn)
21-30 turns in war: 4% end war chance
31-40 turns in war: 6% end war chance
41-50 turns in war: 8% end war chance
51 turns or more in war: 10% end war chance

Thanks to janixx and Immortal Wombat for suggestions.


EDIT:

Version 1.15
Added:
-Ending War sets regard between AIs to +250
(so AIs wont declare war on each other next turn)

EDIT:

Version 1.2 improved by Martin Guhmann
Added:
-Better MP support
Attached Files:
File Type: slc diplomod.slc (23.2 KB, 46 views)

Last edited by player1; November 22, 2001 at 09:19.
player1 is offline  
Old September 26, 2001, 04:46   #2
janilxx
Warlord
 
janilxx's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Finland
Posts: 150
AI vs AI war shouldn't end after 50 turns. Maybe it could be a some kind of random number between x and y
__________________
Jani
janilxx is offline  
Old September 26, 2001, 05:37   #3
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Maybe.

For example:

11-20 turns in war: 1% end war chance
21-30 turns in war: 2% end war chance
31-40 turns in war: 3% end war chance
41-50 turns in war: 4% end war chance
50 turns or more in war: 5% end war chance

Any ideas?

Last edited by player1; September 26, 2001 at 06:41.
player1 is offline  
Old September 26, 2001, 10:09   #4
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 14:48
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
Hey cool

I think perhaps the personalities shouldn't change too much, but as long as the AI isn't constantly switching priorities and never gets anything done, it should be alright.

Quote:
Maybe.

For example:

11-20 turns in war: 1% end war chance
21-30 turns in war: 2% end war chance
31-40 turns in war: 3% end war chance
41-50 turns in war: 4% end war chance
50 turns or more in war: 5% end war chance

Any ideas?
I'd double those percentages, because long AI vs AI wars are boring for the player, and make it easier to clean up through the other end of the empire.
Immortal Wombat is offline  
Old September 26, 2001, 10:47   #5
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Quote:
Originally posted by Immortal Wombat
I think perhaps the personalities shouldn't change too much, but as long as the AI isn't constantly switching priorities and never gets anything done, it should be alright.
In original diplomod v3.6 it changed DIPLOMATIC personality (not STRATEGIC) aproximately once in 150 turns. I changed it to 100 turns.

Quote:
I'd double those percentages, because long AI vs AI wars are boring for the player, and make it easier to clean up through the other end of the empire.
Maybe you'r right. Sometimes after ending of war AI starts new one against same opponent.
player1 is offline  
Old September 26, 2001, 12:50   #6
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Version 1.1 is out!
Look at the top of the thread.
player1 is offline  
Old September 26, 2001, 14:13   #7
Cube
Warlord
 
Cube's Avatar
 
Local Time: 06:48
Local Date: October 31, 2010
Join Date: Nov 2000
Location: El Paso, Tx
Posts: 120
How about making AIs swap techs with each other when they're behind and making the chances of this happening increase the farther they are behind. Bluevoss suggested this in the medmod thread, and I thought it was a good Idea.

Also, In MedMod AIs are going broke, but they don't ask for money. How about making them ask for money once they get below 10,000 gold. I like the war Idea, how about making it so if one of the civs has lost more than 3 or 4 cities, the victim starts sending cease fires, and the atacker starts to consider it.

Edit: I was just reading diplomod(yes, I can read slic, just can't write it well) and saw DIP_request == number. It tells the AI to consider a proposal, but I don't know which proposals represent what number. Could someone tell me what number represents which proposal? I read all the readmes for for diplomod, and can't find this anywhere.

Last edited by Cube; September 26, 2001 at 17:46.
Cube is offline  
Old September 26, 2001, 16:14   #8
Dale
Emperor
 
Dale's Avatar
 
Local Time: 23:48
Local Date: October 31, 2010
Join Date: Dec 2000
Posts: 3,944
One thing I almost had working at the end (before I gave up on the MODding due to time restrictions) was this.

- Set a global counter to keep track of how many times the Human declares war. Let's call this the BadBoy Rating.
- When the BB rating got to a certain level, pick the top two AI's known by the Human and force them to declare war on the Human. These AI's would have a forced trust/regard bonus put on them to increase the chance of combined efforts.
- At certain levels of the BB more and more AI's are forced to declare war on the Human till ALL AI's are at war with the Human. Sort of like Europa's BB rating.

Here's my table I came up with:

- 2 war declarations: 2 AI's declare war on Human.
- 4 war declarations: 3 AI's declare war on Human.
- 7 war declarations: 5 AI's declare war on Human.
- 10 war declarations: ALL AI's declare war on Human.

I almost had it working. The good thing with this method is that since the AI would actually create armies and attack in the three big MODs (AP, MM2 & Cradle), this will force the Human into a war against numerous AI's simulately allied attacks.

However, I ran out of time to implement it.
Dale is offline  
Old September 27, 2001, 00:27   #9
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Quote:
Originally posted by Dale
One thing I almost had working at the end (before I gave up on the MODding due to time restrictions) was this.

- Set a global counter to keep track of how many times the Human declares war. Let's call this the BadBoy Rating.
- When the BB rating got to a certain level, pick the top two AI's known by the Human and force them to declare war on the Human. These AI's would have a forced trust/regard bonus put on them to increase the chance of combined efforts.
- At certain levels of the BB more and more AI's are forced to declare war on the Human till ALL AI's are at war with the Human. Sort of like Europa's BB rating.

Here's my table I came up with:

- 2 war declarations: 2 AI's declare war on Human.
- 4 war declarations: 3 AI's declare war on Human.
- 7 war declarations: 5 AI's declare war on Human.
- 10 war declarations: ALL AI's declare war on Human.

I almost had it working. The good thing with this method is that since the AI would actually create armies and attack in the three big MODs (AP, MM2 & Cradle), this will force the Human into a war against numerous AI's simulately allied attacks.

However, I ran out of time to implement it.
There is a problem:
-Even in such War againt Human, AI's will make AI vs AI Wars, so I need
a way to force alliance between AI's
Any ideas?

Dale, can you give me that code.
Post it here!
player1 is offline  
Old September 27, 2001, 00:38   #10
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Does anybody know how to:
-force AI's to make AI vs AI treaties
(or even consider them)

"
if (that) {
force peace betwen AI1 & AI2
}
"
You get the idea.


P.S. I Know how to force canceling of agreements. That's done in War
Over script (canceling "war agreement")
player1 is offline  
Old September 27, 2001, 00:42   #11
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Quote:
Originally posted by Cube
I was just reading diplomod(yes, I can read slic, just can't write it well) and saw DIP_request == number. It tells the AI to consider a proposal, but I don't know which proposals represent what number. Could someone tell me what number represents which proposal? I read all the readmes for for diplomod, and can't find this anywhere.
Look in aidata folder.
There is file diplomacy-test.txt
player1 is offline  
Old September 27, 2001, 10:56   #12
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 14:48
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
There is no way to force the AI to do anything. What you can do is use the LogRegardEvent function to make the AIs very nice and respectful towards each other. If you do this to both AIs in question, you can get them to have a greater chance of accepting each others proposals.
Immortal Wombat is offline  
Old September 27, 2001, 16:21   #13
Dale
Emperor
 
Dale's Avatar
 
Local Time: 23:48
Local Date: October 31, 2010
Join Date: Dec 2000
Posts: 3,944
AI - AI treaties/alliances
AI treaties/alliances

This is how CTP2 works for AI-AI treaties/alliances:

- For alliance to even be considered, trust AND regard must be over 400. (AI loves and trusts you)
- For normal treaties (except withdraw and peace), trust AND regard must be over 150. (AI likes and respects you)
- For everything else, trust AND regard must be over -250.
- Anything under -250 is war and embargo and demands.

There ARE exceptions to the rules though. The AI diplomacy is not as stupid as it makes itself seem. It will usually accept things that it needs (though the human might not be able to determine why it needs it [see below for explanation of requesting what you just offered]). Hence why some diplomacy tactics of the AI seem stupid.

SLICing AI diplomacy

When it comes to SLICing the AI's proposals, there is NO way we can force the AI into anything. All we can do is try to make the proposal so good that it can't refuse. Hence the "request priority". If we make regard, trust and the request priority high enough, the AI will consider anything. However, this still doesn't guarentee it'll accept. That is determined by the overall goals and wishes of the AI. I don't know any way to affect the goals and wishes of the AI. BTW, these are not the strategic goals and wishes. The overall goals and wishes of the AI determine which strategy-stance, diplomacy-stance, eco-stance, science-stance, military-stance, etc is used. All we can do is influence the decisions of an AI into a certain way. For example, we can't tell the AI which strategic goal to use from goals.txt, but we can make it extremely attractive. This is the same for diplomacy.txt and the others. It's a pity really. The overall top-level is THE one level we could make the biggest leaps in AI advancement.

AI offers back what it just refused

The AI tries to max out the regard/trust bonuses. This causes the "Human requests blah refused, AI offers blah back accepted". When a human initiates certain proposals, the AI doesn't get any regard/trust change. The AI will refuse and propose the same thing in opposite terms if IT gets the regard/trust bonus.

EG: Human offers maps for AI's maps. No regard/trust bonus for AI, Human gets the regard/trust bonus. AI refuses and offers maps for Human maps. AI gets the regard/trust bonus, Human gets no bonus.

Influencing the AI's diplomacy

This is where my theory on what to do in SLIC to force the AI into things comes in.

- We know we can't "tell" an AI what to do, only influence it.
- We know that the AI requires certain levels of trust/regard before certain proposals are even considered.
- We know that the AI considers things via it's overall goals and wishes based on priorities.
- We know that AI diplomacy is always trying to max out trust/regard bonuses for it.

If we add all these points together, we get a very clear picture on how the AI can be influenced a lot better. This is where I was heading with the Diplomod. By changing values in the settings of the AI's diplomacy I was trying to make certain proposals look so attractive it couldn't refuse. All through the Diplomod are examples of where I've tried to influence the AI's into more realistic diplomacy using the above 4 points, but sometimes CTP2's bugs/deficiencies got in the way. I believe I got extremely close to what we needed for CTP2, but AI-AI alliances always alluded me. I did get the AI proposing AI-Human alliances though, that's something new in Civ-genre games.

I hope all this helps out in some way.
Dale is offline  
Old September 28, 2001, 03:07   #14
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Ripped from an old tread (apolyton pack v1.0, page 2) by Petter Triggis:

"What I would have liked to do is to add a new New Proposal: Embassy Treaty."

...


"Next, to get the AI to send a request to establish mutual diplomatic relations, I used the ReactionMotivation event:


code:--------------------------------------------------------------------------------
HandleEvent(ReactionMotivation)'NewDipProposal' pre {

if (!HasAgreement(player[0], player[1], 37) && !AtWarWith(player[0],player[1])
&& HasAdvance(player[0], ID_ADVANCE_BUREAUCRACY)
&& HasAdvance(player[1], ID_ADVANCE_BUREAUCRACY) ){

ConsiderNewProposal(player[0].owner,playe[1].owner,2000,37,0,ID_NONE,ID_NONE,ID_NONE);
}
}

--------------------------------------------------------------------------------


So if they don't have embassys and aren't at war, then as soon as player[0] gets BUREAUCRACY (and player[1] already has it), player[0] will send a New Proposal to player[1] asking to establish diplomatic relations. Then I intercept this message in the NewProposal event:


code:--------------------------------------------------------------------------------
int_t first_type; //initial proposal
int_t second_type; // 'in exchange' proposal

HandleEvent(NewProposal)'RespondToNewProposals' pre {

first_type = GetLastNewProposalType(player[0], player[1], 0);
second_type = GetLastNewProposalType(player[0], player[1], 1);

if ( first_type==37 || second_type == 37 ) {
if (!IsHumanPlayer(player[0]) ){
Event:Accept(player[0], player[1]);
}
}
}
--------------------------------------------------------------------------------


As it stands the default condition is to accept. But I want to work out some more responses so that if it's the human player who's sending the proposal, the AI player may counter with a demand for an advance or gold or something. Anyway, having accepted the proposal it only remains to establish embassys:


code:--------------------------------------------------------------------------------

HandleEvent(Accept)'NewProposalHasBeenAccepted' post {//post

first_type = GetLastNewProposalType(player[0], player[1], 0);
second_type = GetLastNewProposalType(player[0], player[1], 1);

if (first_type == 37 || second_type == 37) {

Event:EstablishEmbassy(player[0],player[1]);
Event:EstablishEmbassy(player[1],player[0]);
}
}

--------------------------------------------------------------------------------


I've just tried this line of thought with the Alliance treaty. It seems to work: you can control when one AI civ will propose an Alliance to another. I guess it's just a matter of writing up the appropriate 'Response logic'. "


LOOK last paragraph! It's maybe posible to FORCE AI alliance!
player1 is offline  
Old September 30, 2001, 16:12   #15
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 13:48
Local Date: October 31, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
Looks like I was wrong about this. What I had in mind was something like:

Code:
HandleEvent(ReactionMotivation) 'WarAndAllianceProposals'  pre {

    if(!IsHumanPlayer(player[0]) && !IsHumanPlayer(player[1])){
         if (TurnsAtWar(player[0],player[1])>0) {// 0 for test
	      // offer cease-fire
	      ConsiderNewProposal(player[0],player[1], 9000,32,0,ID_NONE,ID_NONE,ID_NONE);
	 }
	 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
	      ConsiderNewProposal(player[0], player[1], 2000, 33, 0,ID_NONE,ID_NONE,ID_NONE);
	 }
	 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) ) {
	      //if they don't have a peace treaty, offer one
	           ConsiderNewProposal(player[0], player[1], 2000, 33, 0,ID_NONE,ID_NONE,ID_NONE);
              }
              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);
              }
	 }
    }      
}
In theory this should get AI civs to send proposals to each other, and if you take out the "&& !IsHumanPlayer(player[1])" from the first line, you (the Human) will get these proposals. That's what led me to think that it was just a matter of writing up the response logic: if it's sending the proposals to me it must be sending them to the AI civs. But it's not: they won't send them to each other! The instructions for getting the AI to send new proposals are:

Quote:
At the beginning of every player turn the ReactionMotivation and possibly one or both of the FearMotivation or DesireMotivation events will be triggered. To add a rule which can trigger the sending of a new proposal you should write a SLIC function to handle one of these events. For simplicity it is best to write your handles to be triggered by the ReactionMotivation event. For all of these events, player[0] is the player whose turn it is, and player[1] is the foreigner that would receive the new proposal.

You should access the current diplomacy state for the player using the GetNewProposalPriority function and also call any other functions needed to determine whether or not the player should send a particular new proposal.[b] If it is determined that the proposal should be sent, then call the function ConsiderNewProposal. [\b]If multiple calls to ConsiderNewProposal are made, then the proposal with the highest priority will be sent.
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. I tried several things this afternoon to see if I could get at their motivations. For example, I tried defining a new strategy;

Code:
STRATEGY_GET_OUT_OF_WAR{

     //
    //  DIPLOMACY
    //

    // priority for fear motivations
    FearInvasion        5000
    FearCityDefense     5100
    FearPiracy           900
    FearScienceRank      800
    FearMilitaryRank    4800
    FearTradeRank        800
    FearPollution        900

    // priority for desire motivations
    DesireAttack         800
    DesireGold           900
    DesireScience        900
    DesireMakeFriend    1000
    DesireEnlistFriend  1100

}
which has some hugely increased fear motivations and which I loaded in at the appropriate circumstances. But it didn't make any difference.

I also tried guessing at the 'ConsiderMotivation' function:

Code:
HandleEvent(ComputeMotivations)'TestComputeMotivations' pre {

   ConsiderMotivation(player[0].owner, 5000, 1);//1=FearInvasion?
   ConsiderMotivation(player[0].owner, 1000,11);// 11=DesireMakeFriend?

   message(1,'TestComputeMotivationsM');   
}
but again no luck. And here I'm not sure about what that last parameter does. With different numbers I got the 'Wrong type of argument error'. Does anybody know how this one works?

So there you have it. The instructions I quoted above (from the AI Customization via SLIC document) certainly make it look like we ought to be able to get AI civs to send new proposals to each other. If only they'd given some examples!

BTW: note that this entails that DIPLOMOD's 'DIP_MainRoutine' handler can't be working properly, it uses the ConsiderNewProposal function in the same way.
Peter Triggs is offline  
Old September 30, 2001, 16:31   #16
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Quote:
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.
player1 is offline  
Old September 30, 2001, 18:02   #17
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 13:48
Local Date: October 31, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
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.
Peter Triggs is offline  
Old September 30, 2001, 19:57   #18
Dale
Emperor
 
Dale's Avatar
 
Local Time: 23:48
Local Date: October 31, 2010
Join Date: Dec 2000
Posts: 3,944
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.
Dale is offline  
Old October 1, 2001, 03:11   #19
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Interesting idea, Dale!
player1 is offline  
Old October 1, 2001, 03:19   #20
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Quote:
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]) ).
player1 is offline  
Old October 10, 2001, 03:53   #21
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Quote:
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?
player1 is offline  
Old October 10, 2001, 19:54   #22
Dale
Emperor
 
Dale's Avatar
 
Local Time: 23:48
Local Date: October 31, 2010
Join Date: Dec 2000
Posts: 3,944
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   
///////////////////////////////
     }
}
Dale is offline  
Old October 12, 2001, 17:37   #23
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 13:48
Local Date: October 31, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
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.
Peter Triggs is offline  
Old October 13, 2001, 08:46   #24
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Quote:
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!"
Martin Gühmann is offline  
Old October 13, 2001, 11:08   #25
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 13:48
Local Date: October 31, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
Quote:
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.

Quote:
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'.

Quote:
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.

Quote:
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.
Peter Triggs is offline  
Old October 13, 2001, 11:17   #26
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 13:48
Local Date: October 31, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
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?]
Peter Triggs is offline  
Old October 13, 2001, 12:37   #27
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 14:48
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
Quote:
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

Quote:
[ 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
Immortal Wombat is offline  
Old October 13, 2001, 14:10   #28
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
YEEEEEEEEEES!!!!!!!!
player1 is offline  
Old October 13, 2001, 14:14   #29
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
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 at 14:26.
player1 is offline  
Old October 13, 2001, 14:18   #30
player1
Emperor
 
player1's Avatar
 
Local Time: 15:48
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
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.
player1 is offline  
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 09:48.


Design by Vjacheslav Trushkin, color scheme by ColorizeIt!.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Apolyton Civilization Site | Copyright © The Apolyton Team