MultiAgentDecisionProcess  Release 0.2.1
PolicyDiscrete.cpp
Go to the documentation of this file.
1 
28 #include "PolicyDiscrete.h"
29 #include <stdlib.h>
30 
31 
33 {
35  double randNr= ((double)rand()) / (RAND_MAX + 1.0);
36  double sum=0;
37  Index selected_a=0;
38 
39  for(Index a=0; a<nrA; a++)
40  {
41  sum+=GetActionProb(i, a);
42  if(randNr<=sum)
43  {
44  selected_a=a;
45  break;
46  }
47  }
48  return(selected_a);
49 }