首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当从视图控制器(而非应用程序委托iOS )加载时,股票鱼引擎会中断。

当从视图控制器(而非应用程序委托iOS )加载时,股票鱼引擎会中断。
EN

Stack Overflow用户
提问于 2016-05-24 14:39:54
回答 1查看 179关注 0票数 0

我试图将Stockfish UCI引擎实现为一个国际象棋游戏应用程序。最初,在Stockfish iOS游戏中,持有板和碎片的视图控制器是从应用程序委托加载的。我想做的是,在导航到游戏之前,还有几个屏幕。我遇到的问题是,一旦我加载了棋盘屏幕,游戏就会在bitboard.cpp文件中以消息EXC_BAD_ACCESS(code=1,address=0x1fa80000)中断,并且有几次,我成功地将棋子加载到板上并移动其中一个,但它却在这条线上显示的相同位置刹车:occupancysize = b;

代码语言:javascript
运行
复制
void init_magics(Bitboard table[], Bitboard* attacks[], Bitboard magics[],
               Bitboard masks[], unsigned shifts[], Square deltas[], Fn index) {

int MagicBoosters[][8] = { {  969, 1976, 2850,  542, 2069, 2852, 1708,  164 },
                           { 3101,  552, 3555,  926,  834,   26, 2131, 1117 } };

RKISS rk;
Bitboard occupancy[4096], reference[4096], edges, b;
int i, size, booster;

// attacks[s] is a pointer to the beginning of the attacks table for square 's'
attacks[SQ_A1] = table;

for (Square s = SQ_A1; s <= SQ_H8; ++s)
{
    // Board edges are not considered in the relevant occupancies
    edges = ((Rank1BB | Rank8BB) & ~rank_bb(s)) | ((FileABB | FileHBB) & ~file_bb(s));

    // Given a square 's', the mask is the bitboard of sliding attacks from
    // 's' computed on an empty board. The index must be big enough to contain
    // all the attacks for each possible subset of the mask and so is 2 power
    // the number of 1s of the mask. Hence we deduce the size of the shift to
    // apply to the 64 or 32 bits word to get the index.
    masks[s]  = sliding_attack(deltas, s, 0) & ~edges;
    shifts[s] = (Is64Bit ? 64 : 32) - popcount<Max15>(masks[s]);

    // Use Carry-Rippler trick to enumerate all subsets of masks[s] and
    // store the corresponding sliding attack bitboard in reference[].
    b = size = 0;
    do {

        occupancy[size] = b;
        reference[size] = sliding_attack(deltas, s, b);

        if (HasPext)
            attacks[s][_pext_u64(b, masks[s])] = reference[size];

        size++;
        b = (b - masks[s]) & masks[s];
    } while (b);

    // Set the offset for the table of the next square. We have individual
    // table sizes for each square with "Fancy Magic Bitboards".
    if (s < SQ_H8)
        attacks[s + 1] = attacks[s] + size;

    if (HasPext)
        continue;

    booster = MagicBoosters[Is64Bit][rank_of(s)];

    // Find a magic for square 's' picking up an (almost) random number
    // until we find the one that passes the verification test.
    do {
        do magics[s] = rk.magic_rand<Bitboard>(booster);
        while (popcount<Max15>((magics[s] * masks[s]) >> 56) < 6);

        std::memset(attacks[s], 0, size * sizeof(Bitboard));

        // A good magic must map every possible occupancy to an index that
        // looks up the correct sliding attack in the attacks[s] database.
        // Note that we build up the database for square 's' as a side
        // effect of verifying the magic.
        for (i = 0; i < size; ++i)
        {
            Bitboard& attack = attacks[s][index(s, occupancy[i])];

            if (attack && attack != reference[i])
                break;

            assert(reference[i]);

            attack = reference[i];
        }
    } while (i < size);
}

我在C++方面没有太多的经验和知识,我很难弄清楚是什么导致了这个问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-24 19:32:44

我现在想办法解决了!我认为游戏还在初始化,而我正在加载它的视图,这导致了整个问题,因为初始化是在后台运行!为了解决这个问题,我制作了一个加载屏幕,并在那里调用了游戏的初始值!一旦全部设置在后台,我就会加载游戏的屏幕!希望我的帖子能对未来的人有所帮助!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37416788

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档