bool checkResult(board& b) { if (b.fiftyMoves > 100) { printf("1/2-1/2 {fifty move rule (claimed by PENIQLIOTUV)}"); return true; } if (threeFoldRep(b) >= 2) { printf("1/2-1/2 {3-fold repetition (claimed by PENIQLIOTUV)}"); return true; } if (drawMaterial(b) == true) { printf("1/2-1/2 {insufficient material (claimed by PENIQLIOTUV)}"); return true; } moveList* list = new moveList; generateAllMoves(b,list); int found = 0; for(int i = 0; i < list->count; ++i) { if (!makeMove(b,list->ml_getMove(i))) { continue; } found++; takeMove(b); break; } if(found != 0) { return false; } bool inCheck = sqAttacked(b.kingSquare[b.side],b.side^1,b); if(inCheck == true) { if(b.side == WHITE) { printf("0-1 {black mates (claimed by PENIQLIOTUV)}"); return true; } else { printf("0-1 {white mates (claimed by PENIQLIOTUV)}"); return true; } } else { printf("\n1/2-1/2 {stalemate (claimed by PENIQLIOTUV)}"); return true; } delete list; return false; }
//////////////////////////////////////////////////////////////////////////////// // allmats() // // Draw all of the materials in a given materials library file (.mli). // The name of the library is passed in the resbuf (the only argument // it processes). The resbuf is NULL or not of type RTSTR, the displayed // library will be "Support/render.mli". // // Returns AvRetNorm on success, otherwise, AvRetError. // static AvErrorCode allmats(struct resbuf *rb) { union ads_u_val *resval; char *sLibPath, *sLibName; AvMatlibParam libParam; ads_point corner, offset; double dCubeSize, dCubeSpacing, dLibNameHeight; struct resbuf *pMaterial; int numMaterials, numRows, i; // Get path of materials library to display // resval = getArg(rb, RTSTR, 0); if (resval == NULL) { acdbHostApplicationServices()->getRoamableRootFolder(sLibPath); strcat(sLibPath,DEFAULT_LIBRARY_PATH); } else sLibPath = resval->rstring; // Get offset position for drawing // resval = getArg(rb, RT3DPOINT, 1); if (resval == NULL) { offset[X] = offset[Y] = offset[Z] = DEFAULT_OFFSET; } else { offset[X] = resval->rpoint[X]; offset[Y] = resval->rpoint[Y]; offset[Z] = resval->rpoint[Z]; } // Get cube size // resval = getArg(rb, RTREAL, 2); if (resval == NULL || resval->rreal <= 0.0) dCubeSize = DEFAULT_CUBE_SIZE; else dCubeSize = resval->rreal; // Get title text height // resval = getArg(rb, RTREAL, 3); if (resval == NULL || resval->rreal <= 0.0) dLibNameHeight = DEFAULT_TITLE_HEIGHT; else dLibNameHeight = resval->rreal; // Make sLibName point to the library file name only // sLibName = sLibPath + strlen(sLibPath); while (sLibName > sLibPath) { if (*sLibName == '/') { sLibName++; break; } sLibName--; } acutPrintf("Displaying materials library %s (%s)\n", sLibName, sLibPath); // Get list of materials in library // libParam.mode = AvMatlibList; libParam.libraryName = sLibPath; libParam.flags = AvMatlibLibrary; if (av_matlib(&libParam) != AvRetNorm) return AvRetError; pMaterial = libParam.stringList; numMaterials = resbufListCount(pMaterial); // Display library name, height = 0.8 // drawText(offset, dLibNameHeight, sLibName); // Set Y offset for first material block // offset[Y] += dLibNameHeight * 1.5; numRows = (int)(sqrt((double)numMaterials)); // layout is square dCubeSpacing = dCubeSize * 1.5; // Draw each material in the library // for (i = 0; i < numMaterials; i++) { // Find position // corner[X] = offset[X] + (i % numRows) * dCubeSpacing; corner[Y] = offset[Y] + (int)(i / numRows) * dCubeSpacing; corner[Z] = offset[Z]; // Draw it // if (drawMaterial(corner, dCubeSize, pMaterial->resval.rstring, sLibPath) != AvRetNorm) return AvRetError; pMaterial = pMaterial->rbnext; } acutRelRb(libParam.stringList); // the start of pMaterial acutPrintf("Got %d materials\n", numMaterials); return AvRetNorm; }