Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
枚举c+中的运算符+; 我在C++中发现了一个TIC TAC趾游戏的代码,但是在GETCycMePATH函数中的边^ 1混淆了-> RANDMOD= GETWIN(1,), 如果任何提升到一的力量只会是价值本身,为什么它应该是^1?因为当我删除^1:D时,它给了我一个错误 有人能帮我解释一下吗?谢谢 enum { NOUGHTS, CROSSES, BORDER, EMPTY }; enum { HUMANWIN, COMPWIN, DRAW }; const int directions[4] = { 1, 7, 6, 8 }; const int ConvertTo49[25] = { 8, 9, 10,11,12, 15,16,17,18,19, 22,23,24,25,26, 29,30,31,32,33, 36,37,38,39,40 }; int GetWinningMove(int* board, const int side) { int ourMove = -1; int winFound = 0; int index = 0; for (index = 0; index < 25; ++index) { if (board[ConvertTo49[index]] == EMPTY) { ourMove = ConvertTo49[index]; board[ourMove] = side; if (FindFourInARow(board, ourMove, side) == 4) { winFound = 1; } board[ourMove] = EMPTY; if (winFound == 1) { return ourMove; } ourMove = -1; }; } return ourMove; } int GetComputerMove(int* board, const int side) { int index; int numFree = 0; int availableMoves[25]; int randMove = 0; //Set random number to randomly run a function int randFunction = 0; randFunction = (rand() % 2); //Go for the winning move randMove = GetWinningMove(board, side); if (randMove != -1) { return randMove; } //If random function is 1, stop any winning move from the human if (randFunction == 1) { randMove = GetWinningMove(board, side ^ 1); if (randMove != -1) { return randMove; } } randMove = 0; //Loop through all squares and put piece in random place for (index = 0; index < 25; ++index) { if (board[ConvertTo49[index]] == EMPTY) { availableMoves[numFree++] = ConvertTo49[index]; }; } randMove = (rand() % numFree); return availableMoves[randMove]; } enum{NOUGHTS,crosss,BORDER,EMPTY}; 枚举{HUMANWIN,COMPWIN,DRAW}; 常量int方向[4]={1,7,6,8}; const int ConvertTo49[25]= { 8, 9, 10,11,12, 15,16,17,18,19, 22,23,24,25,26, 29,30,31,32,33, 36,37,38,39,40 }; int GetWinningMove(int*板,常数int侧) { intourmove=-1; int-winFound=0; int指数=0; 对于(索引=0;索引代码>边> > < 1 > /代码>,如果边< /代码>是代码> 0 ,它将给出 1 。代码>边1<代码>不是 < 的权力,C++中的 XOR < /代码>操作> C++ >代码>不是C++中的幂,所以当你认为它是猜测时,你所猜测的一切都是错误的。看见_C++_Enums - Fatal编程技术网

枚举c+中的运算符+; 我在C++中发现了一个TIC TAC趾游戏的代码,但是在GETCycMePATH函数中的边^ 1混淆了-> RANDMOD= GETWIN(1,), 如果任何提升到一的力量只会是价值本身,为什么它应该是^1?因为当我删除^1:D时,它给了我一个错误 有人能帮我解释一下吗?谢谢 enum { NOUGHTS, CROSSES, BORDER, EMPTY }; enum { HUMANWIN, COMPWIN, DRAW }; const int directions[4] = { 1, 7, 6, 8 }; const int ConvertTo49[25] = { 8, 9, 10,11,12, 15,16,17,18,19, 22,23,24,25,26, 29,30,31,32,33, 36,37,38,39,40 }; int GetWinningMove(int* board, const int side) { int ourMove = -1; int winFound = 0; int index = 0; for (index = 0; index < 25; ++index) { if (board[ConvertTo49[index]] == EMPTY) { ourMove = ConvertTo49[index]; board[ourMove] = side; if (FindFourInARow(board, ourMove, side) == 4) { winFound = 1; } board[ourMove] = EMPTY; if (winFound == 1) { return ourMove; } ourMove = -1; }; } return ourMove; } int GetComputerMove(int* board, const int side) { int index; int numFree = 0; int availableMoves[25]; int randMove = 0; //Set random number to randomly run a function int randFunction = 0; randFunction = (rand() % 2); //Go for the winning move randMove = GetWinningMove(board, side); if (randMove != -1) { return randMove; } //If random function is 1, stop any winning move from the human if (randFunction == 1) { randMove = GetWinningMove(board, side ^ 1); if (randMove != -1) { return randMove; } } randMove = 0; //Loop through all squares and put piece in random place for (index = 0; index < 25; ++index) { if (board[ConvertTo49[index]] == EMPTY) { availableMoves[numFree++] = ConvertTo49[index]; }; } randMove = (rand() % numFree); return availableMoves[randMove]; } enum{NOUGHTS,crosss,BORDER,EMPTY}; 枚举{HUMANWIN,COMPWIN,DRAW}; 常量int方向[4]={1,7,6,8}; const int ConvertTo49[25]= { 8, 9, 10,11,12, 15,16,17,18,19, 22,23,24,25,26, 29,30,31,32,33, 36,37,38,39,40 }; int GetWinningMove(int*板,常数int侧) { intourmove=-1; int-winFound=0; int指数=0; 对于(索引=0;索引代码>边> > < 1 > /代码>,如果边< /代码>是代码> 0 ,它将给出 1 。代码>边1<代码>不是 < 的权力,C++中的 XOR < /代码>操作> C++ >代码>不是C++中的幂,所以当你认为它是猜测时,你所猜测的一切都是错误的。看见

枚举c+中的运算符+; 我在C++中发现了一个TIC TAC趾游戏的代码,但是在GETCycMePATH函数中的边^ 1混淆了-> RANDMOD= GETWIN(1,), 如果任何提升到一的力量只会是价值本身,为什么它应该是^1?因为当我删除^1:D时,它给了我一个错误 有人能帮我解释一下吗?谢谢 enum { NOUGHTS, CROSSES, BORDER, EMPTY }; enum { HUMANWIN, COMPWIN, DRAW }; const int directions[4] = { 1, 7, 6, 8 }; const int ConvertTo49[25] = { 8, 9, 10,11,12, 15,16,17,18,19, 22,23,24,25,26, 29,30,31,32,33, 36,37,38,39,40 }; int GetWinningMove(int* board, const int side) { int ourMove = -1; int winFound = 0; int index = 0; for (index = 0; index < 25; ++index) { if (board[ConvertTo49[index]] == EMPTY) { ourMove = ConvertTo49[index]; board[ourMove] = side; if (FindFourInARow(board, ourMove, side) == 4) { winFound = 1; } board[ourMove] = EMPTY; if (winFound == 1) { return ourMove; } ourMove = -1; }; } return ourMove; } int GetComputerMove(int* board, const int side) { int index; int numFree = 0; int availableMoves[25]; int randMove = 0; //Set random number to randomly run a function int randFunction = 0; randFunction = (rand() % 2); //Go for the winning move randMove = GetWinningMove(board, side); if (randMove != -1) { return randMove; } //If random function is 1, stop any winning move from the human if (randFunction == 1) { randMove = GetWinningMove(board, side ^ 1); if (randMove != -1) { return randMove; } } randMove = 0; //Loop through all squares and put piece in random place for (index = 0; index < 25; ++index) { if (board[ConvertTo49[index]] == EMPTY) { availableMoves[numFree++] = ConvertTo49[index]; }; } randMove = (rand() % numFree); return availableMoves[randMove]; } enum{NOUGHTS,crosss,BORDER,EMPTY}; 枚举{HUMANWIN,COMPWIN,DRAW}; 常量int方向[4]={1,7,6,8}; const int ConvertTo49[25]= { 8, 9, 10,11,12, 15,16,17,18,19, 22,23,24,25,26, 29,30,31,32,33, 36,37,38,39,40 }; int GetWinningMove(int*板,常数int侧) { intourmove=-1; int-winFound=0; int指数=0; 对于(索引=0;索引代码>边> > < 1 > /代码>,如果边< /代码>是代码> 0 ,它将给出 1 。代码>边1<代码>不是 < 的权力,C++中的 XOR < /代码>操作> C++ >代码>不是C++中的幂,所以当你认为它是猜测时,你所猜测的一切都是错误的。看见,c++,enums,C++,Enums,相反,^是最重要的。在您的情况下,假定侧的值为0或1(表示机器或播放器),则侧^1表达式将计算为另一个值。也就是说,如果< C++ >代码>边> > < 1 > /代码>,如果边< /代码>是代码> 0 ,它将给出 1 。代码>边1<代码>不是 < 的权力,C++中的 XOR < /代码>操作> C++ >代码>不是C++中的幂,所以当你认为它是猜测时,你所猜测的一切都是错误的。看见

相反,
^
是最重要的。在您的情况下,假定
的值为
0
1
(表示机器或播放器),则
侧^1
表达式将计算为另一个值。也就是说,如果< C++ >代码>边> <代码> > < 1 > /代码>,如果<代码>边< /代码>是代码> 0 ,它将给出<代码> 1 <代码>。<>代码>边1<代码>不是<代码> < <代码>的权力,C++中的<代码> XOR < /代码>操作> C++ >代码>不是C++中的幂,所以当你认为它是猜测时,你所猜测的一切都是错误的。看见