Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
Back On Track complete, bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MCJack123 committed Apr 22, 2020
1 parent fa59570 commit c23629a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions dashbot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <algorithm>
#undef max

#define ODDS (bestLastJump / bestFitness) / 25 + 0.0001
#define ODDS ((bestLastJump == 0.0 ? (bestFitness / 2.0) : bestLastJump) / bestFitness) / 25.0 + 0.0001

const std::unordered_map<std::string, std::vector<bool> > flyStatesForAllMaps = {
{"StereoMadness", {false, true, false, true}},
Expand Down Expand Up @@ -147,6 +147,7 @@ int main(int argc, const char * argv[]) {
if (lastX > bestFitnessR) {
bestJumps = jumps;
bestLastJump = lastJump;
bestFitnessR = 0;
if (saving) {
out.open(argv[2], std::ios_base::binary);
out.write((char*)&bestFitness, sizeof(double));
Expand All @@ -156,10 +157,9 @@ int main(int argc, const char * argv[]) {
out.put(0); out.put(0); out.put(0); out.put(0);
out.close();
}
}
} else std::cout << "not saving this one since it can be better\n";
failCount = 0;
bestFitnessR = 0;
} else if (bestJumps.size() - jumps.size() <= 10 && ++failCount >= 10 && bestJumps.size() > 0) {
} else if ((signed)bestJumps.size() - (signed)jumps.size() <= 10 && ++failCount >= 10 && bestJumps.size() > 0) {
if (jumps.size() == 0 && bestJumps.size() >= 5) {
std::cerr << "forgot how to play! stopping to prevent data loss\n";
return 3;
Expand All @@ -184,10 +184,10 @@ int main(int argc, const char * argv[]) {
} else bestFitnessR = 0;
jumps.clear();
lastJump = 0;
} else if ((uint32_t)floor(xPos / 5) * 5 <= bestLastJump)
} else if ((uint32_t)floor(xPos / 5) * 5 <= bestLastJump) {
if (bestJumps.find((uint32_t)floor(xPos / 5) * 5) != bestJumps.end() && jumps.find((uint32_t)floor(xPos / 5) * 5) == jumps.end())
shouldJump = true;
else if (xPos > lastX) {
} else if (xPos > lastX) {
if (!randing) {
std::cout << "randing after " << bestLastJump << ", odds are " << (ODDS) * 100 << "%\n";
randing = true;
Expand All @@ -210,4 +210,4 @@ int main(int argc, const char * argv[]) {
}
lastX = xPos;
}
}
}
Binary file added samples/BackOnTrack.dbj
Binary file not shown.

0 comments on commit c23629a

Please sign in to comment.