OX V1
Dependencies: mbed
Moop.h@0:6182212860fb, 2016-12-05 (annotated)
- Committer:
- arthicha
- Date:
- Mon Dec 05 15:55:28 2016 +0000
- Revision:
- 0:6182212860fb
V1;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
arthicha | 0:6182212860fb | 1 | #include "mbed.h" |
arthicha | 0:6182212860fb | 2 | |
arthicha | 0:6182212860fb | 3 | |
arthicha | 0:6182212860fb | 4 | |
arthicha | 0:6182212860fb | 5 | class Moop |
arthicha | 0:6182212860fb | 6 | { |
arthicha | 0:6182212860fb | 7 | private: |
arthicha | 0:6182212860fb | 8 | int A , B , C , player , button , turn; |
arthicha | 0:6182212860fb | 9 | int WMbox[6]; |
arthicha | 0:6182212860fb | 10 | |
arthicha | 0:6182212860fb | 11 | Moop::Moop() |
arthicha | 0:6182212860fb | 12 | { |
arthicha | 0:6182212860fb | 13 | WMbox[0] = 3; |
arthicha | 0:6182212860fb | 14 | WMbox[1] = 3; |
arthicha | 0:6182212860fb | 15 | WMbox[2] = 3; |
arthicha | 0:6182212860fb | 16 | WMbox[3] = -1; |
arthicha | 0:6182212860fb | 17 | WMbox[4] = -1; |
arthicha | 0:6182212860fb | 18 | WMbox[5] = -1; |
arthicha | 0:6182212860fb | 19 | } |
arthicha | 0:6182212860fb | 20 | |
arthicha | 0:6182212860fb | 21 | void Moop::Check_case1(){ //คนแรกชนะ |
arthicha | 0:6182212860fb | 22 | printf("Player 1 WIN!"); |
arthicha | 0:6182212860fb | 23 | } |
arthicha | 0:6182212860fb | 24 | |
arthicha | 0:6182212860fb | 25 | void Moop::Check_case2(){ //คน2ชนะ |
arthicha | 0:6182212860fb | 26 | printf("Player 2 WIN!"); |
arthicha | 0:6182212860fb | 27 | } |
arthicha | 0:6182212860fb | 28 | |
arthicha | 0:6182212860fb | 29 | void Moop::Check_error(){ //เช็คคนแพ้ |
arthicha | 0:6182212860fb | 30 | if(this->player == 1){ |
arthicha | 0:6182212860fb | 31 | printf("Player 1 LOSE!"); |
arthicha | 0:6182212860fb | 32 | } |
arthicha | 0:6182212860fb | 33 | else{ |
arthicha | 0:6182212860fb | 34 | printf("Player 2 LOSE!"); |
arthicha | 0:6182212860fb | 35 | } |
arthicha | 0:6182212860fb | 36 | } |
arthicha | 0:6182212860fb | 37 | |
arthicha | 0:6182212860fb | 38 | int Moop::Cross(int degree) |
arthicha | 0:6182212860fb | 39 | { |
arthicha | 0:6182212860fb | 40 | if (degree == 0) |
arthicha | 0:6182212860fb | 41 | { |
arthicha | 0:6182212860fb | 42 | return 1; |
arthicha | 0:6182212860fb | 43 | }else if (degree == 180) |
arthicha | 0:6182212860fb | 44 | { |
arthicha | 0:6182212860fb | 45 | return -1; |
arthicha | 0:6182212860fb | 46 | }else |
arthicha | 0:6182212860fb | 47 | { |
arthicha | 0:6182212860fb | 48 | return 0; |
arthicha | 0:6182212860fb | 49 | } |
arthicha | 0:6182212860fb | 50 | } |
arthicha | 0:6182212860fb | 51 | |
arthicha | 0:6182212860fb | 52 | int Moop::Zine(int degree) |
arthicha | 0:6182212860fb | 53 | { |
arthicha | 0:6182212860fb | 54 | if (degree == 90) |
arthicha | 0:6182212860fb | 55 | { |
arthicha | 0:6182212860fb | 56 | return 1; |
arthicha | 0:6182212860fb | 57 | }else if (degree == -90) |
arthicha | 0:6182212860fb | 58 | { |
arthicha | 0:6182212860fb | 59 | return -1; |
arthicha | 0:6182212860fb | 60 | }else |
arthicha | 0:6182212860fb | 61 | { |
arthicha | 0:6182212860fb | 62 | return 0; |
arthicha | 0:6182212860fb | 63 | } |
arthicha | 0:6182212860fb | 64 | } |
arthicha | 0:6182212860fb | 65 | public: |
arthicha | 0:6182212860fb | 66 | int map[5][5][5],rmap[5][5][5]; //store map. |
arthicha | 0:6182212860fb | 67 | int Check1[5][5][5] , Check2[5][5][5]; //convert to x or o map. |
arthicha | 0:6182212860fb | 68 | |
arthicha | 0:6182212860fb | 69 | |
arthicha | 0:6182212860fb | 70 | |
arthicha | 0:6182212860fb | 71 | |
arthicha | 0:6182212860fb | 72 | int Moop::GetCoordinateX() |
arthicha | 0:6182212860fb | 73 | { |
arthicha | 0:6182212860fb | 74 | if (this->WMbox[0] != -1) |
arthicha | 0:6182212860fb | 75 | { |
arthicha | 0:6182212860fb | 76 | return this->WMbox[0]; |
arthicha | 0:6182212860fb | 77 | }else |
arthicha | 0:6182212860fb | 78 | { |
arthicha | 0:6182212860fb | 79 | return this->WMbox[3]; |
arthicha | 0:6182212860fb | 80 | } |
arthicha | 0:6182212860fb | 81 | } |
arthicha | 0:6182212860fb | 82 | |
arthicha | 0:6182212860fb | 83 | int Moop::GetCoordinateY() |
arthicha | 0:6182212860fb | 84 | { |
arthicha | 0:6182212860fb | 85 | if (this->WMbox[1] != -1) |
arthicha | 0:6182212860fb | 86 | { |
arthicha | 0:6182212860fb | 87 | return this->WMbox[1]; |
arthicha | 0:6182212860fb | 88 | }else |
arthicha | 0:6182212860fb | 89 | { |
arthicha | 0:6182212860fb | 90 | return this->WMbox[4]; |
arthicha | 0:6182212860fb | 91 | } |
arthicha | 0:6182212860fb | 92 | } |
arthicha | 0:6182212860fb | 93 | |
arthicha | 0:6182212860fb | 94 | int Moop::GetCoordinateZ() |
arthicha | 0:6182212860fb | 95 | { |
arthicha | 0:6182212860fb | 96 | if (this->WMbox[2] != -1) |
arthicha | 0:6182212860fb | 97 | { |
arthicha | 0:6182212860fb | 98 | return this->WMbox[2]; |
arthicha | 0:6182212860fb | 99 | }else |
arthicha | 0:6182212860fb | 100 | { |
arthicha | 0:6182212860fb | 101 | return this->WMbox[5]; |
arthicha | 0:6182212860fb | 102 | } |
arthicha | 0:6182212860fb | 103 | } |
arthicha | 0:6182212860fb | 104 | |
arthicha | 0:6182212860fb | 105 | void Moop::ChangeOX(int xx, int yy,int zz,int lx,int ly,int lz) |
arthicha | 0:6182212860fb | 106 | { |
arthicha | 0:6182212860fb | 107 | if (xx != -1) |
arthicha | 0:6182212860fb | 108 | { |
arthicha | 0:6182212860fb | 109 | this->WMbox[0] = xx; |
arthicha | 0:6182212860fb | 110 | this->WMbox[1] = yy; |
arthicha | 0:6182212860fb | 111 | this->WMbox[2] = zz; |
arthicha | 0:6182212860fb | 112 | this->WMbox[3] = lx; |
arthicha | 0:6182212860fb | 113 | this->WMbox[4] = ly; |
arthicha | 0:6182212860fb | 114 | this->WMbox[5] = lz; |
arthicha | 0:6182212860fb | 115 | }else |
arthicha | 0:6182212860fb | 116 | { |
arthicha | 0:6182212860fb | 117 | this->WMbox[0] = lx; |
arthicha | 0:6182212860fb | 118 | this->WMbox[1] = ly; |
arthicha | 0:6182212860fb | 119 | this->WMbox[2] = lz; |
arthicha | 0:6182212860fb | 120 | this->WMbox[3] = xx; |
arthicha | 0:6182212860fb | 121 | this->WMbox[4] = yy; |
arthicha | 0:6182212860fb | 122 | this->WMbox[5] = zz; |
arthicha | 0:6182212860fb | 123 | } |
arthicha | 0:6182212860fb | 124 | } |
arthicha | 0:6182212860fb | 125 | |
arthicha | 0:6182212860fb | 126 | void Moop::Choose(int box) |
arthicha | 0:6182212860fb | 127 | { |
arthicha | 0:6182212860fb | 128 | if (box) |
arthicha | 0:6182212860fb | 129 | { |
arthicha | 0:6182212860fb | 130 | this->WMbox[0] = -1; |
arthicha | 0:6182212860fb | 131 | this->WMbox[1] = -1; |
arthicha | 0:6182212860fb | 132 | this->WMbox[2] = -1; |
arthicha | 0:6182212860fb | 133 | }else |
arthicha | 0:6182212860fb | 134 | { |
arthicha | 0:6182212860fb | 135 | this->WMbox[3] = -1; |
arthicha | 0:6182212860fb | 136 | this->WMbox[4] = -1; |
arthicha | 0:6182212860fb | 137 | this->WMbox[5] = -1; |
arthicha | 0:6182212860fb | 138 | } |
arthicha | 0:6182212860fb | 139 | } |
arthicha | 0:6182212860fb | 140 | |
arthicha | 0:6182212860fb | 141 | void Rotate(int role,int pitch,int yaw) |
arthicha | 0:6182212860fb | 142 | { |
arthicha | 0:6182212860fb | 143 | if ((pitch == 90) || (pitch == -90)) //{{1,0,0},{0,cosy,-siny},{0,siny,cosy}}{{cosx,0,+sinx},{0,1,0},{-sinx,0,cosx}} |
arthicha | 0:6182212860fb | 144 | { |
arthicha | 0:6182212860fb | 145 | for (int i=0;i<5;i++) |
arthicha | 0:6182212860fb | 146 | { |
arthicha | 0:6182212860fb | 147 | for (int j=0;j<5;j++) |
arthicha | 0:6182212860fb | 148 | { |
arthicha | 0:6182212860fb | 149 | for(int k=0;k<5;k++) |
arthicha | 0:6182212860fb | 150 | { |
arthicha | 0:6182212860fb | 151 | this->A = ((i-2)*this->Cross(pitch))+((k-2)*this->Zine(pitch)); |
arthicha | 0:6182212860fb | 152 | this->B = ((j-2)*this->Cross(yaw))+((i-2)*this->Zine(pitch)*this->Zine(yaw))-((k-2)*this->Zine(yaw)*this->Cross(pitch)); |
arthicha | 0:6182212860fb | 153 | this->C = ((j-2)*this->Zine(yaw))-((i-2)*this->Cross(yaw)*this->Zine(pitch))+((k-2)*this->Cross(yaw)*this->Cross(pitch)); |
arthicha | 0:6182212860fb | 154 | this->rmap[i+2][j+2][k+2]=this->map[i][j][k]; |
arthicha | 0:6182212860fb | 155 | } |
arthicha | 0:6182212860fb | 156 | } |
arthicha | 0:6182212860fb | 157 | } |
arthicha | 0:6182212860fb | 158 | }else if ((role == 90) || (role == -90)) // {{cosy,0,+siny},{0,1,0},{-siny,0,cosy}}{{1,0,0},{0,cosx,-sinx},{0,sinx,cosx}} |
arthicha | 0:6182212860fb | 159 | { |
arthicha | 0:6182212860fb | 160 | for (int i=0;i<5;i++) |
arthicha | 0:6182212860fb | 161 | { |
arthicha | 0:6182212860fb | 162 | for (int j=0;j<5;j++) |
arthicha | 0:6182212860fb | 163 | { |
arthicha | 0:6182212860fb | 164 | for(int k=0;k<5;k++) |
arthicha | 0:6182212860fb | 165 | { |
arthicha | 0:6182212860fb | 166 | this->A = ((i-2)*this->Cross(yaw)) + ((j-2)*this->Zine(role)*this->Zine(yaw)) +((k-2)*this->Zine(yaw)*this->Cross(role)); |
arthicha | 0:6182212860fb | 167 | this->B = ((j-2)*this->Cross(role))-((k-2)*this->Zine(role)); |
arthicha | 0:6182212860fb | 168 | this->C = -((i-2)*this->Zine(yaw))+((j-2)*this->Cross(yaw)*this->Zine(role))+((k-2)*this->Cross(yaw)*this->Cross(role)); |
arthicha | 0:6182212860fb | 169 | this->rmap[i+2][j+2][k+2]=this->map[i][j][k]; |
arthicha | 0:6182212860fb | 170 | } |
arthicha | 0:6182212860fb | 171 | } |
arthicha | 0:6182212860fb | 172 | } |
arthicha | 0:6182212860fb | 173 | }else |
arthicha | 0:6182212860fb | 174 | { |
arthicha | 0:6182212860fb | 175 | for (int i=0;i<5;i++) |
arthicha | 0:6182212860fb | 176 | { |
arthicha | 0:6182212860fb | 177 | for (int j=0;j<5;j++) |
arthicha | 0:6182212860fb | 178 | { |
arthicha | 0:6182212860fb | 179 | for(int k=0;k<5;k++) |
arthicha | 0:6182212860fb | 180 | { |
arthicha | 0:6182212860fb | 181 | this->A = ((i-2)*this->Cross(yaw))-((j-2)*this->Zine(yaw)); |
arthicha | 0:6182212860fb | 182 | this->B = ((i-2)*this->Zine(yaw))+((j-2)*this->Cross(yaw)); |
arthicha | 0:6182212860fb | 183 | this->C = (k-2); |
arthicha | 0:6182212860fb | 184 | this->rmap[i+2][j+2][k+2]=this->map[i][j][k]; |
arthicha | 0:6182212860fb | 185 | } |
arthicha | 0:6182212860fb | 186 | } |
arthicha | 0:6182212860fb | 187 | } |
arthicha | 0:6182212860fb | 188 | } |
arthicha | 0:6182212860fb | 189 | for (int i=0;i<5;i++) |
arthicha | 0:6182212860fb | 190 | { |
arthicha | 0:6182212860fb | 191 | for (int j=0;j<5;j++) |
arthicha | 0:6182212860fb | 192 | { |
arthicha | 0:6182212860fb | 193 | for(int k=0;k<5;k++) |
arthicha | 0:6182212860fb | 194 | { |
arthicha | 0:6182212860fb | 195 | this->map[i][j][k]=this->rmap[i][j][k]; |
arthicha | 0:6182212860fb | 196 | } |
arthicha | 0:6182212860fb | 197 | } |
arthicha | 0:6182212860fb | 198 | } |
arthicha | 0:6182212860fb | 199 | } |
arthicha | 0:6182212860fb | 200 | |
arthicha | 0:6182212860fb | 201 | int Moop::Update(int i,int j,int k,int turner){ |
arthicha | 0:6182212860fb | 202 | if(1){ |
arthicha | 0:6182212860fb | 203 | |
arthicha | 0:6182212860fb | 204 | switch(turner%2){ // เลือกตำแหน่งคนลง |
arthicha | 0:6182212860fb | 205 | |
arthicha | 0:6182212860fb | 206 | case '0': |
arthicha | 0:6182212860fb | 207 | i-- , j-- , k--; |
arthicha | 0:6182212860fb | 208 | if(this->map[i][j][k] == 0){ |
arthicha | 0:6182212860fb | 209 | this->map[i][j][k] = 5; // 5 = 'x' |
arthicha | 0:6182212860fb | 210 | this->turn++; |
arthicha | 0:6182212860fb | 211 | } |
arthicha | 0:6182212860fb | 212 | else{ |
arthicha | 0:6182212860fb | 213 | this->Check_error(); // ลงไมไ่ด้ |
arthicha | 0:6182212860fb | 214 | } |
arthicha | 0:6182212860fb | 215 | case '1': |
arthicha | 0:6182212860fb | 216 | i-- , j-- , k--; |
arthicha | 0:6182212860fb | 217 | if(this->map[i][j][k] == 0){ |
arthicha | 0:6182212860fb | 218 | this->map[i][j][k] = 6; // 6 = 'o' |
arthicha | 0:6182212860fb | 219 | this->turn++; |
arthicha | 0:6182212860fb | 220 | } |
arthicha | 0:6182212860fb | 221 | else{ |
arthicha | 0:6182212860fb | 222 | this->Check_error(); // ลงไมไ่ด้ |
arthicha | 0:6182212860fb | 223 | } |
arthicha | 0:6182212860fb | 224 | } |
arthicha | 0:6182212860fb | 225 | if(i == 5 or j == 5 or k == 5){ // ลงเกิน map |
arthicha | 0:6182212860fb | 226 | this->Check_error(); |
arthicha | 0:6182212860fb | 227 | } |
arthicha | 0:6182212860fb | 228 | |
arthicha | 0:6182212860fb | 229 | for(i=0 ; i<5 ; i++){ //แนว k |
arthicha | 0:6182212860fb | 230 | for(j=0 ; j<5 ; j++){ |
arthicha | 0:6182212860fb | 231 | for(k=0 ; k<3 ; k++){ |
arthicha | 0:6182212860fb | 232 | if(this->map[i][j][k] and this->map[i][j][k+1] and this->map[i][j][k+2] == 5){ |
arthicha | 0:6182212860fb | 233 | this->Check_case1(); |
arthicha | 0:6182212860fb | 234 | } |
arthicha | 0:6182212860fb | 235 | else if(this->map[i][j][k] and this->map[i][j][k+1] and this->map[i][j][k+2] == 6){ |
arthicha | 0:6182212860fb | 236 | this->Check_case2(); |
arthicha | 0:6182212860fb | 237 | } |
arthicha | 0:6182212860fb | 238 | } |
arthicha | 0:6182212860fb | 239 | } |
arthicha | 0:6182212860fb | 240 | } |
arthicha | 0:6182212860fb | 241 | |
arthicha | 0:6182212860fb | 242 | for(i=0 ; i<5 ; i++){ // แนว j |
arthicha | 0:6182212860fb | 243 | for(k=0 ; k<5 ; k++){ |
arthicha | 0:6182212860fb | 244 | for(j=0 ; j<3 ; j++){ |
arthicha | 0:6182212860fb | 245 | if(this->map[i][j][k] and this->map[i][j+1][k] and this->map[i][j+2][k] == 5){ |
arthicha | 0:6182212860fb | 246 | this->Check_case1(); |
arthicha | 0:6182212860fb | 247 | } |
arthicha | 0:6182212860fb | 248 | else if(this->map[i][j][k] and this->map[i][j+1][k] and this->map[i][j+2][k] == 6){ |
arthicha | 0:6182212860fb | 249 | this->Check_case2(); |
arthicha | 0:6182212860fb | 250 | } |
arthicha | 0:6182212860fb | 251 | } |
arthicha | 0:6182212860fb | 252 | } |
arthicha | 0:6182212860fb | 253 | } |
arthicha | 0:6182212860fb | 254 | |
arthicha | 0:6182212860fb | 255 | for(j=0 ; j<5 ; j++){ // แนว i |
arthicha | 0:6182212860fb | 256 | for(k=0 ; k<5 ; k++){ |
arthicha | 0:6182212860fb | 257 | for(i=0 ; i<3 ; i++){ |
arthicha | 0:6182212860fb | 258 | if(this->map[i][j][k] and this->map[i+1][j][k] and this->map[i+2][j][k] == 5){ |
arthicha | 0:6182212860fb | 259 | this->Check_case1(); |
arthicha | 0:6182212860fb | 260 | } |
arthicha | 0:6182212860fb | 261 | else if(this->map[i][j][k] and this->map[i+1][j][k] and this->map[i+2][j][k] == 6){ |
arthicha | 0:6182212860fb | 262 | this->Check_case2(); |
arthicha | 0:6182212860fb | 263 | } |
arthicha | 0:6182212860fb | 264 | } |
arthicha | 0:6182212860fb | 265 | } |
arthicha | 0:6182212860fb | 266 | } |
arthicha | 0:6182212860fb | 267 | |
arthicha | 0:6182212860fb | 268 | for(i=0 ; i<5 ; i++){ // แนวทแยง i เป็นฐานขึ้น |
arthicha | 0:6182212860fb | 269 | for(j=0 ; j<3 ; j++){ |
arthicha | 0:6182212860fb | 270 | for(k=0 ; k<3 ; k++){ |
arthicha | 0:6182212860fb | 271 | if(this->map[i][j][k] and this->map[i][j+1][k+1] and this->map[i][j+2][k+2] == 5){ |
arthicha | 0:6182212860fb | 272 | this->Check_case1(); |
arthicha | 0:6182212860fb | 273 | } |
arthicha | 0:6182212860fb | 274 | else if(this->map[i][j][k] and this->map[i][j+1][k+1] and this->map[i][j+2][k+2] == 6){ |
arthicha | 0:6182212860fb | 275 | this->Check_case2(); |
arthicha | 0:6182212860fb | 276 | } |
arthicha | 0:6182212860fb | 277 | } |
arthicha | 0:6182212860fb | 278 | } |
arthicha | 0:6182212860fb | 279 | } |
arthicha | 0:6182212860fb | 280 | |
arthicha | 0:6182212860fb | 281 | for(j=0 ; j<5 ; j++){ // แนวทแยง j เป็นฐานขึ้น |
arthicha | 0:6182212860fb | 282 | for(i=0 ; i<3 ; i++){ |
arthicha | 0:6182212860fb | 283 | for(k=0 ; k<3 ; k++){ |
arthicha | 0:6182212860fb | 284 | if(this->map[i][j][k] and this->map[i+1][j][k+1] and this->map[i+2][j][k+2] == 5){ |
arthicha | 0:6182212860fb | 285 | this->Check_case1(); |
arthicha | 0:6182212860fb | 286 | } |
arthicha | 0:6182212860fb | 287 | else if(this->map[i][j][k] and this->map[i+1][j][k+1] and this->map[i+2][j][k+2] == 6){ |
arthicha | 0:6182212860fb | 288 | this->Check_case2(); |
arthicha | 0:6182212860fb | 289 | } |
arthicha | 0:6182212860fb | 290 | } |
arthicha | 0:6182212860fb | 291 | } |
arthicha | 0:6182212860fb | 292 | } |
arthicha | 0:6182212860fb | 293 | |
arthicha | 0:6182212860fb | 294 | for(k=0 ; k<5 ; k++){ // แนวทแยง k เป็นฐานขึ้น |
arthicha | 0:6182212860fb | 295 | for(i=0 ; i<3 ; i++){ |
arthicha | 0:6182212860fb | 296 | for(j=0 ; j<3 ; j++){ |
arthicha | 0:6182212860fb | 297 | if(this->map[i][j][k] and this->map[i+1][j+1][k] and this->map[i+2][j+2][k] == 5){ |
arthicha | 0:6182212860fb | 298 | this->Check_case1(); |
arthicha | 0:6182212860fb | 299 | } |
arthicha | 0:6182212860fb | 300 | else if(this->map[i][j][k] and this->map[i+1][j+1][k] and this->map[i+2][j+2][k] == 6){ |
arthicha | 0:6182212860fb | 301 | this->Check_case2(); |
arthicha | 0:6182212860fb | 302 | } |
arthicha | 0:6182212860fb | 303 | } |
arthicha | 0:6182212860fb | 304 | } |
arthicha | 0:6182212860fb | 305 | } |
arthicha | 0:6182212860fb | 306 | |
arthicha | 0:6182212860fb | 307 | for(i=0 ; i<5 ; i++){ // แนวทแยง i เป็นฐานลง |
arthicha | 0:6182212860fb | 308 | for(j=0 ; j<3 ; j++){ |
arthicha | 0:6182212860fb | 309 | for(k=4 ; k>1 ; k--){ |
arthicha | 0:6182212860fb | 310 | if(this->map[i][j][k] and this->map[i][j+1][k-1] and this->map[i][j+2][k-2] == 5){ |
arthicha | 0:6182212860fb | 311 | this->Check_case1(); |
arthicha | 0:6182212860fb | 312 | } |
arthicha | 0:6182212860fb | 313 | else if(this->map[i][j][k] and this->map[i][j+1][k-1] and this->map[i][j+2][k-2] == 6){ |
arthicha | 0:6182212860fb | 314 | this->Check_case2(); |
arthicha | 0:6182212860fb | 315 | } |
arthicha | 0:6182212860fb | 316 | } |
arthicha | 0:6182212860fb | 317 | } |
arthicha | 0:6182212860fb | 318 | } |
arthicha | 0:6182212860fb | 319 | |
arthicha | 0:6182212860fb | 320 | for(j=0 ; j<5 ; j++){ // แนวทแยง j เป็นฐานลง |
arthicha | 0:6182212860fb | 321 | for(i=0 ; i<3 ; i++){ |
arthicha | 0:6182212860fb | 322 | for(k=4 ; k>1 ; k--){ |
arthicha | 0:6182212860fb | 323 | if(this->map[i][j][k] and this->map[i+1][j][k-1] and this->map[i+2][j][k-2] == 5){ |
arthicha | 0:6182212860fb | 324 | this->Check_case1(); |
arthicha | 0:6182212860fb | 325 | } |
arthicha | 0:6182212860fb | 326 | else if(this->map[i][j][k] and this->map[i+1][j][k-1] and this->map[i+2][j][k-2] == 6){ |
arthicha | 0:6182212860fb | 327 | this->Check_case2(); |
arthicha | 0:6182212860fb | 328 | } |
arthicha | 0:6182212860fb | 329 | } |
arthicha | 0:6182212860fb | 330 | } |
arthicha | 0:6182212860fb | 331 | } |
arthicha | 0:6182212860fb | 332 | |
arthicha | 0:6182212860fb | 333 | for(k=0 ; k<5 ; k++){ // แนวทแยง k เป็นฐานลง |
arthicha | 0:6182212860fb | 334 | for(i=0 ; i<3 ; i++){ |
arthicha | 0:6182212860fb | 335 | for(j=4 ; j>1 ; j--){ |
arthicha | 0:6182212860fb | 336 | if(this->map[i][j][k] and this->map[i+1][j-1][k] and this->map[i+2][j-2][k] == 5){ |
arthicha | 0:6182212860fb | 337 | this->Check_case1(); |
arthicha | 0:6182212860fb | 338 | } |
arthicha | 0:6182212860fb | 339 | else if(this->map[i][j][k] and this->map[i+1][j-1][k] and this->map[i+2][j-2][k] == 6){ |
arthicha | 0:6182212860fb | 340 | this->Check_case2(); |
arthicha | 0:6182212860fb | 341 | } |
arthicha | 0:6182212860fb | 342 | } |
arthicha | 0:6182212860fb | 343 | } |
arthicha | 0:6182212860fb | 344 | } |
arthicha | 0:6182212860fb | 345 | for(i=0 ; i<3 ; i++){ // แนวทแยงแบบตัด1 |
arthicha | 0:6182212860fb | 346 | for(j=0 ; j<3 ; j++){ |
arthicha | 0:6182212860fb | 347 | for(k=0 ; k<3 ; k++){ |
arthicha | 0:6182212860fb | 348 | if(this->map[i][j][k] and this->map[i+1][j+1][k+1] and this->map[i+2][j+2][k+2] == 5){ |
arthicha | 0:6182212860fb | 349 | this->Check_case1(); |
arthicha | 0:6182212860fb | 350 | } |
arthicha | 0:6182212860fb | 351 | else if(this->map[i][j][k] and this->map[i+1][j+1][k+1] and this->map[i+2][j+2][k+2] == 6){ |
arthicha | 0:6182212860fb | 352 | this->Check_case2(); |
arthicha | 0:6182212860fb | 353 | } |
arthicha | 0:6182212860fb | 354 | } |
arthicha | 0:6182212860fb | 355 | } |
arthicha | 0:6182212860fb | 356 | } |
arthicha | 0:6182212860fb | 357 | for(i=4 ; i>1 ; i--){ // แนวทแยงแบบตัด2 |
arthicha | 0:6182212860fb | 358 | for(j=0 ; j<3 ; j++){ |
arthicha | 0:6182212860fb | 359 | for(k=0 ; k<3 ; k++){ |
arthicha | 0:6182212860fb | 360 | if(this->map[i][j][k] and this->map[i-1][j+1][k+1] and this->map[i-2][j+2][k+2] == 5){ |
arthicha | 0:6182212860fb | 361 | this->Check_case1(); |
arthicha | 0:6182212860fb | 362 | } |
arthicha | 0:6182212860fb | 363 | else if(this->map[i][j][k] and this->map[i-1][j+1][k+1] and this->map[i-2][j+2][k+2] == 6){ |
arthicha | 0:6182212860fb | 364 | this->Check_case2(); |
arthicha | 0:6182212860fb | 365 | } |
arthicha | 0:6182212860fb | 366 | } |
arthicha | 0:6182212860fb | 367 | } |
arthicha | 0:6182212860fb | 368 | } |
arthicha | 0:6182212860fb | 369 | for(i=4 ; i>1 ; i--){ // แนวทแยงแบบตัด 3 |
arthicha | 0:6182212860fb | 370 | for(j=4 ; j>1 ; j--){ |
arthicha | 0:6182212860fb | 371 | for(k=0 ; k<3 ; k++){ |
arthicha | 0:6182212860fb | 372 | if(this->map[i][j][k] and this->map[i-1][j-1][k+1] and this->map[i-2][j-2][k+2] == 5){ |
arthicha | 0:6182212860fb | 373 | this->Check_case1(); |
arthicha | 0:6182212860fb | 374 | } |
arthicha | 0:6182212860fb | 375 | else if(this->map[i][j][k] and this->map[i-1][j-1][k+1] and this->map[i-2][j-2][k+2] == 6){ |
arthicha | 0:6182212860fb | 376 | this->Check_case2(); |
arthicha | 0:6182212860fb | 377 | } |
arthicha | 0:6182212860fb | 378 | } |
arthicha | 0:6182212860fb | 379 | } |
arthicha | 0:6182212860fb | 380 | } |
arthicha | 0:6182212860fb | 381 | for(i=0 ; i<3 ; i++){ // แนวทแยงแบบตัด4 |
arthicha | 0:6182212860fb | 382 | for(j=4 ; j>1 ; j--){ |
arthicha | 0:6182212860fb | 383 | for(k=0 ; k<3 ; k++){ |
arthicha | 0:6182212860fb | 384 | if(this->map[i][j][k] and this->map[i+1][j-1][k+1] and this->map[i+2][j-2][k+2] == 5){ |
arthicha | 0:6182212860fb | 385 | this->Check_case1(); |
arthicha | 0:6182212860fb | 386 | } |
arthicha | 0:6182212860fb | 387 | else if(this->map[i][j][k] and this->map[i+1][j-1][k+1] and this->map[i+2][j-2][k+2] == 6){ |
arthicha | 0:6182212860fb | 388 | this->Check_case2(); |
arthicha | 0:6182212860fb | 389 | } |
arthicha | 0:6182212860fb | 390 | } |
arthicha | 0:6182212860fb | 391 | } |
arthicha | 0:6182212860fb | 392 | } |
arthicha | 0:6182212860fb | 393 | |
arthicha | 0:6182212860fb | 394 | |
arthicha | 0:6182212860fb | 395 | } |
arthicha | 0:6182212860fb | 396 | |
arthicha | 0:6182212860fb | 397 | } |
arthicha | 0:6182212860fb | 398 | |
arthicha | 0:6182212860fb | 399 | |
arthicha | 0:6182212860fb | 400 | |
arthicha | 0:6182212860fb | 401 | void Moop::Check_map(){ //แสดงthis->map |
arthicha | 0:6182212860fb | 402 | for(this->A=0 ; this->A<5 ; this->A++){ |
arthicha | 0:6182212860fb | 403 | for(this->B=0 ; this->B<5 ; this->B++){ |
arthicha | 0:6182212860fb | 404 | for(this->C=0 ; this->C<5 ; this->C++){ |
arthicha | 0:6182212860fb | 405 | if(this->map[this->A][this->B][this->C] == 5){ |
arthicha | 0:6182212860fb | 406 | this->Check1[this->A][this->B][this->C] = 1; |
arthicha | 0:6182212860fb | 407 | } |
arthicha | 0:6182212860fb | 408 | else if(this->map[this->A][this->B][this->C] == 6){ |
arthicha | 0:6182212860fb | 409 | this->Check2[this->A][this->B][this->C] = 1; |
arthicha | 0:6182212860fb | 410 | } |
arthicha | 0:6182212860fb | 411 | else{ |
arthicha | 0:6182212860fb | 412 | this->Check1[this->A][this->B][this->C] = 0; |
arthicha | 0:6182212860fb | 413 | this->Check2[this->A][this->B][this->C] = 0; |
arthicha | 0:6182212860fb | 414 | } |
arthicha | 0:6182212860fb | 415 | } |
arthicha | 0:6182212860fb | 416 | } |
arthicha | 0:6182212860fb | 417 | } |
arthicha | 0:6182212860fb | 418 | } |
arthicha | 0:6182212860fb | 419 | } |
arthicha | 0:6182212860fb | 420 | |
arthicha | 0:6182212860fb | 421 | |
arthicha | 0:6182212860fb | 422 | |
arthicha | 0:6182212860fb | 423 | |
arthicha | 0:6182212860fb | 424 | |
arthicha | 0:6182212860fb | 425 | |
arthicha | 0:6182212860fb | 426 | |
arthicha | 0:6182212860fb | 427 | |
arthicha | 0:6182212860fb | 428 | |
arthicha | 0:6182212860fb | 429 | |
arthicha | 0:6182212860fb | 430 |