Skip to content

Instantly share code, notes, and snippets.

@mdakram28
Created May 26, 2014
Embed
What would you like to do?
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