标题:求教c语言编写黑白棋游戏如何确定当前落子位置请问这个函数哪里错了
只看楼主
一灬滴水
Rank: 1
来 自:陕西宝鸡
等 级:新手上路
帖 子:4
专家分:0
注 册:2017-7-28
 问题点数:0 回复次数:0 
求教c语言编写黑白棋游戏如何确定当前落子位置请问这个函数哪里错了
bool Game::IsMaybePlace(int row, int col)
{
    int or, oc;
    int i, j;

    for(or=-1; or<=1; ++or)
    {
        for(oc=-1; oc<=1; ++oc)
        {
            if(or==0 && oc==0)
            {
                continue;
            }
            if(IsLegalPlace(row+or, col+oc) && _layout[row+or][col+oc] == (CTYPE)(1-_curPieces))
            {
                for(i = row + or*2, j= col + oc*2; IsLegalPlace(i, j); i+=or, j+=oc)
                {
                    if(_layout[i][j] == (CTYPE)(1-_curPieces))
                    {
                        continue;
                    }
                    else if(_layout[i][j] == _curPieces)
                    {
                        return true;
                    }
                    else if(_layout[i][j] == CNOTING)
                    {
                        break;
                    }
                }
            }
        }
    }
    return false;
}
搜索更多相关主题的帖子: c语言 游戏 int row for 
2017-07-28 17:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-479677-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.221854 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved