X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=src%2Fgenesorter.cpp;h=8126d6aaa5781336ab03ba3a822f4d72f4c8820d;hb=e81855989d0f0e124e0ec770b417bcb099959391;hp=1e199843a1a5ecedcbf692fc6da5117dafa4ce8e;hpb=3401199b1ce268dd6465f09abf6264592b989140;p=germs.git diff --git a/src/genesorter.cpp b/src/genesorter.cpp index 1e19984..8126d6a 100644 --- a/src/genesorter.cpp +++ b/src/genesorter.cpp @@ -26,16 +26,27 @@ #include "genealgorithms.h" +#include using namespace std; GeneSorter::ActionList GeneSorter::sort(const GeneOrder& go){ - return ActionList(); + ActionList al; + GeneOrder temp(go); + while(inversionDistance(go) > 0){ + ActionList safe = safeActions(go); + if (safe.size() > 0){ + safe[0](temp); + al.push_back(safe[0]); + }else + return ActionList(); //TODO: Need to handle hurdles. + } + return al; } GeneSorter::ActionList GeneSorter::safeActions(const GeneOrder& go){ if (countCycles(go) == go.size() - 1) return ActionList(); ActionList al; - al.push_back(ActionPointer(new ReverseAction(2,3))); + //al.push_back(SortAction(new ReverseAction(2,3))); return al; }