Created
May 26, 2014 11:10
-
-
Save mdakram28/006eb32194a96db35aba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void playNext1(){ | |
ArrayList<Node> temp = new ArrayList<Node>(); | |
//System.out.println(id+" : "+sub_nodes.size()); | |
long max = sub_nodes.get(0).pref; | |
for(int i=0;i<sub_nodes.size();i++) | |
{ | |
if(sub_nodes.get(i).pref > max) | |
{ | |
temp.clear(); | |
temp.add(sub_nodes.get(i)); | |
max = sub_nodes.get(i).pref; | |
} | |
else if(sub_nodes.get(i).pref == max) | |
{ | |
temp.add(sub_nodes.get(i)); | |
} | |
} | |
int choice = (int) (Math.random()*temp.size()); | |
temp.get(choice).n++; | |
temp.get(choice).setAsState(); | |
} | |
public void playNext2(){ | |
ArrayList<Node> temp = new ArrayList<Node>(); | |
//System.out.println(id+" : "+sub_nodes.size()); | |
long min = sub_nodes.get(0).pref; | |
for(int i=0;i<sub_nodes.size();i++) | |
{ | |
if(sub_nodes.get(i).pref < min) | |
{ | |
temp.clear(); | |
temp.add(sub_nodes.get(i)); | |
min = sub_nodes.get(i).pref; | |
} | |
else if(sub_nodes.get(i).pref == min) | |
{ | |
temp.add(sub_nodes.get(i)); | |
} | |
} | |
int choice = (int) (Math.random()*temp.size()); | |
temp.get(choice).n++; | |
temp.get(choice).setAsState(); | |
} | |
public void playNextn(){ | |
ArrayList<Node> temp = new ArrayList<Node>(); | |
//System.out.println(id+" : "+sub_nodes.size()); | |
int choice = 0; | |
long min = sub_nodes.get(0).n; | |
for(int i=0;i<sub_nodes.size();i++) | |
{ | |
if(sub_nodes.get(i).n < min) | |
{ | |
min = sub_nodes.get(i).n; | |
choice = i; | |
} | |
} | |
sub_nodes.get(choice).n++; | |
sub_nodes.get(choice).setAsState(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment