source: src/main/java/agents/anac/y2014/KGAgent/BidGenerationChange.java@ 126

Last change on this file since 126 was 126, checked in by Aron Hammond, 6 years ago

Added function to calculate opposition to MultiLateralAnalysis.java

Moved code to add RLBOA listeners to RLBOAUtils is misc package

Added input for strategyParameters to SessionPanel (gui)

!! close SessionInfo after tournament; this caused /tmp/ to fill up with GeniusData files

Our own package:

  • Added opponents and strategies that are mentioned in the report
  • Change class hierarchy, agents can now extend from RLBOAagentBilateral to inherit RL functionality.
  • States extend from AbstractState
File size: 2.8 KB
Line 
1package agents.anac.y2014.KGAgent;
2
3import java.util.ArrayList;
4import java.util.List;
5import java.util.Random;
6
7import agents.anac.y2014.kGA_gent.library_genetic.Gene;
8import agents.anac.y2014.kGA_gent.library_genetic.GenerationChange;
9
10public class BidGenerationChange implements GenerationChange{
11
12 /**
13 * @param args
14 */
15 public static void main(String[] args) {
16 // TODO 自動çâ€?Ÿæˆ�ã�•ã‚Œã�Ÿãƒ¡ã‚½ãƒƒãƒ‰ãƒ»ã‚¹ã‚¿ãƒ–
17
18 }
19
20
21 int size = 50;
22
23 int end = 40;
24
25 double line = 2.0;
26
27 static Random rnd=null;
28
29 int gen = 0;
30
31 public BidGenerationChange() {
32
33 //System.out.println("Call BidGenerationChange Instance");
34 if(rnd==null){
35 rnd = new Random();
36 }
37 }
38 public BidGenerationChange(int size) {
39
40 this.size =size;
41 //System.out.println("Call BidGenerationChange Instance");
42 if(rnd==null){
43 rnd = new Random();
44 }
45 }
46
47 public BidGenerationChange(int size,int gen) {
48
49 end=gen;
50 this.size =size;
51 //System.out.println("Call BidGenerationChange Instance");
52 if(rnd==null){
53 rnd = new Random();
54 }
55 }
56
57 /*
58 * トーナメント戦略 ランダム�個体�択肢��1番�2番�交�を行�
59 */
60 static int tornament = 8;
61
62
63 @Override
64 public List<Gene> Generation(List<Gene> list) {
65 // TODO 自動çâ€?Ÿæˆ�ã�•ã‚Œã�Ÿãƒ¡ã‚½ãƒƒãƒ‰ãƒ»ã‚¹ã‚¿ãƒ–
66
67 //System.out.println("call Generation");
68
69 ArrayList<Gene> ret = new ArrayList<Gene>(size);
70
71 int f=size-2,s=size-1,buf;
72
73 gen ++;
74
75 MyBidGene bufBidGene = (MyBidGene)list.get(0);
76
77 ret.add(new MyBidGene(bufBidGene));
78
79 while (ret.size() < size) {
80
81 f=size-2;
82 s=size-1;
83
84
85 for (int i = 0; i < tornament; i++) {
86
87 buf = rnd.nextInt(size);
88
89 s = Math.min(buf, s);
90 f = Math.min(s, f);
91
92 }
93 Gene b = list.get(s).Cros(list.get(f));
94 b.Mutate();
95 ret.add(b);
96 }
97
98 //System.out.println("end Generation");
99
100
101 return ret;
102 }
103
104 @Override
105 public List<Gene> StartGeneration(Gene gene) {
106 // TODO 自動çâ€?Ÿæˆ�ã�•ã‚Œã�Ÿãƒ¡ã‚½ãƒƒãƒ‰ãƒ»ã‚¹ã‚¿ãƒ–
107 List<Gene> ret = new ArrayList<Gene>(size);
108 while (ret.size()<size) {
109 ret.add(new MyBidGene());
110 }
111 return ret;
112 }
113
114 public List<Gene> StartGeneration() {
115 // TODO 自動çâ€?Ÿæˆ�ã�•ã‚Œã�Ÿãƒ¡ã‚½ãƒƒãƒ‰ãƒ»ã‚¹ã‚¿ãƒ–
116 // System.out.println("Calll StartGeneration");
117 List<Gene> ret = new ArrayList<Gene>(size);
118 while (ret.size()<size) {
119 ret.add(new MyBidGene());
120 }
121 return ret;
122 }
123
124 @Override
125 public boolean End(List<Gene> list) {
126 // TODO 自動çâ€?Ÿæˆ�ã�•ã‚Œã�Ÿãƒ¡ã‚½ãƒƒãƒ‰ãƒ»ã‚¹ã‚¿ãƒ–
127 if(gen > end){
128 return true;
129 }
130 return false;
131 }
132
133}
Note: See TracBrowser for help on using the repository browser.