import java.io.FileNotFoundException;
import java.io.IOException;

//
//  ProbCollection.java
//  DecDynProg
//
//  Created by Daniel Bernstein on Sun Nov 09 2003.
//  expanded by Christopher Amato.
//

/**
 * Defines the tranistion, observation and reward matrices
 *
 */
public class ProblemData3Probs {

    public double[][][][] trans, rew;
    
   //OLD====================== double[][][][][][] obs;
    
    public double [][][][][][] obs;
	public double[] startDist;
	
    
	private static void checkSumToOne(double trans[][][][], double obs[][][][][][]) {

        // check that trans probs sum to one
        double count;
        for (int s = 0; s < trans.length; s++) {
            for (int a1 = 0; a1 < trans[0].length; a1++) {
				for (int a2 = 0; a2 < trans[0][0].length; a2++) {
                    count = 0;
					for (int s_ = 0; s_ < trans[0][0][0].length; s_++) {
                        count += trans[s][a1][a2][s_];
                    }
                    if (count > 1.01||count <0.99) {
                        System.out.println("DONT SUM TO ONE STATE! " + count + " " + s + " " + a1 + " " + a2);
      //                  System.exit(1);
                    }
                }
            }
        }
                    
        // check that obs probs sum to one
		for (int s = 0; s < obs[0][0].length; s++) {
			for (int a1 = 0; a1 < obs[0][0][0].length; a1++) {
				for (int a2 = 0; a2 < obs[0][0][0][0].length; a2++) {
					for (int s_ = 0; s_ < obs[0][0][0][0][0].length; s_++) {
						count = 0;
						for (int o1 = 0; o1 < obs.length; o1++) {
							for (int o2 = 0; o2 < obs[0].length; o2++) {
								count += obs[o1][o2][s][a1][a2][s_];
							}
						}
						if (count > 1.01 || count < 0.99) {
							System.out.println("DONT SUM TO ONE OBS! " + count +" s=" + s + " a1=" + a1 + " a2=" + a2+ " s_="+s_ );
		//					System.exit(1);
						}
					}
				}
			}
		}
    }


    public ProblemData3Probs(int problem) {
    
        switch (problem) {
		
		
		                
		                case 9:
		                	
//		                	DEC-MDP recycling robot
							
							System.out.println("My DEC-MDP Recycling Robot Problem...");

							int numStates=2*2;
							int numObs=2;
							int numAct=3;
							
							int numStatesEach =2;
							
							/*The problem can be described as follows:
							 * Each robot chooses to search for the big item, search for the little item,
							 * wait or recharge.  The state is the status of the battery power for each agent
							 * Searching for the big item increases the chance of depleting the battery, and if both
							 * robots get the big item then the reward is higher
							 * Searching for the little item depletes the battery a smaller amount and never fails
							 * Recharging recharges the battery, but does not provide a reward (do this instead of waiting) 
							 * 
							 */
							
							
							
							startDist = new double[numStates];
							startDist[0] = 1.0;
							startDist[1] = 0.0;
							startDist[2] = 0.0;
							startDist[3] = 0.0;
			            
							//actions for each agent are: searchbig, searchlittle, wait and recharge
							//states (the battery status) are high and low for each agent
							//rewards 
							
							//trans[s][a1][a2][s_]
						
							//these are idependent so trans[s1,s2][a1][a2][s1,s2]=trans[s1][a1][s1]*trans[s2][a2][s2]
							double[][][] transEach = new double[numStatesEach][numAct][numStatesEach];
							
							//the prob of staying on high charge after a search for the big item
							double alphaBig=0.5;
							//the prob of staying on high charge after a search for the little item
							double alphaSmall=0.7;
							//the prob of depleting the battery after a search for the big item
							double betaBig=0.3;
							//the prob of depleting the battery after a search for the small item
							double betaSmall=0.2;	
							
							//P(s'|a, s)	
							
							//trans[s][a][s_]
							
							//searching for the big thing has a higher prob of depleting battery 
							//retaining a high battery level after each action
							transEach[0][2][0]=alphaBig;
							transEach[0][1][0]=alphaSmall;
							transEach[0][0][0]=1.0;
							
							//transitioning from the high to the low battery level after each action
							transEach[0][2][1]=(1-alphaBig);
							transEach[0][1][1]=(1-alphaSmall);
							transEach[0][0][1]=0.0;	
							
							//transitioning from low to high on searching means the battery ran out
							transEach[1][2][0]=betaBig;
							transEach[1][1][0]=betaSmall;				
							transEach[1][0][0]=1.0;
							
							transEach[1][2][1]=(1-betaBig);
							transEach[1][1][1]=(1-betaSmall);
							transEach[1][0][1]=0.0;				
											
			                	trans = new double[numStates][numAct][numAct][numStates];
			                System.out.println("trans");
			                	for(int s1=0;s1<numStatesEach;s1++){
			                		for(int s2=0;s2<numStatesEach;s2++){
			                			for(int a1=0;a1<numAct;a1++){
			                				for(int a2=0;a2<numAct;a2++){
			                					for(int s1_=0;s1_<numStatesEach;s1_++){
			                						for(int s2_=0;s2_<numStatesEach;s2_++){
			                							int s=s1*numStatesEach+s2;
			                							int s_=s1_*numStatesEach+s2_;
//			                							 transition function: P[STATES][ACTIONS][ACTIONS][STATES]
			                							trans[s][a1][a2][s_]=transEach[s1][a1][s1_]*transEach[s2][a2][s2_];
			                			//				System.out.println("P["+s+"]["+a1+"]["+a2+"]["+s_+"]="+trans[s][a1][a2][s_]+";");
			                				
			                						}
			                					}
			                				}
			                			}
			                		}
			                	}
			                
			                	
			                //observations are independent too
			                
			                	//P(o|s, a, s')
			                	
			              double[][][][] obsEach = new double[numObs][numStates][numAct][numStates];
			                
			              	for(int s=0;s<numStatesEach;s++){
			              		for(int a=0;a<numAct;a++){
		                				for(int s_=0;s_<numStatesEach;s_++){
		                					for(int o=0;o<numObs;o++){
		                						if(o==s_){
		                							obsEach[o][s][a][s_]=1.0;
		                						}
		                					}
		                				}
			              		}
			              	}
			                
			             
			                //obs[o1][o2][s][a1][a2][s_]
			              obs= new double[numObs][numObs][numStates][numAct][numAct][numStates];
			              System.out.println("obs");
			              for(int o1=0;o1<numObs;o1++){
			              	for(int o2=0;o2<numObs;o2++){
			              		for(int s1=0;s1<numStatesEach;s1++){
			              			for(int s2=0;s2<numStatesEach;s2++){
			              				for(int a1=0;a1<numAct;a1++){
			              					for(int a2=0;a2<numAct;a2++){
			              						for(int s1_=0;s1_<numStatesEach;s1_++){
			              							for(int s2_=0;s2_<numStatesEach;s2_++){
			              								int s=s1*numStatesEach+s2;
			              								int s_=s1_*numStatesEach+s2_;	
			              								obs[o1][o2][s][a1][a2][s_]=obsEach[o1][s1][a1][s1_]*obsEach[o2][s2][a2][s2_];
			              							}
			              						}
		                						}
		                					}
			              			}
			              		}
			              	}
			              }
                  
                          
			             int dep = -10;
			             //only get big when both search for it in the same step
			             int big = 5;
			             //each agent that searches for the small will get that reward (so twice for both searching for small)
			             int small = 2;
			              //the reward when depending on the following state as well
			             double[][][][][] rewDep = new double[2][numStates][numAct][numAct][numStates];

			             
			             //both searching for the big item gets a big reward
			             for(int agent=0;agent<2;agent++){
			             //consider all states since the ones in which a battery is depleted will be overwritten below	
			             	for(int s=0;s<numStates;s++){
			             		for(int s_=0;s_<numStates;s_++){
			              			rewDep[agent][s][2][2][s_]=big;
			             			rewDep[agent][s][2][1][s_]=small;
			             			rewDep[agent][s][1][2][s_]=small;
			             			rewDep[agent][s][1][1][s_]=2*small;
			             			rewDep[agent][s][1][0][s_]=small;
			             			rewDep[agent][s][0][1][s_]=small;
			             		}
			             	}
			             }
			             
			             //remember that other state transitions like 1 to 2 and 2 to 1
			             //mean that one agent has depleted the battery
			             
			             //depleting the battery during any action is bad (except recharging)
			             for(int agent=0;agent<2;agent++){
			             	for(int a1=0;a1<numAct;a1++){
			             		//recharge is 0
			             		if(a1!=0){
			             			for(int a2=0;a2<numAct;a2++){
			             				//neither recharged
			             				if(a2!=0){
			             					//both
			             					rewDep[agent][3][a1][a2][0]=2*dep;
			             					//agent 1
			             					rewDep[agent][3][a1][a2][1]=dep;
			             					//agent 2
			             					rewDep[agent][3][a1][a2][2]=dep;
			             					//agent 1
			             					rewDep[agent][2][a1][a2][0]=dep;
			             					//switch
			             					rewDep[agent][2][a1][a2][1]=dep;
			             					//agent 2
			             					rewDep[agent][1][a1][a2][0]=dep;
			             					//switch
			             					rewDep[agent][1][a1][a2][2]=dep;
			             				}
			             				//agent 2 recharged, agent 1 didn't
			             				else{
			             					//agent 2 was low
			             					rewDep[agent][3][a1][a2][0]=dep;
			             					//agent 2 was high
			             					rewDep[agent][2][a1][a2][0]=dep;
			             				}
			             			}
			             		}
			             		//agent 1 recharged
			             		else{
			             			for(int a2=0;a2<numAct;a2++){
			             				//agent 1 recharged, agent 2 didn't
			             				if(a2!=0){
			             					//agent 1 was low
			             					rewDep[agent][3][a1][a2][0]=dep;
			             					//agent 1 was high
			             					rewDep[agent][1][a1][a2][0]=dep;
			             					
			             				}
			             				//both recharged -- do nothing
			             				
			             			}
			             		}
			             	}
			             }
			             
			             //print out the rewards
			           
			            int ag =0 ; 	
				             for(int s=0;s<numStates;s++){
				             	for(int a1=0;a1<numAct;a1++){
				             		for(int a2=0;a2<numAct;a2++){
				             			for(int s_=0;s_<numStates;s_++){
				             		
				             //				System.out.println("rewDep["+ag+"]["+s+"]["+a1+"]["+a2+"]["+s_+"]="+rewDep[ag][s][a1][a2][s_]);
				             			}
				             		}
				             	}
				             }
			             
			             //rew[agent][state][act1][act2];   
			             rew = new double[2][numStates][numAct][numAct];
			             
			             //R(s, a1, a2)=/Sigma_{i=1}^numStates P(s'|s, a1, a2) * R(s, a1, a2)
			             
			             //rewards are symmetrical
			             for(int agent=0;agent<2;agent++){
			             	for(int s=0;s<numStates;s++){
			             		for(int a1=0;a1<numAct;a1++){
			             			for(int a2=0;a2<numAct;a2++){
			             				for(int s_=0;s_<numStates;s_++){
			             					rew[agent][s][a1][a2]+=trans[s][a1][a2][s_]*rewDep[agent][s][a1][a2][s_];
			             				}
			             			}
			             		}
			             	}
			             }
			            
			            // }	             
			             	//state 0 = battery high for both
			             	
			                //state 1 = battery high for agent 1 and low for agent 2
			                
			                //state 2 = battery low for agent 1 and high for agent 2 
			     
			                //state 3 = battery low for both
			           
			             
			                
			            //    checkSumToOne(trans, obs);
			                
			                
		                	
		                	
		                	break;
		                	
		                	
		                	
		    				
		        			/*************************************************************************************************
		                        BROADCAST OBSERVING MORE
		                    *************************************************************************************************/
		                    

		                	
		        			case 10 :
		        			
		        				

		        	               double[] startDist1 = new double[4];
		        	               startDist1[0] = 1;
		        	               startDist1[1] = 0;
		        	               startDist1[2] = 0;
		        	               startDist1[3] = 0;
		        	               
		        	               double[] startDist2 = new double[4];
		        	               startDist2[0] = 0;
		        	               startDist2[1] = 1;
		        	               startDist2[2] = 0;
		        	               startDist2[3] = 0;
		        	               
		        	               double[] startDist3 = new double[4];
		        	               startDist3[0] = 0.25;
		        	               startDist3[1] = 0.25;
		        	               startDist3[2] = 0.25;
		        	               startDist3[3] = 0.25;
		        	               
		        	               double[] startDist4 = new double[4];
		        	               startDist4[0] = 0;
		        	               startDist4[1] = 0;
		        	               startDist4[2] = 1;
		        	               startDist4[3] = 0;
		        	               
		        	               double[] startDist5 = new double[4];
		        	               startDist5[0] = 0;
		        	               startDist5[1] = 0;
		        	               startDist5[2] = 0;
		        	               startDist5[3] = 1;
		        	               
		        	               startDist = startDist2;


		        	                         trans = new double[4][2][2][4];
		        	                             for (int s = 0; s < trans.length; s++) {
		        	                   for (int a1 = 0; a1 < trans[0].length; a1++) {
		        	                       for (int a2 = 0; a2 < trans[0][0].length; a2++) {
		        	                           for (int s_ = 0; s_ < trans[0][0][0].length; s_++) {
		        	                                                         // the case where neither has something to send
		        	                               if (s == 0) {
		        	                                   switch (s_) {
		        	                                       case 0:
		        	                                           trans[s][a1][a2][s_] = 0.09;
		        	                                           break;
		        	                                       case 1:
		        	                                           trans[s][a1][a2][s_] = 0.81;
		        	                                           break;
		        	                                       case 2:
		        	                                           trans[s][a1][a2][s_] = 0.01;
		        	                                           break;
		        	                                       case 3:
		        	                                           trans[s][a1][a2][s_] = 0.09;
		        	                                           break;
		        	                                       }
		        	                               }
		        	                                                             // the case where only agent 1 has something to send
		        	                               if (s == 1) {
		        	                                   if (a1 == 1) {
		        	                                       switch (s_) {
		        	                                       case 0:
		        	                                           trans[s][a1][a2][s_] = 0.09;
		        	                                           break;
		        	                                       case 1:
		        	                                           trans[s][a1][a2][s_] = 0.81;
		        	                                           break;
		        	                                       case 2:
		        	                                           trans[s][a1][a2][s_] = 0.01;
		        	                                           break;
		        	                                       case 3:
		        	                                           trans[s][a1][a2][s_] = 0.09;
		        	                                           break;
		        	                                       }
		        	                                   }
		        	                                   else {
		        	                                       if (s_ == 1) {
		        	                                           trans[s][a1][a2][s_] = 0.9;
		        	                                       }
		        	                                       else if (s_ == 3) {
		        	                                           trans[s][a1][a2][s_] = 0.1;
		        	                                       }
		        	                                       else {
		        	                                           trans[s][a1][a2][s_] = 0;
		        	                                       }
		        	                                   }
		        	                               }
		        	                                                             // the case where only agent 2 has something to send
		        	                               if (s == 2) {
		        	                                   if (a2 == 1) {
		        	                                       switch (s_) {
		        	                                       case 0:
		        	                                           trans[s][a1][a2][s_] = 0.09;
		        	                                           break;
		        	                                       case 1:
		        	                                           trans[s][a1][a2][s_] = 0.81;
		        	                                           break;
		        	                                       case 2:
		        	                                           trans[s][a1][a2][s_] = 0.01;
		        	                                           break;
		        	                                       case 3:
		        	                                           trans[s][a1][a2][s_] = 0.09;
		        	                                           break;
		        	                                       case 4:
		        	                                           trans[s][a1][a2][s_] = 0;
		        	                                           break;
		        	                                       }
		        	                                   }
		        	                                   else {
		        	                                       if (s_ == 2) {
		        	                                           trans[s][a1][a2][s_] = 0.1;
		        	                                       }
		        	                                       else if (s_ == 3) {
		        	                                           trans[s][a1][a2][s_] = 0.9;
		        	                                       }
		        	                                       else {
		        	                                           trans[s][a1][a2][s_] = 0;
		        	                                       }
		        	                                   }
		        	                               }
		        	                                                             // the case where they both have something to send
		        	                               if (s == 3) {
		        	                                   if (a1 == a2) {
		        	                                       if (s_ == 3) {
		        	                                           trans[s][a1][a2][s_] = 1;
		        	                                       }
		        	                                       else {
		        	                                           trans[s][a1][a2][s_] = 0;
		        	                                       }
		        	                                   }
		        	                                   else if (a1 == 1) {
		        	                                       if (s_ == 2) {
		        	                                           trans[s][a1][a2][s_] = 0.1;
		        	                                       }
		        	                                       else if (s_ == 3) {
		        	                                           trans[s][a1][a2][s_] = 0.9;
		        	                                       }
		        	                                       else {
		        	                                           trans[s][a1][a2][s_] = 0;
		        	                                       }
		        	                                   }
		        	                                   else {
		        	                                       if (s_ == 1) {
		        	                                           trans[s][a1][a2][s_] = 0.9;
		        	                                       }
		        	                                       else if (s_ == 3) {
		        	                                           trans[s][a1][a2][s_] = 0.1;
		        	                                       }
		        	                                       else {
		        	                                           trans[s][a1][a2][s_] = 0;
		        	                                       }
		        	                                   }
		        	                               }
		        	                           }
		        	                       }
		        	                   }
		        	               }
		        	                             obs = new double[5][5][4][2][2][4];
		        	                             // observation rules:
		        	               // 0 = no buffer, no send
		        	               // 1 = no buffer, send
		        	               // 2 = buffer, no send
		        	               // 3 = buffer, send
		        	               // 4 = buffer, collision
		        	                             boolean send1, send2;
		        	               int sendstatus;
		        	                             for (int o1 = 0; o1 < obs.length; o1++) {
		        	                   for (int o2 = 0; o2 < obs[0].length; o2++) {
		        	                       for (int s = 0; s < obs[0][0].length; s++) {
		        	                           for (int a1 = 0; a1 < obs[0][0][0].length; a1++) {
		        	                               for (int a2 = 0; a2 < obs[0][0][0][0].length; a2++) {
		        	                                   for (int s_ = 0; s_ < obs[0][0][0][0][0].length; s_++) {
		        	                                                                         // did node 1 actually attempt to broadcast with a full buffer?
		        	                                       if ((s == 1 || s == 3) && (a1 == 1)) {
		        	                                           send1 = true;
		        	                                       }
		        	                                       else {
		        	                                           send1 = false;
		        	                                       }
		        	                                                                             // did node 2 actually attempt to broadcast with a full buffer?
		        	                                       if ((s == 2 || s == 3) && (a2 == 1)) {
		        	                                           send2 = true;
		        	                                       }
		        	                                       else {
		        	                                           send2 = false;
		        	                                       }

		        	                                       // was there no bradcast, a successful broadcast, or a collision?
		        	                                       if (!send1 && !send2) {
		        	                                           sendstatus = 0;
		        	                                       }
		        	                                       else if (send1 && send2) {
		        	                                           sendstatus = 2;
		        	                                       }
		        	                                       else {
		        	                                           sendstatus = 1;
		        	                                       }
		        	                                                                             if ((sendstatus == 0) && (s_ == 0)) {
		        	                                           if ((o1 == 0) && (o2 == 0)) {
		        	                                               obs[o1][o2][s][a1][a2][s_] = 1;
		        	                                           }
		        	                                       }
		        	                                       else if ((sendstatus == 0) && (s_ == 1)) {
		        	                                           if ((o1 == 2) && (o2 == 0)) {
		        	                                               obs[o1][o2][s][a1][a2][s_] = 1;
		        	                                           }
		        	                                       }
		        	                                       else if ((sendstatus == 0) && (s_ == 2)) {
		        	                                           if ((o1 == 0) && (o2 == 2)) {
		        	                                               obs[o1][o2][s][a1][a2][s_] = 1;
		        	                                           }
		        	                                       }
		        	                                       else if ((sendstatus == 0) && (s_ == 3)) {
		        	                                           if ((o1 == 2) && (o2 == 2)) {
		        	                                               obs[o1][o2][s][a1][a2][s_] = 1;
		        	                                           }
		        	                                       }
		        	                                       else if ((sendstatus == 1) && (s_ == 0)) {
		        	                                           if ((o1 == 1) && (o2 == 1)) {
		        	                                               obs[o1][o2][s][a1][a2][s_] = 1;
		        	                                           }
		        	                                       }
		        	                                       else if ((sendstatus == 1) && (s_ == 1)) {
		        	                                           if ((o1 == 3) && (o2 == 1)) {
		        	                                               obs[o1][o2][s][a1][a2][s_] = 1;
		        	                                           }
		        	                                       }
		        	                                       else if ((sendstatus == 1) && (s_ == 2)) {
		        	                                           if ((o1 == 1) && (o2 == 3)) {
		        	                                               obs[o1][o2][s][a1][a2][s_] = 1;
		        	                                           }
		        	                                       }
		        	                                       else if ((sendstatus == 1) && (s_ == 3)) {
		        	                                           if ((o1 == 3) && (o2 == 3)) {
		        	                                               obs[o1][o2][s][a1][a2][s_] = 1;
		        	                                           }
		        	                                       }
		        	                                       else if (sendstatus == 2) {
		        	                                           if ((o1 == 4) && (o2 == 4)) {
		        	                                               obs[o1][o2][s][a1][a2][s_] = 1;
		        	                                           }
		        	                                       }
		        	                                       else {
		        	                                           if ((o1 == 0) && (o2 == 0)) {
		        	                                               obs[o1][o2][s][a1][a2][s_] = 1;
		        	                                           }
		        	                                       }
		        	                                   }                                                              }
		        	                           }
		        	                       }
		        	                   }
		        	               }
		        	                             
		        	                             rew = new double[2][4][2][2];
		        	                             for (int s = 0; s < rew[0].length; s++) {
		        	                   for (int a1 = 0; a1 < rew[0][0].length; a1++) {
		        	                       for (int a2 = 0; a2 < rew[0][0][0].length; a2++) {
		        	                           if ((s == 3 && a1 == 1 && a2 == 0) || (s == 1 && a1 == 1)) {
		        	                               rew[0][s][a1][a2] = 1.0;
		        	                               rew[1][s][a1][a2] = 1.0;
		        	                           }
		        	                           else if ((s == 3 && a1 == 0 && a2 == 1) || (s == 2 && a2 == 1)) {
		        	                               rew[0][s][a1][a2] = 1.0;
		        	                               rew[1][s][a1][a2] = 1.0;
		        	                           }
		        	                                                     else {
		        	                               rew[0][s][a1][a2] = 0;
		        	                               rew[1][s][a1][a2] = 0;
		        	                           }
		        	                       }
		        	                   }
		        	               }
		        	                             /*
                                                 System.out.println("trans");
                                                 for (int s = 0; s < trans.length; s++) {
                                                   for (int a1 = 0; a1 < trans[0].length; a1++) {
                                                       for (int a2 = 0; a2 < trans[0][0].length; a2++) {
                                                           for (int s_ = 0; s_ < trans[0][0][0].length; s_++) {
                                                               System.out.println("["+(s+1)+", "+(a1+1)+", "+(a2+1)+", "+(s_+1)+"] "+trans[s][a1][a2][s_]);  
                                                               
                                                           }
                                                       }
                                                   }
                                                 }
                                                 System.out.println("obs");
                                                 for (int o1 = 0; o1 < obs.length; o1++) {
                                                   for (int o2 = 0; o2 < obs[0].length; o2++) {
                                                       for (int s_ = 0; s_ < obs[0][0].length; s_++) {
                                                           for (int a1 = 0; a1 < obs[0][0][0].length; a1++) {
                                                               for (int a2 = 0; a2 < obs[0][0][0][0].length; a2++) {
                                                                   for (int s = 0; s < obs[0][0][0][0][0].length; s++) {
                                                                       System.out.println("["+(o1+1)+", "+(o2+1)+", "+(s+1)+", "+(a1+1)+", "+(a2+1)+", "+(s_+1)+"] "+obs[o1][o2][s][a1][a2][s_]);  
                                                                       
                                                                   }
                                                               }
                                                           }
                                                       }   
                                                   }
                                                 }
                                                 
                                                 System.out.println("rew");
                                                 for (int s = 0; s < rew[0].length; s++) {
                                                   for (int a1 = 0; a1 < rew[0][0].length; a1++) {
                                                       for (int a2 = 0; a2 < rew[0][0][0].length; a2++) {
                                                           System.out.println("["+(s+1)+", "+(a1+1)+", "+(a2+1)+"] "+rew[0][s][a1][a2]);  
                                                       }
                                                   }
                                                 }                
                                                 */
                                                 
                                                 
	//	        	               checkSumToOne(trans, obs);
		        	                             break; 
	
		        	   	
                        
                       
                        case 22:
                        	
                        	
                        	//multiagent
                        	 //Tiger-Problem-A
                        	startDist= new double[2];
                		    startDist[0]=0.5;
                		    startDist[1]=0.5;  
                        	
                			// STATES
                			//   0: (hungry tiger, untold riches)
                			//   1: (untold riches, hungry tiger)
                			int m_states = 2;

                			// ACTIONS
                			//   0: openL
                			//   1: openR
                			//   2: listen
                			int m_actions = 3;

                			// OBSERVATIONS
                			//   0: tigerL
                			//   1: tigerR
                			int m_observations = 2;

                			// initial state
                			//m_initialState = new ProbVector(m_states);
                			//m_initialState.SetValueAt(0, 0.5);
                			//m_initialState.SetValueAt(1, 0.5);


                			// transition function: trans[STATES][ACTIONS][ACTIONS][STATES]
                			trans = new double[m_states][m_actions][m_actions][m_states];
                			for (int s=0; s<m_states; s++) {
                				for (int a1=0; a1<m_actions; a1++) {
                					for (int a2=0; a2<m_actions; a2++) {
                						for (int s_=0; s_<m_states; s_++)
                							trans[s][a1][a2][s_] = 0.5;
                					}
                				}
                			}
                			trans[0][2][2][0] = 1.0;
                			trans[0][2][2][1] = 0.0;
                			trans[1][2][2][0] = 0.0;
                			trans[1][2][2][1] = 1.0;

                			
                			// observation function
                			//   obs[OBSERVATIONS][OBSERVATIONS][STATES][ACTIONS][ACTIONS][STATES]
                			obs = new double[m_observations][m_observations][m_states][m_actions][m_actions][m_states];
                			for (int s=0; s<m_states; s++) {
                				for (int a1=0; a1<m_actions; a1++) {
                					for (int a2=0; a2<m_actions; a2++) {
                						for (int o1=0; o1<m_observations; o1++) {
                							for (int o2=0; o2<m_observations; o2++) {
                								for (int s_=0; s_<m_states; s_++) {
                								    obs[o1][o2][s][a1][a2][s_] = 0.25;
                								}
                							}
                						}
                					}
                				}
                			}
                			//Tiger switched without somebody opening --> 0 probability
                			obs[0][0][0][2][2][1] = 0.25;
                			obs[1][0][0][2][2][1] = 0.25;
                			obs[0][1][0][2][2][1] = 0.25;
                			obs[1][1][0][2][2][1] = 0.25;
                			obs[0][0][1][2][2][0] = 0.25;
                			obs[1][0][1][2][2][0] = 0.25;
                			obs[0][1][1][2][2][0] = 0.25;
                			obs[1][1][1][2][2][0] = 0.25;
                			
                			//Tiger stayed, nobody openend, heard different noises
                			obs[0][0][0][2][2][0] = 0.7225;
                			obs[1][0][0][2][2][0] = 0.1275;
                			obs[0][1][0][2][2][0] = 0.1275;
                			obs[1][1][0][2][2][0] = 0.0225;
                			obs[0][0][1][2][2][1] = 0.0225;
                			obs[1][0][1][2][2][1] = 0.1275;
                			obs[0][1][1][2][2][1] = 0.1275;
                			obs[1][1][1][2][2][1] = 0.7225;
                			
                			// reward function A
                			//   rew[STATE][ACTION1][ACTION2]
                			rew = new double[2][m_states][m_actions][m_actions];
                			for(int agent=0;agent<2;agent++){
                				rew[agent][0][0][0] = -50;	
                				rew[agent][0][0][1] = -100;
                				rew[agent][0][1][0] = -100;
                				rew[agent][0][1][1] = 20;	
                				rew[agent][1][0][0] = 20;	
                				rew[agent][1][0][1] = -100;
                				rew[agent][1][1][0] = -100;
                				rew[agent][1][1][1] = -50;

                				rew[agent][0][0][2] = -101;
                				rew[agent][0][2][0] = -101;
                				rew[agent][0][1][2] = 9;	
                				rew[agent][0][2][1] = 9;	
                				rew[agent][1][0][2] = 9;	
                				rew[agent][1][2][0] = 9;	
                				rew[agent][1][1][2]= -101;	
                				rew[agent][1][2][1] = -101;

                				rew[agent][0][2][2] = -2;
                				rew[agent][1][2][2] = -2;
                			}
                        	
                        break;
                        
                    
                   
                     
		                	
		}
	}
  
    

   
   
}

