当前位置: 首页>>代码示例>>C++>>正文


C++ Counter::GetColour方法代码示例

本文整理汇总了C++中Counter::GetColour方法的典型用法代码示例。如果您正苦于以下问题:C++ Counter::GetColour方法的具体用法?C++ Counter::GetColour怎么用?C++ Counter::GetColour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Counter的用法示例。


在下文中一共展示了Counter::GetColour方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IsFinished

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;
}
开发者ID:kristenjacobs,项目名称:connect4,代码行数:63,代码来源:BoardEvaluator.cpp


注:本文中的Counter::GetColour方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。