clear all
efficiency = 0.9;  
alpha = 0.5;       
gamma = 1;         
deprecitation = 0.1; 
counter = 1;
for tax1 = .05:.1:.95   
    for investmentrate1 = .05:.1:.95 
        for tax2 = .05:.1:.95            
            for investmentrate2 = .05:.1:.95 
                
                party(1) = 1;
                
                resource(1) = 100; 
                L(1) = 100;        
                
                for t = 1:100       
                    
                    if party(t) == 1
                        tax = tax1;
                        investmentrate = investmentrate1;
                    else
                        tax = tax2;
                        investmentrate = investmentrate2;
                    end;
                    
                    p(t) = efficiency*(resource(t)^alpha)*(L(t)^(1-alpha));
                    L(t+1) = L(t) - deprecitation*L(t) + gamma*investmentrate*tax*p(t);
                    resource(t+1) = (1-tax)*p(t) + (1-investmentrate)*tax*p(t);
                    deltares(t) = resource(t+1) - resource(t); 
                    
                    if deltares(t) >= 0  && party(t) == 1      
                        party(t+1) = 1;
                    elseif deltares(t) >= 0  && party(t) == 2
                        party(t+1) = 2;
                    elseif deltares(t) < 0  && party(t) == 1
                        party(t+1) = 2;
                    elseif deltares(t) < 0  && party(t) == 2
                        party(t+1) = 1;
                    end;
                    
                end;
                out(counter, 1) = tax1;
                out(counter, 2) = investmentrate1;
                out(counter, 3) = tax2;
                out(counter, 4) = investmentrate2;
                out(counter, 5) = sum(resource(91:100)) - sum(resource(81:90));
                counter = counter + 1;
                clear p L resource party                
            end;
        end;
    end;
end;
xlswrite('result4.xls',out,'Sheet1','A2');