std::tuple<Move, Value> AperyBook::probe(const Position &pos, const std::string &fname, bool pick_best) { AperyBookEntry entry; uint16_t best = 0; uint32_t sum = 0; Move move = kMoveNone; Key key = book_key(pos); Value min_book_score = static_cast<Value>(static_cast<int>(Options["Min_Book_Score"])); Value score = kValueZero; if (file_name_ != fname && !open(fname.c_str())) return std::make_tuple(kMoveNone, kValueZero); binary_search(key); while (read(reinterpret_cast<char*>(&entry), sizeof(entry)), entry.key == key && good()) { best = std::max(best, entry.count); sum += entry.count; if ( min_book_score <= entry.score && ( (random_() % sum < entry.count) || (pick_best && entry.count == best) ) ) { Square to = to_square(entry.from_to_pro & 0x007fU); int from_raw = (entry.from_to_pro >> 7) & 0x007fU; if (from_raw >= kBoardSquare) { move = move_init(to, to_drop_piece_type(static_cast<Square>(from_raw))); } else { Square from = to_square(from_raw); PieceType pt_from = type_of(pos.square(from)); if (entry.from_to_pro & kPromoted) move = move_init(from, to, pt_from, type_of(pos.square(to)), true); else move = move_init(from, to, pt_from, type_of(pos.square(to)), false); } score = entry.score; } }
int move(){ int done = 0; Uint32 slowdown, slowdown2 = SDL_GetTicks(); hero tux = {1, 0, 0, 0, 0, 0, 1, gd->screen.width/NASOBIC_1, 25, 39, 0}; map_info map = {NULL, (7*gd->screen.height)/BACK_Y, 0, 0, 0, gd->screen.height - tux.h, 0}; SDL_Rect src = { 0, BACK_Y, gd->screen.width, gd->screen.height}; SDL_Rect pst = { gd->screen.width/2, gd->screen.height - tux.h, 0, 0}; platform **first_plat = (platform **)malloc(sizeof(platform *)), **last_plat = (platform **)malloc(sizeof(platform *)); if(!move_init(&map, tux, first_plat, last_plat)) return 0; while(!done){ if(!screen_blit(map.surface, &src, &pst, tux)) return 0; slowdown = SDL_GetTicks(); if((slowdown-slowdown2)<FRAME_WAIT) SDL_Delay(FRAME_WAIT-slowdown+slowdown2); slowdown2 = SDL_GetTicks(); if(!keys(&pst, &tux, map.limit)) return 0; if(!data_handling(&pst, &src, &tux, &map, first_plat, last_plat)) done = 1; } return 1; }
void lower_mob(int npc) { t_list **mob; t_npc *p; mob = find_mob(npc); p = g_env->npc + npc; move_init(((t_mob *)(*mob)->content)->move, p->x, -1, p->y); ((t_mob *)(*mob)->content)->move->fct = anim_move2; }
void ProductType::move_init_impl(void *dst, void *src) { for (int i = 0; i<n; ++i) { auto vt = cp[i]; auto align = vt->object_alignment(); src = round_up(src,align); dst = round_up(dst,align); vt->move_init(dst,src); auto z = vt->object_size(); INCR(src, z); INCR(dst, z); } }
int key_hook(int kc, t_env *e) { if (kc == 65362 || kc == 65364 || kc == 65363 || kc == 65361) move_init(e, kc); if (kc == 65507) e->p.speed = -0.15; if (kc == 101) e->p.speed = 0.8; if (kc == 65307) exit(1); expose_hook(e); return (0); }
void move_mob(int npc, int x, int y, enum e_dir dir) { t_npc *player; t_list **mob; mob = find_mob(npc); player = g_env->npc + npc; player->sq = &g_env->sq[x + y * g_env->mapw]; move_init(((t_mob *)(*mob)->content)->move, x, 0, y); ((t_mob *)(*mob)->content)->move->fct = anim_move; rot_init(((t_mob *)(*mob)->content)->rot, dir); if (!is_in_list(*mob, player->sq->mobs)) switch_link(mob, &player->sq->mobs); }