forked from drocco/CrowdSourcing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTurker.java
More file actions
34 lines (29 loc) · 945 Bytes
/
Turker.java
File metadata and controls
34 lines (29 loc) · 945 Bytes
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
import java.util.Random;
public class Turker {
private float rightPercentage;
@SuppressWarnings("unused")
private int responseTime;//not used for now
@SuppressWarnings("unused")
private int moneyCost;//not used yet
private static Random rand = new Random();//static because I'm afraid that we might end up with a lot of turkers with same seed
public Turker(float rightPercentage, int responseTime, int moneyCost) {
super();
this.rightPercentage = rightPercentage;
this.responseTime = responseTime;
this.moneyCost = moneyCost;
}
public int answerQuestion(Question q){
if(rand.nextFloat() <= rightPercentage) {
return q.getRightChoice();
} else {//Ugly code but I think it works... should probably improve this
int pick = rand.nextInt(q.getNumberOfChoices() - 1) + 1;
if(pick >= q.getRightChoice()) {
pick++;
}
return pick;
}
}
public float getRightPercentage() {
return rightPercentage;
}
}