Monopoly In MathLab

Writes simon on September 23rd, 2008

Read More: Politics, Science & Technology

I read the blog post by Ian Wright via the Excellent stephen kinsella blog. Basically what he did was to model a type of Monopoly board in Mathimatica. So I decided to see if I could do the same in Mathlab.  Basically the board consists of different squares of varying values. A player roles a dice and moves that many squares. If they can afford to buy and it is not already owned then the players buys the square if it is owned then that player pays rent to the person who owns that land. This was done with 50 Players. After a while one or 2 players will come to rule the board owning most things. This is not dependent on initial condidtions mearly random, chance, luck, What ever you are having your self.  If you run the code a number of times different people win.

And my Mathlab model does the same thing. So what happens if we add a taxation to this model. I.e the people in relative poverty (60% of median income) share between them the tax take of 20% of the money of the people with 20% of the median income.

So firstly after ten goes.

 10 Goes  - http://sheet.zoho.com

 

As can be seen after ten goes the Taxed system seems to be a bit more even balanced then the untaxed system. While after 100 goes. 

100 Goes - http://sheet.zoho.com 

There is clearly a winner in the 100 goes with Tax but their is less inequality. While with the 100 goes and no tax.  One or two people are clearly dominate and the rest have very little.

So there you go. My code is below the fold if you want to have a look at it I cannot say that it is correct 100% but I think it is. 

Code under fold for those interested.

% create the independent variable (vector)

land= zeros(1,50);

for i=1:50,land(i)=i^1.5;end

totalcost=0;

for i=1:50,totalcost=totalcost+land(i);end

numPlayers=50;

players=zeros(2,numPlayers);

initalMoney=totalcost/numPlayers;

for i=1:numPlayers,players(1,i)=0;end

for i=1:numPlayers,players(2,i)=initalMoney; end

 landowner=zeros(50,1); %owner 

 

 for goes=1:100

 

 

 for i=1:numPlayers

     lk=unidrnd(7)-1;

     positionawayfromstart=players(1,i)+lk;

     lk=mod(positionawayfromstart,50)+1;

     players(1,i)=lk;

     if landowner(lk)==0 && players(2,i) > land(lk)

         landowner(lk)=i;

 

         players(2,i)=players(2,i)-land(lk);

     end

     if landowner(lk)~=0 && landowner(lk)~=i

         th=landowner(lk);

         rentowd=land(lk)*0.1; %pay rent at 10

         if players(2,i) >= rentowd

         players(2,i)=players(2,i)-rentowd;

         players(2,th)=players(2,th)+rentowd;

 

         else

            for j=1:50

               if landowner(j)==i && land(j) > rentowd

                  landowner(j)=0;

                     players(2,i)=players(2,i)+land(j);

                     players(2,i)=players(2,i)-rentowd;

                     players(2,th)=players(2,th)+rentowd;

                end 

             end

     end

 

 end

 end

 %tax

 %Find the realitive poverty point

 k=median(players,2);

 realitivepoverty=k(2)*0.6;

%Tax people 20% above median income 20%

 taxtake=0;

   countofpoor=0;

for i=1:numPlayers

 

 if players(2,i)< realitivepoverty

     countofpoor=countofpoor+1;

end

tax=0; %set tax to zero

if players(2,i)>(k(2)*1.2) %if on 20% above median

 

   tax=players(2,i)*0.2; %take tax.

  taxtake=taxtake+tax;

 players(2,i)=players(2,i)-tax;

end

end

%tax person

taxperperson=0

if countofpoor~=0  %stop devide by zero

taxperperson=taxtake/countofpoor;

end

for i=1:numPlayers

  if players(2,i)< realitivepoverty %income less then poverty 

    players(2,i)=players(2,i)+ taxperperson; %get cut of the tax money

end

end

end

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • MisterWong
  • Slashdot
  • StumbleUpon
  • YahooMyWeb

2 Responses to “Monopoly In MathLab”

  1. 0 Stephen Kinsella

    Excellent stuff, really nicely coded, too!

  2. 0 simon

    Thanks. But code could be better looking back on it can see could have used more of MathLabs functions

Posting Your Comment
Please Wait
There was an error with your comment, please try again.