root/InOutExpositor/dScore.pde

Revision 5972babe7c40454704b75ea69ba2e12d80927eaa, 2.0 kB (checked in by Robin Gareus <robin@…>, 3 years ago)

fixed expositor to compile w/processing-1.0.9

  • Property mode set to 100644
Line 
1////////////////////////////////////////////////////////////
2void drawWantedClients( Client A ) {
3  for(int t=0;t<3;t++) {
4    boolean show = false ;
5    if(t==0 && showType[0]) show = true ;
6    if(t==1 && showType[1]) show = true ;
7    if(t==2 && showType[2]) show = true ;
8
9    if(show) {
10      Vector li = getPreferedList(A,t) ;
11      noStroke() ;
12      fill( getColorType(t), 100 ) ;
13
14      float mS = 0 ;
15      float sE = 0 ;
16      Client copin ;
17
18      for(int u=0;u<li.size();u++) {
19        copin = ((Client)li.elementAt(u)) ;
20        float sc = A.in[t].howMuchWanted( copin.id ) ;
21        if(u==0) mS=sc ;
22
23        sE = sc*100/mS ;
24        ellipse(copin.x(),copin.y(),sE,sE) ;
25      }
26    }
27  }
28}
29//////////////////////////////////////////////////////////////////
30
31String getPreferedListString( Client A, int type)
32{
33  Vector li = getPreferedList(A,type) ;
34  String res = "[" ;
35  for(int u=0;u<li.size();u++) {
36    int copId = ((Client)li.elementAt(u)).id ;
37    res += ((Client)li.elementAt(u)).login ;
38    res += "("+A.in[type].howMuchWanted( copId )+")" ;
39    if(u!=li.size()-1) res+=", " ;
40  }
41  res+="]" ;
42  return res ;
43}
44///////////////////////////////////////////////////////////////
45Vector getPreferedList( Client A, int type )
46{
47  Vector res = new Vector() ;
48  Aspiration asp = A.in[type] ;
49
50  float[] notes = new float[nClients] ;
51  Vector toput = new Vector() ;
52  for(int i=0;i<nClients;i++) {
53    if(i!=A.id) { // do not put me
54      notes[i] = asp.howMuchWanted(i) + random(-3,3) ;
55      toput.add( getClient(i) ) ;
56    }
57  }
58
59  float Max = 999999 ;
60
61  while( toput.size()>0 ) {
62    Client tim ;
63    int h = 0 ;
64    float pMax = -99999 ;
65    for(int y=0;y<toput.size();y++) {
66      tim = (Client)toput.elementAt(y) ;
67      if( notes[tim.id]>pMax && notes[tim.id]<=Max ) {
68        pMax = notes[tim.id] ;
69        h = tim.id ;
70      }
71    }
72    Max = pMax ;
73    if( isLinkPossible(type,h,A.id) ) res.addElement( getClient(h) ) ;
74    toput.removeElement( getClient(h) ) ;
75  }
76
77  return res ;
78}
79////////////////////////////////////////////////////////////////////
80
81
82
83
Note: See TracBrowser for help on using the browser.