bool BoardEvaluator::IsFinished(Board &board, Colour *winningColour) { for (unsigned int i = 0; i < WIDTH; i++) { for (unsigned int j = 0; j < HEIGHT; j++) { Counter *counter = board.Space(i, j); if (counter != NULL) { // creating the dirctions to be searched in. North north(i, j); South south(i, j); East east(i, j); West west(i, j); NorthEast northEast(i, j); NorthWest northWest(i, j); SouthEast southEast(i, j); SouthWest southWest(i, j); bool retVal = false; Colour retCol = NULL_COLOUR; unsigned int conLength = CONNECT_LENGTH; Colour colour = (Colour)counter->GetColour(); if (RecursiveSearch(colour, &north, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &south, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &east, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &west, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &northEast, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &northWest, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &southEast, conLength - 1, board)) { retCol = colour; retVal = true; } if (RecursiveSearch(colour, &southWest, conLength - 1, board)) { retCol = colour; retVal = true; } if (retVal) { *winningColour = retCol; return true; } } } } return false; }
rectangle(WIDTH, HEIGHT), rectangle(WIDTH, HEIGHT) ^ blob(bulk), blob(bulk) ^ bulk, 0, blob(bulk) ^ bulk, rectangle(WIDTH, HEIGHT) ^ blob(bulk), 0, 0, }; state *bulky_ten = &bulky_ten_; bulky_ten->ko = 0; state cho1_4_ = (state) { rectangle(9, 3), rectangle(9, 3) ^ rectangle(7, 2) ^ (3ULL << 7) ^ (1ULL << (2 * V_SHIFT)), south(east(rectangle(4, 1))), 0, 0, 0, 0, 0 }; state *cho1_4 = &cho1_4_; cho1_4->immortal = cho1_4->player; cho1_4->target = cho1_4->opponent; state cho1_ = cho1_4_; state *cho1 = &cho1_; cho1->opponent |= 1ULL << V_SHIFT; state cho2_ = cho1_;
AZ_MATRIX *user_Ke_build(struct user_partition *Edge_Partition) { double dcenter, doff, sigma = .0001; int ii,jj, horv, i, nx, global_id, nz_ptr, Nlocal_edges; /* Aztec matrix and temp variables */ int *Ke_bindx, *Ke_data_org = NULL; double *Ke_val; AZ_MATRIX *Ke_mat; int proc_config[AZ_PROC_SIZE], *cpntr = NULL; int *reordered_glob_edges = NULL, *reordered_edge_externs = NULL; Nlocal_edges = Edge_Partition->Nlocal; nx = (int) sqrt( ((double) Edge_Partition->Nglobal/2) + .00001); Ke_bindx = (int *) malloc((7*Nlocal_edges+1)*sizeof(int)); Ke_val = (double *) malloc((7*Nlocal_edges+1)*sizeof(double)); Ke_bindx[0] = Nlocal_edges+1; dcenter = 2 + 2.*sigma/((double) ( 3 * nx * nx)); doff = -1 + sigma/((double) ( 6 * nx * nx)); for (i = 0; i < Nlocal_edges; i++) { global_id = (Edge_Partition->my_global_ids)[i]; invindex(global_id, &ii, &jj, nx, &horv); nz_ptr = Ke_bindx[i]; Ke_val[i] = dcenter; if (horv == HORIZONTAL) { if (jj != 0) { Ke_bindx[nz_ptr] = north(ii,jj,nx); Ke_val[nz_ptr++] = doff; Ke_bindx[nz_ptr] = east(ii,jj,nx); Ke_val[nz_ptr++] = -1.; if (ii != 0) {Ke_bindx[nz_ptr]=west(ii,jj,nx); Ke_val[nz_ptr++]= 1.;} jj--; } else { Ke_val[i] = 1. + 2.*sigma/((double) ( 3 * nx * nx)); jj = nx-1; } Ke_bindx[nz_ptr] = east(ii,jj,nx); Ke_val[nz_ptr++] = 1.; if (ii != 0){ Ke_bindx[nz_ptr]=west(ii,jj,nx); Ke_val[nz_ptr++]=-1.;} if (jj != 0){ Ke_bindx[nz_ptr]=south(ii,jj,nx); Ke_val[nz_ptr++]=doff;} } else { if (ii != 0) { Ke_bindx[nz_ptr] = north(ii,jj,nx); Ke_val[nz_ptr++] = -1.; Ke_bindx[nz_ptr] = east(ii,jj,nx); Ke_val[nz_ptr++] = doff; if (jj != 0) {Ke_bindx[nz_ptr]=south(ii,jj,nx); Ke_val[nz_ptr++]=1.;} ii--; } else { Ke_val[i] = 1 + 2.*sigma/((double) ( 3 * nx * nx)); ii = nx-1; } Ke_bindx[nz_ptr] = north(ii,jj,nx); Ke_val[nz_ptr++] = 1.; if (ii != 0) {Ke_bindx[nz_ptr]=west(ii,jj,nx); Ke_val[nz_ptr++]=doff;} if (jj != 0) {Ke_bindx[nz_ptr]=south(ii,jj,nx); Ke_val[nz_ptr++]=-1.;} } Ke_bindx[i+1] = nz_ptr; } AZ_set_proc_config(proc_config, COMMUNICATOR); AZ_transform_norowreordering(proc_config, &(Edge_Partition->needed_external_ids), Ke_bindx, Ke_val, Edge_Partition->my_global_ids, &reordered_glob_edges, &reordered_edge_externs, &Ke_data_org, Nlocal_edges, 0, 0, 0, &cpntr, AZ_MSR_MATRIX); AZ_free(reordered_glob_edges); AZ_free(reordered_edge_externs); Edge_Partition->Nghost = Ke_data_org[AZ_N_external]; Ke_mat = AZ_matrix_create( Nlocal_edges ); AZ_set_MSR(Ke_mat, Ke_bindx, Ke_val, Ke_data_org, 0, NULL, AZ_LOCAL); return(Ke_mat); }