source: src/main/java/negotiator/onetomany/players/UF_IWant3Red.java@ 244

Last change on this file since 244 was 243, checked in by Faria Nassiri Mofakham, 5 years ago

Agent class. Utility_Function interface defined. 8 sample utility functions created and all tested. Now, Bundle has getPrice() and Stack has getColor(). Still, aggregation in Bundle class is without iterators (iterators could not work out yet).

File size: 735 bytes
Line 
1/**
2 * UtilityFunctionIWant3Red class
3 */
4package negotiator.onetomany.players;
5
6import negotiator.onetomany.domain.Bundle;
7import negotiator.onetomany.domain.Stack;
8
9/**
10 * This utility function simply implements a hardheaded behavior
11 * which evaluates as 1 any bundle which includes a stack with 3 Red chips,
12 * and 0, otherwise
13 *
14 * @author Faria Nassiri-Mofakham
15 *
16 */
17public class UF_IWant3Red implements Utility_Function
18{
19
20 @Override
21 public Double getUtility(Bundle b)
22 {
23 if (b!=null)
24 for (Stack s : b)
25 if (s.getColor()=="Red" && s.getQuantity()==3)
26 return 1.0;
27 return 0.0;
28 }
29
30 @Override
31 public String toString()
32 {
33 return this.getClass().getSimpleName();
34 }
35
36}
Note: See TracBrowser for help on using the repository browser.