| 1 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | // Contains Video/Audio/Data network configurations (links) |
|---|
| 3 | class State { |
|---|
| 4 | boolean[] vConfig ; |
|---|
| 5 | boolean[] aConfig ; |
|---|
| 6 | boolean[] dConfig ; |
|---|
| 7 | float time ; |
|---|
| 8 | int N2 ; |
|---|
| 9 | int N ; |
|---|
| 10 | ////////////////////////// |
|---|
| 11 | State(int n) { |
|---|
| 12 | reset(n) ; |
|---|
| 13 | } |
|---|
| 14 | State(String dconf, String aconf, String vconf) { |
|---|
| 15 | int n = dconf.length() ; |
|---|
| 16 | reset(n) ; |
|---|
| 17 | for (int u=0;u<N2;u++) { |
|---|
| 18 | dConfig[u] = (dconf.charAt(u)=='1') ; |
|---|
| 19 | aConfig[u] = (aconf.charAt(u)=='1') ; |
|---|
| 20 | vConfig[u] = (vconf.charAt(u)=='1') ; |
|---|
| 21 | } |
|---|
| 22 | } |
|---|
| 23 | void reset(int n) { |
|---|
| 24 | vConfig = new boolean[n] ; |
|---|
| 25 | aConfig = new boolean[n] ; |
|---|
| 26 | dConfig = new boolean[n] ; |
|---|
| 27 | N2 = n ; |
|---|
| 28 | N = int(sqrt(N2)) ; |
|---|
| 29 | } |
|---|
| 30 | ////////////////////////// |
|---|
| 31 | boolean isLink(int type, int i, int j) { |
|---|
| 32 | boolean res = false ; |
|---|
| 33 | if(N*i+j<N*N) { |
|---|
| 34 | if(type==0) |
|---|
| 35 | res = (i!=j && dConfig[N*i + j]) ; |
|---|
| 36 | else if(type==1) |
|---|
| 37 | res = (i!=j && aConfig[N*i + j]) ; |
|---|
| 38 | else if(type==2) |
|---|
| 39 | res = (i!=j && vConfig[N*i + j]) ; |
|---|
| 40 | } |
|---|
| 41 | return res ; |
|---|
| 42 | } |
|---|
| 43 | ////////////////////////// |
|---|
| 44 | boolean isAnyLink(int i, int j) { |
|---|
| 45 | boolean res = false ; |
|---|
| 46 | if(N*i+j<N*N) { |
|---|
| 47 | res = (i!=j && dConfig[N*i + j]) || (i!=j && aConfig[N*i + j]) || (i!=j && vConfig[N*i + j]) ; |
|---|
| 48 | } |
|---|
| 49 | return res ; |
|---|
| 50 | } |
|---|
| 51 | ////////////////////////// |
|---|
| 52 | String getConfigString(int type) { |
|---|
| 53 | String res = "" ; |
|---|
| 54 | boolean[] ll = new boolean[N2]; |
|---|
| 55 | if(type==0) ll = dConfig ; |
|---|
| 56 | if(type==1) ll = aConfig ; |
|---|
| 57 | if(type==2) ll = vConfig ; |
|---|
| 58 | for(int u=0;u<N2;u++) { |
|---|
| 59 | if(ll[u]) res += "1" ; |
|---|
| 60 | else res += "0" ; |
|---|
| 61 | } |
|---|
| 62 | return res ; |
|---|
| 63 | } |
|---|
| 64 | ////////////////////////// |
|---|
| 65 | } |
|---|
| 66 | ///////////////////////////////////////////////// |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|