Open processing

I am trying to create a graph demonstrating a capital dependent parrondo paradox - http://parrondoparadox.blogspot.co.uk/2011/02/mathematical-background-of-parrondos.html

I am coding in www.openprocessing.org.

My code is

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// define variables 
int Capital = 0;
int T = 0;
int lambda = 0.5;
float p = 0.495;
float p1 = 0.095;
float p2 = 0.745;
float R1,R2;
int M=3;
//set up canvas
size(480,480);
background(255,255,255);
//draw zero axis
stroke(200, 200, 200);
line(t,height/2-Capital,t+1,height/2-Capital);
//stroke(0,0,0);
 
while (T<100) 
{ 
  R1 = random(0,1);

  T = T+1;
  if (R1 < lambda) // Game A
  {
      if ( R1 < lambda * p )
          Capital = Capital+1;
      else
          Capital = Capital-1;
  }
  
  R2 = random(0,1);
  else
   {
   if ( Capital%M ==0 ) //play coin one of game B
       {
           if (R2 < p1)
               Capital = Capital+1;
           else
               Capital = Capital-1;
       } 
   else                // play coin two of game B
       {
            if (R2 <p2)
                Capital = Capital+1;
            else
                Capital = Capital-1;
       }
   }
}


This is the first time I have either tried to create graphics on c++, or used open processing.

I believe the errors are in my use of the line and stroke functions. Could anyone either explain these, or direct me to my error?

This should produce a graph where the capital decreases on the yaxis as time T increases on the x axis.

Many thanks in advance!
Processing is its own language. This is not C++, and wouldn't compile as C++.

You might want to check out the reference at http://www.processing.org/reference/
Topic archived. No new replies allowed.