void UBehaviorTreeGraphNode_CompositeDecorator::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) { Super::PostEditChangeProperty(PropertyChangedEvent); if (PropertyChangedEvent.Property && PropertyChangedEvent.Property->GetFName() == GET_MEMBER_NAME_CHECKED(UBehaviorTreeGraphNode_CompositeDecorator, bShowOperations)) { BuildDescription(); } }
void UBehaviorTreeGraphNode_CompositeDecorator::OnInnerGraphChanged() { BuildDescription(); bCanAbortFlow = false; UBehaviorTreeDecoratorGraph* MyGraph = Cast<UBehaviorTreeDecoratorGraph>(BoundGraph); if (MyGraph) { for (int32 i = 0; i < MyGraph->Nodes.Num(); i++) { UBehaviorTreeDecoratorGraphNode_Decorator* MyNode = Cast<UBehaviorTreeDecoratorGraphNode_Decorator>(MyGraph->Nodes[i]); UBTDecorator* MyNodeInstance = MyNode ? Cast<UBTDecorator>(MyNode->NodeInstance) : NULL; if (MyNodeInstance && MyNodeInstance->GetFlowAbortMode() != EBTFlowAbortMode::None) { bCanAbortFlow = true; break; } } } }
void Drakes::AdjustDrake(CHAR_DATA & ch, CHAR_DATA & drake, int stoneType, const Info & info, int level, Age age) { // Set the appropriate strings const char * stoneName(material_table[stoneType].name); std::string shortDesc(BuildShortDesc(stoneName, age)); std::string longDesc(shortDesc + " is here.\n"); longDesc[0] = UPPER(longDesc[0]); setName(drake, shortDesc.c_str()); copy_string(drake.short_descr, shortDesc.c_str()); copy_string(drake.long_descr, longDesc.c_str()); copy_string(drake.description, BuildDescription(ch, stoneName, age).c_str()); // Seed any random values with ch's id srand(ch.id + 12345); // Adjust damage type and damverb drake.dam_type = info.damageType; const char * damverb("strike"); switch (info.damageType) { case DAM_BASH: switch ((rand() + stoneType) % 3) { case 0: damverb = "slam"; break; case 1: damverb = "smash"; break; case 2: damverb = "crush"; break; } break; case DAM_SLASH: switch ((rand() + stoneType) % 3) { case 0: damverb = "slice"; break; case 1: damverb = "claw"; break; case 2: damverb = "talon"; break; } break; case DAM_PIERCE: switch ((rand() + stoneType) % 2) { case 0: damverb = "bite"; break; case 1: damverb = "strike"; break; } break; } copy_string(drake.dam_verb, damverb); // Perform basic adjustments drake.level = UMAX(1, level + age); drake.damroll = (level / 10) + (age * 4); drake.hitroll = (level * 2) / 3; drake.damage[0] = (level * 2) / 3; drake.damage[1] = 4; drake.damage[2] = drake.damroll; drake.max_hit = dice(level * 4, 19) + 400 + (age * 100); // Adjust for damage and hp mods drake.damage[0] = (drake.damage[0] * (100 + info.damageMod)) / 100; drake.max_hit = (drake.max_hit * (100 + info.hpMod)) / 100; // Adjust stats for (size_t i(0); i < MAX_STATS; ++i) { drake.perm_stat[i] = 18 + age; drake.mod_stat[i] = 18 + age; drake.max_stat[i] = 18 + age; } // Fill in resistances for (size_t i(0); i < info.resistances.size(); ++i) drake.resist[info.resistances[i].type] = info.resistances[i].modBase + (age * info.resistances[i].modStep); // Restore random seed srand(time(0)); // Determine duration until next age level up int duration((age + 1) * 260); if (age == Ancient) duration = -1; else duration = (duration * (100 + info.maturationMod)) / 100; // Mark the drake's stone type and age in the modifier and level fields AFFECT_DATA af = {0}; af.where = TO_AFFECTS; af.type = gsn_wakenedstone; af.modifier = stoneType; af.level = age; af.duration = duration; affect_to_char(&drake, &af); // Adjust the drake's level for overwhelm drake.level += SpecialCount(drake, Overwhelm); }
int _tmain(int argc, _TCHAR* argv[]) { // Create a NatNet server int iConnectionType = ConnectionType_Multicast; //int iConnectionType = ConnectionType_Unicast; int iResult = CreateServer(iConnectionType); if(iResult != ErrorCode_OK) { printf("Error initializing server. See log for details. Exiting"); return 1; } // Create a MarkerSet description BuildDescription(&descriptions); // OK! Ready to stream data. Listen for request from clients (RequestHandler()) printf("\n\nCommands:\nn\tnext frame\ns\tstream frames\nr\treset server\nq\tquit\n\r\tmulticast\nu\tunicast\n\n"); bool bExit = false; while(int c =_getch()) { switch(c) { case 'n': // next frame { sFrameOfMocapData frame; BuildFrame(g_lCurrentFrame++, &descriptions, &frame); SendFrame(&frame); FreeFrame(&frame); } break; case 'q': // quit bExit = true; break; case 's': // play continuously g_lCurrentFrame = 0; if(g_bPlaying) StopPlayingThread(); else StartPlayingThread(); break; case 'r': // reset server resetServer(); break; case 'm': // change to multicast iResult = CreateServer(ConnectionType_Multicast); if(iResult == ErrorCode_OK) printf("Server connection type changed to Multicast.\n\n"); else printf("Error changing server connection type to Multicast.\n\n"); break; case 'u': // change to unicast iResult = CreateServer(ConnectionType_Unicast); if(iResult == ErrorCode_OK) printf("Server connection type changed to Unicast.\n\n"); else printf("Error changing server connection type to Unicast.\n\n"); break; default: break; } if(bExit) { theServer->Uninitialize(); FreeDescription(&descriptions); break; } } return ErrorCode_OK; }
void GreedyTensorSearch(const TTrainData& data, const TVector<int>& splitCounts, double modelLength, TProfileInfo& profile, TFold* fold, TLearnContext* ctx, TSplitTree* resSplitTree) { TSplitTree currentSplitTree; TrimOnlineCTRcache({fold}); TVector<TIndexType> indices(data.LearnSampleCount); MATRIXNET_INFO_LOG << "\n"; const bool useStatsFromPrevTree = AreStatsFromPrevTreeUsed(ctx->Params.ObliviousTreeOptions.Get()); if (useStatsFromPrevTree) { AssignRandomWeights(data.LearnSampleCount, ctx, fold); ctx->StatsFromPrevTree.GarbageCollect(); } for (ui32 curDepth = 0; curDepth < ctx->Params.ObliviousTreeOptions->MaxDepth; ++curDepth) { TCandidateList candList; AddFloatFeatures(data, ctx, &ctx->StatsFromPrevTree, &candList); AddOneHotFeatures(data, ctx, &ctx->StatsFromPrevTree, &candList); AddSimpleCtrs(data, fold, ctx, &ctx->StatsFromPrevTree, &candList); AddTreeCtrs(data, currentSplitTree, fold, ctx, &ctx->StatsFromPrevTree, &candList); auto IsInCache = [&fold](const TProjection& proj) -> bool {return fold->GetCtrRef(proj).Feature.empty();}; SelectCtrsToDropAfterCalc(ctx->Params.SystemOptions->CpuUsedRamLimit, data.GetSampleCount(), ctx->Params.SystemOptions->NumThreads, IsInCache, &candList); CheckInterrupted(); // check after long-lasting operation if (!useStatsFromPrevTree) { AssignRandomWeights(data.LearnSampleCount, ctx, fold); } profile.AddOperation(TStringBuilder() << "AssignRandomWeights, depth " << curDepth); double scoreStDev = ctx->Params.ObliviousTreeOptions->RandomStrength * CalcScoreStDev(*fold) * CalcScoreStDevMult(data.LearnSampleCount, modelLength); TVector<size_t> candLeafCount(candList.ysize(), 1); const ui64 randSeed = ctx->Rand.GenRand(); ctx->LocalExecutor.ExecRange([&](int id) { auto& candidate = candList[id]; if (candidate.Candidates[0].SplitCandidate.Type == ESplitType::OnlineCtr) { const auto& proj = candidate.Candidates[0].SplitCandidate.Ctr.Projection; if (fold->GetCtrRef(proj).Feature.empty()) { ComputeOnlineCTRs(data, *fold, proj, ctx, &fold->GetCtrRef(proj), &candidate.ResultingCtrTableSize); candLeafCount[id] = candidate.ResultingCtrTableSize; } } TVector<TVector<double>> allScores(candidate.Candidates.size()); ctx->LocalExecutor.ExecRange([&](int oneCandidate) { if (candidate.Candidates[oneCandidate].SplitCandidate.Type == ESplitType::OnlineCtr) { const auto& proj = candidate.Candidates[oneCandidate].SplitCandidate.Ctr.Projection; Y_ASSERT(!fold->GetCtrRef(proj).Feature.empty()); } allScores[oneCandidate] = CalcScore(data.AllFeatures, splitCounts, *fold, indices, ctx->ParamsUsedWithStatsFromPrevTree, ctx->Params, candidate.Candidates[oneCandidate].SplitCandidate, currentSplitTree.GetDepth(), &ctx->StatsFromPrevTree); }, NPar::TLocalExecutor::TExecRangeParams(0, candidate.Candidates.ysize()) , NPar::TLocalExecutor::WAIT_COMPLETE); if (candidate.Candidates[0].SplitCandidate.Type == ESplitType::OnlineCtr && candidate.ShouldDropCtrAfterCalc) { fold->GetCtrRef(candidate.Candidates[0].SplitCandidate.Ctr.Projection).Feature.clear(); } TFastRng64 rand(randSeed + id); rand.Advance(10); // reduce correlation between RNGs in different threads for (size_t i = 0; i < allScores.size(); ++i) { double bestScoreInstance = MINIMAL_SCORE; auto& splitInfo = candidate.Candidates[i]; const auto& scores = allScores[i]; for (int binFeatureIdx = 0; binFeatureIdx < scores.ysize(); ++binFeatureIdx) { const double score = scores[binFeatureIdx]; const double scoreInstance = TRandomScore(score, scoreStDev).GetInstance(rand); if (scoreInstance > bestScoreInstance) { bestScoreInstance = scoreInstance; splitInfo.BestScore = TRandomScore(score, scoreStDev); splitInfo.BestBinBorderId = binFeatureIdx; } } } }, 0, candList.ysize(), NPar::TLocalExecutor::WAIT_COMPLETE); size_t maxLeafCount = 1; for (size_t leafCount : candLeafCount) { maxLeafCount = Max(maxLeafCount, leafCount); } fold->DropEmptyCTRs(); CheckInterrupted(); // check after long-lasting operation profile.AddOperation(TStringBuilder() << "Calc scores " << curDepth); const TCandidateInfo* bestSplitCandidate = nullptr; double bestScore = MINIMAL_SCORE; for (const auto& subList : candList) { for (const auto& candidate : subList.Candidates) { double score = candidate.BestScore.GetInstance(ctx->Rand); TProjection projection = candidate.SplitCandidate.Ctr.Projection; ECtrType ctrType = ctx->CtrsHelper.GetCtrInfo(projection)[candidate.SplitCandidate.Ctr.CtrIdx].Type; if (!ctx->LearnProgress.UsedCtrSplits.has(std::make_pair(ctrType, projection)) && score != MINIMAL_SCORE) { score *= pow(1 / (1 + subList.ResultingCtrTableSize / static_cast<double>(maxLeafCount)), ctx->Params.ObliviousTreeOptions->ModelSizeReg.Get()); } if (score > bestScore) { bestScore = score; bestSplitCandidate = &candidate; } } } if (bestScore == MINIMAL_SCORE) { break; } if (bestSplitCandidate->SplitCandidate.Type == ESplitType::OnlineCtr) { TProjection projection = bestSplitCandidate->SplitCandidate.Ctr.Projection; ECtrType ctrType = ctx->CtrsHelper.GetCtrInfo(projection)[bestSplitCandidate->SplitCandidate.Ctr.CtrIdx].Type; ctx->LearnProgress.UsedCtrSplits.insert(std::make_pair(ctrType, projection)); } auto bestSplit = TSplit(bestSplitCandidate->SplitCandidate, bestSplitCandidate->BestBinBorderId); if (bestSplit.Type == ESplitType::OnlineCtr) { const auto& proj = bestSplit.Ctr.Projection; if (fold->GetCtrRef(proj).Feature.empty()) { size_t totalLeafCount; ComputeOnlineCTRs(data, *fold, proj, ctx, &fold->GetCtrRef(proj), &totalLeafCount); DropStatsForProjection(*fold, *ctx, proj, &ctx->StatsFromPrevTree); } } else if (bestSplit.Type == ESplitType::OneHotFeature) { bestSplit.BinBorder = data.AllFeatures.OneHotValues[bestSplit.FeatureIdx][bestSplit.BinBorder]; } SetPermutedIndices(bestSplit, data.AllFeatures, curDepth + 1, *fold, &indices, ctx); if (useStatsFromPrevTree) { ctx->ParamsUsedWithStatsFromPrevTree.SelectParametersForSmallestSplitSide(curDepth + 1, *fold, indices, &ctx->LocalExecutor); } currentSplitTree.AddSplit(bestSplit); MATRIXNET_INFO_LOG << BuildDescription(ctx->Layout, bestSplit); MATRIXNET_INFO_LOG << " score " << bestScore << "\n"; profile.AddOperation(TStringBuilder() << "Select best split " << curDepth); int redundantIdx = GetRedundantSplitIdx(curDepth + 1, indices); if (redundantIdx != -1) { DeleteSplit(curDepth + 1, redundantIdx, ¤tSplitTree, &indices); MATRIXNET_INFO_LOG << " tensor " << redundantIdx << " is redundant, remove it and stop\n"; break; } } *resSplitTree = std::move(currentSplitTree); }