function war(n,m,p_1,p_2)

 
j=1;
a(1)=n;
b(1)=m;

while (a(j) > 0) & (b(j) > 0)
	x = random('Binomial',a(j),1-(1-p_1/a(j))^(b(j)));
        y = random('Binomial',b(j),1-(1-p_2/b(j))^(a(j)));
	a(j+1)=a(j)-x
	b(j+1)=b(j)-y
	j=j+1;
	end
end
