ctrl: allow to erasing training data leaving graph files
This commit is contained in:
parent
9b80517eda
commit
4c5cf2503e
4 changed files with 24 additions and 4 deletions
|
|
@ -118,6 +118,7 @@ private:
|
||||||
int cmdNodeSave ();
|
int cmdNodeSave ();
|
||||||
int cmdNodeLoad ();
|
int cmdNodeLoad ();
|
||||||
int cmdNodeErase ();
|
int cmdNodeErase ();
|
||||||
|
int cmdNodeEraseTraining ();
|
||||||
int cmdNodeDelete ();
|
int cmdNodeDelete ();
|
||||||
int cmdNodeCheck ();
|
int cmdNodeCheck ();
|
||||||
int cmdNodeCache ();
|
int cmdNodeCache ();
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ public:
|
||||||
int32_t storageToBotFile (int32_t options);
|
int32_t storageToBotFile (int32_t options);
|
||||||
|
|
||||||
// remove all bot related files from disk
|
// remove all bot related files from disk
|
||||||
void unlinkFromDisk ();
|
void unlinkFromDisk (bool onlyTrainingData);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// loading the graph may attempt to recurse loading, with converting or download, reset retry counter
|
// loading the graph may attempt to recurse loading, with converting or download, reset retry counter
|
||||||
|
|
|
||||||
|
|
@ -355,6 +355,7 @@ int BotControl::cmdNode () {
|
||||||
"load",
|
"load",
|
||||||
"help",
|
"help",
|
||||||
"erase",
|
"erase",
|
||||||
|
"erase_training",
|
||||||
"fileinfo",
|
"fileinfo",
|
||||||
"check"
|
"check"
|
||||||
};
|
};
|
||||||
|
|
@ -399,6 +400,7 @@ int BotControl::cmdNode () {
|
||||||
addGraphCmd ("save", "save [noarguments]", "Save graph file to disk.", &BotControl::cmdNodeSave);
|
addGraphCmd ("save", "save [noarguments]", "Save graph file to disk.", &BotControl::cmdNodeSave);
|
||||||
addGraphCmd ("load", "load [noarguments]", "Load graph file from disk.", &BotControl::cmdNodeLoad);
|
addGraphCmd ("load", "load [noarguments]", "Load graph file from disk.", &BotControl::cmdNodeLoad);
|
||||||
addGraphCmd ("erase", "erase [iamsure]", "Erases the graph file from disk.", &BotControl::cmdNodeErase);
|
addGraphCmd ("erase", "erase [iamsure]", "Erases the graph file from disk.", &BotControl::cmdNodeErase);
|
||||||
|
addGraphCmd ("erase_training", "erase_training", "Erases the training data leaving graph files.", &BotControl::cmdNodeEraseTraining);
|
||||||
addGraphCmd ("delete", "delete [nearest|index]", "Deletes single graph node from map.", &BotControl::cmdNodeDelete);
|
addGraphCmd ("delete", "delete [nearest|index]", "Deletes single graph node from map.", &BotControl::cmdNodeDelete);
|
||||||
addGraphCmd ("check", "check [noarguments]", "Check if graph working correctly.", &BotControl::cmdNodeCheck);
|
addGraphCmd ("check", "check [noarguments]", "Check if graph working correctly.", &BotControl::cmdNodeCheck);
|
||||||
addGraphCmd ("cache", "cache [nearest|index]", "Caching node for future use.", &BotControl::cmdNodeCache);
|
addGraphCmd ("cache", "cache [nearest|index]", "Caching node for future use.", &BotControl::cmdNodeCache);
|
||||||
|
|
@ -616,7 +618,7 @@ int BotControl::cmdNodeErase () {
|
||||||
|
|
||||||
// prevent accidents when graph are deleted unintentionally
|
// prevent accidents when graph are deleted unintentionally
|
||||||
if (arg <StringRef> (iamsure) == "iamsure") {
|
if (arg <StringRef> (iamsure) == "iamsure") {
|
||||||
bstor.unlinkFromDisk ();
|
bstor.unlinkFromDisk (false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg ("Please, append \"iamsure\" as parameter to get graph erased from the disk.");
|
msg ("Please, append \"iamsure\" as parameter to get graph erased from the disk.");
|
||||||
|
|
@ -624,6 +626,14 @@ int BotControl::cmdNodeErase () {
|
||||||
return BotCommandResult::Handled;
|
return BotCommandResult::Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int BotControl::cmdNodeEraseTraining () {
|
||||||
|
enum args { graph_cmd = 1, cmd };
|
||||||
|
|
||||||
|
bstor.unlinkFromDisk (true);
|
||||||
|
|
||||||
|
return BotCommandResult::Handled;
|
||||||
|
}
|
||||||
|
|
||||||
int BotControl::cmdNodeDelete () {
|
int BotControl::cmdNodeDelete () {
|
||||||
enum args { graph_cmd = 1, cmd, nearest };
|
enum args { graph_cmd = 1, cmd, nearest };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -390,14 +390,16 @@ int32_t BotStorage::storageToBotFile (int32_t options) {
|
||||||
return BotFile::Graph;
|
return BotFile::Graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BotStorage::unlinkFromDisk () {
|
void BotStorage::unlinkFromDisk (bool onlyTrainingData) {
|
||||||
// this function removes graph file from the hard disk
|
// this function removes graph file from the hard disk
|
||||||
|
|
||||||
StringArray unlinkable {};
|
StringArray unlinkable {};
|
||||||
bots.kickEveryone (true);
|
bots.kickEveryone (true);
|
||||||
|
|
||||||
// if we're delete graph, delete all corresponding to it files
|
// if we're delete graph, delete all corresponding to it files
|
||||||
|
if (!onlyTrainingData) {
|
||||||
unlinkable.emplace (buildPath (BotFile::Graph)); // graph itself
|
unlinkable.emplace (buildPath (BotFile::Graph)); // graph itself
|
||||||
|
}
|
||||||
unlinkable.emplace (buildPath (BotFile::Practice)); // corresponding to practice
|
unlinkable.emplace (buildPath (BotFile::Practice)); // corresponding to practice
|
||||||
unlinkable.emplace (buildPath (BotFile::Vistable)); // corresponding to vistable
|
unlinkable.emplace (buildPath (BotFile::Vistable)); // corresponding to vistable
|
||||||
unlinkable.emplace (buildPath (BotFile::Pathmatrix)); // corresponding to matrix
|
unlinkable.emplace (buildPath (BotFile::Pathmatrix)); // corresponding to matrix
|
||||||
|
|
@ -412,6 +414,13 @@ void BotStorage::unlinkFromDisk () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
graph.reset (); // re-initialize points
|
graph.reset (); // re-initialize points
|
||||||
|
|
||||||
|
if (onlyTrainingData) {
|
||||||
|
graph.loadGraphData ();
|
||||||
|
|
||||||
|
// take bots back to game
|
||||||
|
cv_quota.revert ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef BotStorage::getRunningPath () {
|
StringRef BotStorage::getRunningPath () {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue