int put_stones(t_env *env) { int type_rate[2]; int quantity; int x; int y; int c; static int base_rate[NB_STONE + 1] = { RATE_FOOD, RATE_LINEMATE, RATE_DERAUMERE, RATE_SIBUR, RATE_MENDIANE, RATE_PHIRAS, RATE_THYSTAME}; type_rate[0] = -1; while (++type_rate[0] < NB_STONE + 1) { quantity = get_quantity_by_type(env, type_rate[0]) + 1; c = 1; while (quantity-- && (type_rate[1] = base_rate[type_rate[0]]) >= 0) { x = rand_int(0, env->opt.x); y = rand_int(0, env->opt.y); env->map[y][x].ground[type_rate[0]] = 1; c += put_one(env, type_rate, x, y); } printf("%d %s ont ete poses.\n", c, type_to_str(type_rate[0])); } return (0); }
void put_octet(int value, int size, int fd) { if (size == 1) put_one(value, fd); else if (size == 2) put_two(value, fd); else if (size == 4) put_four(value, fd); return ; }
int totalNQueens(int n) { vector<vector<string>> res; string none(n,'.'); vector<string> temp(n, none); put_one(res, temp, 0, n); return res.size(); }
void disk::put_all(putblocklist_t &blocklist) { if (!m_maxBlockSize) throw be_error("Can't put; engine is read-only"); for (int i = 0; i < blocklist.size(); i++) { put_one(blocklist[i]); } }
void put_one(vector<vector<string>> &res, vector<string> &temp, int now, int max) { if(now == max) res.push_back(temp); for(int i=0; i<max; i++) { bool flag= true; for(int j=0; j<now; j++) if(temp[j][i] == 'Q') { flag = false; break; } int x =now, y=i; while(x >=0 && y>=0 && flag) { if(temp[x][y] == 'Q') flag = false; --x; --y; } x= now, y =i; while(x>=0 && y<max && flag) { if(temp[x][y] == 'Q') flag =false; --x; ++y; } if(flag) { temp[now][i] = 'Q'; put_one(res, temp, now+1, max); temp[now][i] = '.'; } } }
void s3be::put_all(putblocklist_t &blocklist) { std::vector<PutObjectOutcomeCallable> ops; ops.reserve(blocklist.size()); for (int i = 0; i < blocklist.size(); i++) { ops.push_back(put_one(blocklist[i])); } // Collect results for (int i = 0; i < blocklist.size(); i++) { PutObjectOutcome response = ops[i].get(); blocklist[i].success = response.IsSuccess(); // Only cache succesful puts if (response.IsSuccess()) m_cache.put(blocklist[i].id, blocklist[i].mem); else blocklist[i].failureReason = response.GetError().GetMessage(); } }
int put_one(t_env *env, int type_rate[2], int x, int y) { int r; r = 0; if (type_rate[1] > 0 && rand_int(0, 100) <= type_rate[1]) { env->map[y][x].ground[type_rate[0]]++; r++; type_rate[1] -= 5; if (x == 0) r += put_one(env, type_rate, env->opt.x - 1, y); else r += put_one(env, type_rate, x - 1, y); r += put_one(env, type_rate, (x + 1) % env->opt.x, y); r += put_one(env, type_rate, x, (y + 1) % env->opt.y); if (y == 0) r += put_one(env, type_rate, x, env->opt.y - 1); else r += put_one(env, type_rate, x, y - 1); } return (r); }