@matfah/

Token Pass FR 2013

Java

No description

fork
loading
Files
  • Main.java
  • TokenPass.java

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.16200942818445419","path":"Main.java","file":{"path":"Main.java","content":{"asEncoding":{"base64":"aW1wb3J0IGphdmEubGFuZy5yZWZsZWN0Lio7CmltcG9ydCBqYXZhLnV0aWwuKjsKCnB1YmxpYyBjbGFzcyBNYWluIHsKICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAKICAgIGZvcihpbnQgaSA9IDE7IGkgPCAxMjsgaSsrKQogICAgICB0ZXN0Q29uc3RydWN0b3IoaSk7CiAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlRlc3RpbmcgdGhlIFRva2VuUGFzcyBjb25zdHJ1Y3RvciBmaW5pc2hlZCBzdWNjZXNzZnVsbHkhIik7CiAgICBmb3IoaW50IGkgPSAxOyBpIDwgMTI7IGkrKykKICAgICAgdGVzdERpc3RyaWJ1dGVDdXJyZW50UGxheWVyVG9rZW5zKGkpOwogICAgU3lzdGVtLm91dC5wcmludGxuKCJUZXN0aW5nIHRoZSBUb2tlblBhc3MgZGlzdHJpYnV0ZUN1cnJlbnRQbGF5ZXJUb2tlbnMgbWV0aG9kIGZpbmlzaGVkIHN1Y2Nlc3NmdWxseSEiKTsKICAgIFN5c3RlbS5vdXQucHJpbnRsbigiQWxsIHRlc3RzIHBhc3NlZCEiKTsKICB9CiAgCiAgcHVibGljIHN0YXRpYyB2b2lkIHRlc3REaXN0cmlidXRlQ3VycmVudFBsYXllclRva2VucyhpbnQgbikgewogICAgRmllbGQgYm9hcmRGaWVsZCA9IG51bGw7CiAgICAKICAgIHRyeSB7CiAgICAgIGJvYXJkRmllbGQgPSBUb2tlblBhc3MuY2xhc3MuZ2V0RGVjbGFyZWRGaWVsZCgiYm9hcmQiKTsKICAgIH0KICAgIGNhdGNoKEV4Y2VwdGlvbiBlKSB7CiAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRXJyb3IgYWNjZXNzaW5nIGJvYXJkIGluc3RhbmNlIHZhcmlhYmxlIik7CiAgICAgIFN5c3RlbS5leGl0KDApOwogICAgfQogICAgYm9hcmRGaWVsZC5zZXRBY2Nlc3NpYmxlKHRydWUpOwogICAgCiAgICBGaWVsZCBjdXJyZW50UGxheWVyRmllbGQgPSBudWxsOwogICAgCiAgICB0cnkgewogICAgICBjdXJyZW50UGxheWVyRmllbGQgPSBUb2tlblBhc3MuY2xhc3MuZ2V0RGVjbGFyZWRGaWVsZCgiY3VycmVudFBsYXllciIpOwogICAgfQogICAgY2F0Y2goRXhjZXB0aW9uIGUpIHsKICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJFcnJvciBhY2Nlc3NpbmcgY3VycmVudFBsYXllciBpbnN0YW5jZSB2YXJpYWJsZSIpOwogICAgICBTeXN0ZW0uZXhpdCgwKTsKICAgIH0KICAgIGN1cnJlbnRQbGF5ZXJGaWVsZC5zZXRBY2Nlc3NpYmxlKHRydWUpOwogICAgCiAgICBUb2tlblBhc3MgcGFzcyA9IG51bGw7CiAgICAgIAogICAgdHJ5IHsKICAgICAgcGFzcyA9IG5ldyBUb2tlblBhc3Mobik7CiAgICB9CiAgICBjYXRjaChFeGNlcHRpb24gZSkgewogICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkVycm9yIGNvbnN0cnVjdGluZyBUb2tlblBhc3Mgb2JqZWN0Iik7CiAgICAgIFN5c3RlbS5leGl0KDApOwogICAgfQogICAgCiAgICBpbnRbXSBib2FyZCA9IG5ldyBpbnRbbl07CiAgICBpbnRbXSBib2FyZENvcHkgPSBuZXcgaW50W25dOwogICAgZm9yKGludCBpID0gMDsgaSA8IGJvYXJkLmxlbmd0aDsgaSsrKSB7CiAgICAgIGJvYXJkQ29weVtpXSA9IGJvYXJkW2ldID0gKGludCkoTWF0aC5yYW5kb20oKSoxMCkrMTsKICAgIH0KICAgIGludCBjdXJyZW50UGxheWVyID0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gb3B0aW9ucywgc29GYXIgKyBvcHRpb25zW2ldLCBwbGFjZSk7CiAgICB9CiAgfQp9"},"asBuffer":null},"loaded":true}}
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
import java.lang.reflect.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    
    for(int i = 1; i < 12; i++)
      testConstructor(i);
    System.out.println("Testing the TokenPass constructor finished successfully!");
    for(int i = 1; i < 12; i++)
      testDistributeCurrentPlayerTokens(i);
    System.out.println("Testing the TokenPass distributeCurrentPlayerTokens method finished successfully!");
    System.out.println("All tests passed!");
  }
  
  public static void testDistributeCurrentPlayerTokens(int n) {
    Field boardField = null;
    
    try {
      boardField = TokenPass.class.getDeclaredField("board");
    }
    catch(Exception e) {
      System.out.println("Error accessing board instance variable");
      System.exit(0);
    }
    boardField.setAccessible(true);
    
    Field currentPlayerField = null;
    
    try {
      currentPlayerField = TokenPass.class.getDeclaredField("currentPlayer");
    }
    catch(Exception e) {
      System.out.println("Error accessing currentPlayer instance variable");
      System.exit(0);
    }
    currentPlayerField.setAccessible(true);
    
    TokenPass pass = null;
      
    try {
      pass = new TokenPass(n);
    }
    catch(Exception e) {
      System.out.println("Error constructing TokenPass object");
      System.exit(0);
    }
    
    int[] board = new int[n];
    int[] boardCopy = new int[n];
    for(int i = 0; i < board.length; i++) {
      boardCopy[i] = board[i] = (int)(Math.random()*10)+1;
    }
    int currentPlayer = (int)(Math.random()*n);
    
    try {
      boardField.set(pass, board);
      currentPlayerField.set(pass, currentPlayer);
    }
    catch(Exception e) {
      System.out.println("Error setting instance variables");
      System.exit(0);
    }
    
    int count = boardCopy[currentPlayer];
    boardCopy[currentPlayer] = 0;
    
    int pos = currentPlayer+1;
    while(count > 0) {
      boardCopy[pos % boardCopy.length]++;
      count--;
      pos++;
    }
    
    try {
      pass.distributeCurrentPlayerTokens();
    }
    catch(Exception e) {
      System.out.println("Error calling distributeCurrentPlayerTokens()");
      System.exit(0);
    }
    
    try {
      board = (int[])boardField.get(pass);
    }
    catch(Exception e) {
      System.out.println("Error accessing board instance variable");
      System.exit(0);
    }
    
    if(!Arrays.toString(board).equals(Arrays.toString(boardCopy))) {
      System.out.println("distributeCurrentPlayerTokens() is not changing the board instance variable correctly");
      System.exit(0);
    }
    
    try {
      if(currentPlayer != (Integer)currentPlayerField.get(pass)) {
        System.out.println("distributeCurrentPlayerTokens() should NOT change the currentPlayer instance variable");
        System.exit(0);
      }
    }
    catch(Exception e) {
      System.out.println("Error accessing currentPlayer instance variable");
      System.exit(0);
    }
  }
  
  public static void testConstructor(int n) {
    
    Field boardField = null;
    
    try {
      boardField = TokenPass.class.getDeclaredField("board");
    }
    catch(Exception e) {
      System.out.println("Error accessing board instance variable");
      System.exit(0);
    }
    boardField.setAccessible(true);
    
    Field currentPlayerField = null;
    
    try {
      currentPlayerField = TokenPass.class.getDeclaredField("currentPlayer");
    }
    catch(Exception e) {
      System.out.println("Error accessing currentPlayer instance variable");
      System.exit(0);
    }
    currentPlayerField.setAccessible(true);
    
    ArrayList<Character> boards = new ArrayList<Character>();
    ArrayList<Character> currentPlayers = new ArrayList<Character>();
    
    for(int i = 1; i <= 10000; i++) {
    
      TokenPass pass = null;
      
      try {
        pass = new TokenPass(n);
      }
      catch(Exception e) {
        System.out.println("Error constructing TokenPass object");
        System.exit(0);
      }
      
      int[] board = null;
      int currentPlayer = -1;
      
      try {
        board = (int[])boardField.get(pass);
        currentPlayer = (Integer)currentPlayerField.get(pass);
      }
      catch(Exception e) {
        System.out.println("Error accessing TokenPass instance variables");
        System.exit(0);
      }
      
      if(board == null || board.length != n) {
        System.out.println("Constructor does not initialize board instance variable correctly");
        System.exit(0);
      }
      
      if(currentPlayer < 0 || currentPlayer >= n) {
        System.out.println("Constructor does not initialize currentPlayer instance variable within the correct range");
        System.exit(0);
      }
      
      for(int x : board) {
        if(x < 1 || x > 10) {
          System.out.println("Constructor places illegal values in the board instance variable");
          System.exit(0);
        }
        
        boards.add((char)('A' + x));
        currentPlayers.add((char)('A' + currentPlayer));
      }
      
    }
    
    //test for randomness
    Character[] options = new Character[10];
    for(int i = 1; i <= 10; i++)
      options[i-1] = (char)('A' + i);
      
    if(!isRandom(boards, options)) {
      System.out.println("I could be wrong, but I don't think your constructor is randomly generating values correctly!");
      System.exit(0);
    }
    
    options = new Character[n];
    for(int i = 0; i < n; i++)
      options[i] = (char)('A' + i);
    
    if(!isRandom(currentPlayers, options)) {
      System.out.println("I could be wrong, but I don't think your constructor is randomly generating values correctly!");
      System.exit(0);
    }
  }
  
  public static boolean isRandom(ArrayList<Character> boards, Character[] options) {
    
    for(int length = 1; length <= 2; length++) {
      ArrayList<String> allPossibles = new ArrayList<String>();
      stringsOfLength(length, options, "", allPossibles);
      
      TreeMap<String, Integer> frequencyCounts = new TreeMap<String, Integer>();
      for(String x: allPossibles)
        frequencyCounts.put(x, 0);
        
      int total = 0;
      for(int start = 0; start <= boards.size()-length; start++) {
        String temp = "";
        for(int i = start; i < start + length; i++) {
          temp += boards.get(i);
        }
        total++;
        frequencyCounts.put(temp, frequencyCounts.get(temp)+1);
      }
      
      double goal = total / (double)allPossibles.size();
      
      //Math.random() is uniformly distributed... hopefully...
      double variance = 1/12.0 * (allPossibles.size() - 1)*(allPossibles.size() - 1);
      double stdev = Math.sqrt(variance);
      
      //let's assume that 68% of the data should be within one stdev of the goal
      int outliers = 0;
      
      for(String x: allPossibles) {
        
        int count = frequencyCounts.get(x);
        
        if(Math.abs(count - goal) / goal > 0.34)
          outliers++;
      }
      
      if(outliers / (double)total > 0.32) {
        return false;
      }
      
    }
    
    return true;
  }
  
  public static void stringsOfLength(int len, Character[] options, String soFar, ArrayList<String> place) {
    
    if(len == 0) {
      place.add(soFar);
      return;
    }
    
    for(int i = 0; i < options.length; i++) {
        stringsOfLength(len-1, options, soFar + options[i], place);
    }
  }
}