source: src/main/java/onetomany/bargainingchipsgame/oldAggregations.java@ 256

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

Commit #1 of:
+ negotiator.onetomany package refactored into onetomany package.
+ info created for all contained the packages.
+ current work defined under onetomany.bargainingchipsgame.
+ in this package, onetomany.bargainingchipsgame.players package includes packages for utility function, coordinator, negotiatior, and buyer and seller.
+ negotiator.onetomany package now contains nothing, can be deleted.
+ Interaction thread

File size: 16.4 KB
Line 
1package onetomany.bargainingchipsgame;
2//import java.util.Arrays;
3//
4// public Bundle aggregateWith333(Bundle b)
5// {
6// if (b!=null && this!=null)
7// {
8// Bundle l=new Bundle();
9//
10// for (Stack s : b.getBundle())
11// {
12// l=this.aggregateWith(s);
13// }
14// return l;
15// }
16// return this;
17// }
18//
19//public Bundle aggregateWith(Bundle b)
20// {
21// if (b!=null && this!=null)
22// {
23// Bundle l=new Bundle();
24//
25// for (Stack s : b.getBundle())
26// {
27// l=this.aggregateWith(s); // due to parallel actions on all stacks in a nested manner, sometimes some strange results, when the second bundle has multiple stacks (doesn't matter if any shared colors or not!!
28//// Boolean f=false;
29//// for (int i=1; i<this.size();i++)
30//// {
31//// Stack t= this.getBundle().get(i);
32//// t.aggregateWith(s);
33////
34////
35//// for (Stack t : this.getBundle())
36//// {
37//// if (t.getChip().getColor()==s.getChip().getColor())
38//// {
39//// l.addStack(t.aggregateWith(s));
40//// f=true;
41//// }
42//// else
43//// l.addStack(t);
44//// }
45//// if (!f)
46//// l.addStack(s);
47// }
48// return l;
49// }
50// return this;
51// }
52//
53//
54// public int findStack(Stack s)
55// {
56// int i=-1; //not found
57// if (s!=null)
58// for (int j=0;j<this.size();j++)
59// {
60// if (s.getChip().getColor()==this.getStack(j).getChip().getColor())
61// {
62// i=j;
63// break;
64// }
65// }
66// return i;
67// }
68//
69//
70// public Bundle aggregateWith2(Stack s)
71// {
72// if (s!=null && this!=null && findStack(s)>=0)
73// {
74// Bundle b=new Bundle();
75// Boolean f=false;
76//
77// for (int i=0; i<this.size();i++)
78// {
79// Stack t=this.getStack(i);
80// if (t.getChip().getColor()==s.getChip().getColor())
81// {
82// b.addStack(t.aggregateWith(s));
83// f=true;
84// }
85// else
86// b.addStack(t);
87// }
88// if (!f) //s not aggregated with any stack in `this' bundle
89// b.addStack(s);
90// return b;
91// }
92// return this;
93// }
94//
95//
96// public Bundle aggregateWith2(Bundle b)
97// {
98// if (b!=null && this!=null)
99// {
100// Bundle l=new Bundle();
101//
102// for (Stack s : b.getBundle())
103// {
104// l=this.aggregateWith2(s);
105// }
106// return l;
107// }
108// return this;
109// }
110//
111// public Bundle aggregateWith3(Bundle b)
112// {
113// if (b!=null && this!=null)
114// {
115// Bundle l=new Bundle();
116// //Boolean[] f1= {}; //flag for b bundle stack added
117// //Boolean[] f2= {}; //flag for `this' bundle stack added
118// Boolean[] f2 = new Boolean[this.size()]; //flag for `this' bundle stack added
119// Arrays.fill(f2, Boolean.FALSE);
120//
121// for (int j=0;j<b.size();j++) //loop over bundle b stacks
122// {
123// Stack s=b.getStack(j);
124//
125// for (int i=0; i<this.size();i++) //loop over `this' bundle stacks
126// {
127// int k=findStack(s);
128// if (k>=0)
129// {
130// Stack t= this.getStack(k);
131// l.addStack(t.aggregateWith(s));
132// //f1[j]=true; // this stack of b bundle considered into the new bundle
133// f2[k]=true; // this stack of `this' bundle considered into the new bundle
134// }
135// else
136// {
137// l.addStack(s);
138// //f1[j]=true; // this stack of b bundle directly added into the new bundle
139// }
140// }
141// }
142// for (int i=1;i<this.size();i++)
143// if (f2[i]!=true)
144// l.addStack(this.getStack(i));
145//
146// //and no need to check for f1, because in if or else above have been considered
147//
148// return l;
149// }
150// return this;
151// }
152//
153//
154// public Bundle aggregateWith333(Bundle b)
155// {
156// if (b!=null && this!=null)
157// {
158// Bundle l=new Bundle();
159//
160// for (Stack s : b.getBundle())
161// {
162// l=this.aggregateWith3(s);
163// }
164// return l;
165// }
166// return this;
167// }
168//
169//
170// public Bundle aggregateWith4(Bundle b)
171// {
172// if (b!=null && this!=null)
173// {
174// Bundle l=new Bundle();
175// int i;
176// for (i=1;i<this.size();i++)
177// l.addStack(this.getStack(i));
178//
179// for (int j=0;j<b.size();j++) //loop over bundle b stacks
180// {
181// Stack s=b.getStack(j);
182// i=findStack(s);
183// if (i>=0) // the color of j-th stack of bundle b found in i-th stack of `this' bundle
184// {
185// l.aggregateWith2(this.getStack(i)); //aggregate these two stacks into the new bundle l <-- aggregateWith2 stack (difference with aggregateWith5 bundle)
186// }
187// else
188// l.addStack(s); // so put j-th stack of bundle b directly into the new bundle
189// // and other stacks of `this' bundle have already been in the new bundle!
190// }
191// return l;
192// }
193// return this;
194// }
195//
196//
197// public Bundle aggregateWith5(Bundle b)
198// {
199// if (b!=null && this!=null)
200// {
201// Bundle l=new Bundle();
202// int i;
203// for (i=1;i<this.size();i++)
204// l.addStack(this.getStack(i));
205//
206// for (int j=0;j<b.size();j++) //loop over bundle b stacks
207// {
208// Stack s=b.getStack(j);
209// i=findStack(s);
210// if (i>=0) // the color of j-th stack of bundle b found in i-th stack of `this' bundle
211// {
212// l.aggregateWith(this.getStack(i)); //aggregate these two stacks into the new bundle l <-- aggregateWith stack (difference with aggregateWith4 bundle)
213// }
214// else
215// l.addStack(s); // so put j-th stack of bundle b directly into the new bundle
216// // and other stacks of `this' bundle have already been in the new bundle!
217// }
218// return l;
219// }
220// return this;
221// }
222//
223//
224//
225//
226//
227
228
229//OTHER TESTS
230//
231//
232//
233//
234// System.out.println("\nTEST12::: index of stack1 in Bundle1: "+bundle1.findStack(stack1));
235//
236// System.out.println("\nTEST13::: index of stack2 in Bundle1: "+bundle1.findStack(stack2));
237//
238// System.out.println("\nTEST14::: index of null in Bundle1: "+bundle1.findStack(null));
239//
240// s=new Stack(new Chip("Yellow", 8),40);
241//
242// System.out.println("\nTEST15::: index of stack "+s+" in Bundle1: "+bundle1.findStack(s));
243
244//
245//
246//System.out.println("\n*TEST6-02:::Bundle1: "+bundle1+" is aggregated with Stack "+ss+" as follows:\n"+bundle1.aggregateWith2(ss));
247//System.out.println("\n*TEST6:::Bundle1: "+bundle1+" is aggregated with Stack: 40 x Chip(Yellow, 8$) as follows:\n"+bundle1.aggregateWith2(new Stack(new Chip("Yellow", 8),40)));
248//System.out.println("\n*TEST6-03:::Bundle1: "+bundle1+" is aggregated with Stack "+sss+" as follows:\n"+bundle1.aggregateWith2(sss));
249//
250//
251//
252//System.out.println("\n*TEST7:::Bundle1: "+bundle1+" is aggregated with ``null Stack'' as follows:\n"+bundle1.aggregateWith2(ssss));
253//
254//
255//System.out.println("\n-----aggregateWith-----");
256//
257//
258//
259//
260//System.out.println("\n*TEST9-01::: Without shared colors ::: single stack B2: "+b2+" is aggregated with ``null'' bundle5 as follows:\n"+ b2.aggregateWith(bundle5));
261//
262//
263//System.out.println("\n*TEST9-02::: Without shared colors ::: multi stack B1: "+b1+" is aggregated with ``null'' bundle5 as follows:\n"+ b1.aggregateWith(bundle5));
264//
265//
266//System.out.println("\n*TEST9-03::: Without shared colors ::: single stack B2: "+b2+" is aggregated with single stack B5: "+b5+" as follows:\n"+ b2.aggregateWith(b5));
267//
268//System.out.println("\n*TEST9-04::: Without shared colors ::: single stack B2: "+b2+" is aggregated with multi stack B3: "+b3+" as follows:\n"+ b2.aggregateWith(b3));
269//
270//System.out.println("\n*TEST9-05::: With shared colors ::: single stack B2: "+b2+" is aggregated with single stack B5: "+b6+" as follows:\n"+ b2.aggregateWith(b6));
271//
272//System.out.println("\n*TEST9-06::: With shared colors ::: single stack B2: "+b2+" is aggregated with multi stack B3: "+b1+" as follows:\n"+ b2.aggregateWith(b1));
273//
274//
275//System.out.println("\n*TEST9-07::: With shared colors ::: multi stack B1: "+b1+" is aggregated with multi stack B3: "+b3+" as follows:\n"+ b1.aggregateWith(b3));
276//
277//
278//System.out.println("\n*TEST9-08::: With shared colors ::: multi stack B1: "+b1+" is aggregated with single stack B2: "+b2+" as follows:\n"+ b1.aggregateWith(b2));
279//
280//System.out.println("\n*TEST9-09::: Without shared colors ::: multi stack B1: "+b1+" is aggregated with multi stack B2: "+b4+" as follows:\n"+ b1.aggregateWith(b4));
281//
282//
283//System.out.println("\n-----aggregateWith2-----");
284//
285//
286//System.out.println("\n*TEST10-01::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b2.aggregateWith2(bundle5));
287//
288//
289//System.out.println("\n*TEST10-02::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b1.aggregateWith2(bundle5));
290//
291//
292//System.out.println("\n*TEST10-03::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b5+" as follows:\n"+ b2.aggregateWith2(b5));
293//
294//System.out.println("\n*TEST10-04::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b2.aggregateWith2(b3));
295//
296//System.out.println("\n*TEST10-05::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b6+" as follows:\n"+ b2.aggregateWith2(b6));
297//
298//System.out.println("\n*TEST10-06::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b1+" as follows:\n"+ b2.aggregateWith2(b1));
299//
300//
301//System.out.println("\n*TEST10-07::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b1.aggregateWith2(b3));
302//
303//
304//System.out.println("\n*TEST10-08::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with single stack B2: "+b2+" as follows:\n"+ b1.aggregateWith2(b2));
305//
306//System.out.println("\n*TEST10-09::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B2: "+b4+" as follows:\n"+ b1.aggregateWith2(b4));
307//
308//
309//System.out.println("\n-----BUNDLEaggregateWith4Bundle (& BUNDLEaggregateWith2Stack)-----");
310//
311//
312//System.out.println("\n*TEST10-01::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b2.aggregateWith4(bundle5));
313//
314//
315//System.out.println("\n*TEST10-02::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b1.aggregateWith4(bundle5));
316//
317//
318//System.out.println("\n*TEST10-03::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b5+" as follows:\n"+ b2.aggregateWith4(b5));
319//
320//System.out.println("\n*TEST10-04::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b2.aggregateWith4(b3));
321//
322//System.out.println("\n*TEST10-05::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b6+" as follows:\n"+ b2.aggregateWith4(b6));
323//
324//System.out.println("\n*TEST10-06::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b1+" as follows:\n"+ b2.aggregateWith4(b1));
325//
326//
327//System.out.println("\n*TEST10-07::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b1.aggregateWith4(b3));
328//
329//
330//System.out.println("\n*TEST10-08::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with single stack B2: "+b2+" as follows:\n"+ b1.aggregateWith4(b2));
331//
332//System.out.println("\n*TEST10-09::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B2: "+b4+" as follows:\n"+ b1.aggregateWith4(b4));
333//
334//System.out.println("\n-----BUNDLEaggregateWith5Bundle (& BUNDLEaggregateWithStack)-----");
335//
336//
337//System.out.println("\n*TEST10-01::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b2.aggregateWith5(bundle5));
338//
339//
340//System.out.println("\n*TEST10-02::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b1.aggregateWith5(bundle5));
341//
342//
343//System.out.println("\n*TEST10-03::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b5+" as follows:\n"+ b2.aggregateWith5(b5));
344//
345//System.out.println("\n*TEST10-04::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b2.aggregateWith5(b3));
346//
347//System.out.println("\n*TEST10-05::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b6+" as follows:\n"+ b2.aggregateWith5(b6));
348//
349//System.out.println("\n*TEST10-06::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b1+" as follows:\n"+ b2.aggregateWith5(b1));
350//
351//
352//System.out.println("\n*TEST10-07::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b1.aggregateWith5(b3));
353//
354//
355//System.out.println("\n*TEST10-08::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with single stack B2: "+b2+" as follows:\n"+ b1.aggregateWith5(b2));
356//
357//System.out.println("\n*TEST10-09::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B2: "+b4+" as follows:\n"+ b1.aggregateWith5(b4));
358//
359//
360//System.out.println("\n-----BUNDLEaggregateWith33Bundle (& BUNDLEaggregateWithStack)-----");
361//
362//
363//System.out.println("\n*TEST10-01::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b2.aggregateWith33(bundle5));
364//
365//
366//System.out.println("\n*TEST10-02::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b1.aggregateWith33(bundle5));
367//
368//
369//System.out.println("\n*TEST10-03::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b5+" as follows:\n"+ b2.aggregateWith33(b5));
370//
371//System.out.println("\n*TEST10-04::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b2.aggregateWith33(b3));
372//
373//System.out.println("\n*TEST10-05::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b6+" as follows:\n"+ b2.aggregateWith33(b6));
374//
375//System.out.println("\n*TEST10-06::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b1+" as follows:\n"+ b2.aggregateWith33(b1));
376//
377//
378//System.out.println("\n*TEST10-07::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b1.aggregateWith33(b3));
379//
380//
381//System.out.println("\n*TEST10-08::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with single stack B2: "+b2+" as follows:\n"+ b1.aggregateWith33(b2));
382//
383//System.out.println("\n*TEST10-09::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B2: "+b4+" as follows:\n"+ b1.aggregateWith33(b4));
384//
385//System.out.println("\n-----BUNDLEaggregateWith333Bundle-----");
386//
387//
388//System.out.println("\n*TEST10-01::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b2.aggregateWith333(bundle5));
389//
390//
391//System.out.println("\n*TEST10-02::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with ``null'' bundle5 as follows:\n"+ b1.aggregateWith333(bundle5));
392//
393//
394//System.out.println("\n*TEST10-03::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b5+" as follows:\n"+ b2.aggregateWith333(b5));
395//
396//System.out.println("\n*TEST10-04::: Without shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b2.aggregateWith333(b3));
397//
398//System.out.println("\n*TEST10-05::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with single stack B5: "+b6+" as follows:\n"+ b2.aggregateWith333(b6));
399//
400//System.out.println("\n*TEST10-06::: With shared colors ::: single stack B2: "+b2+" is aggregated2 with multi stack B3: "+b1+" as follows:\n"+ b2.aggregateWith333(b1));
401//
402//
403//System.out.println("\n*TEST10-07::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B3: "+b3+" as follows:\n"+ b1.aggregateWith333(b3));
404//
405//
406//System.out.println("\n*TEST10-08::: With shared colors ::: multi stack B1: "+b1+" is aggregated2 with single stack B2: "+b2+" as follows:\n"+ b1.aggregateWith333(b2));
407//
408//System.out.println("\n*TEST10-09::: Without shared colors ::: multi stack B1: "+b1+" is aggregated2 with multi stack B2: "+b4+" as follows:\n"+ b1.aggregateWith333(b4));
409//
410//
Note: See TracBrowser for help on using the repository browser.