void PathMachine::syncing(const SigParseEvent &sigParseEvent) { ParseEvent &event = sigParseEvent.deref(); { Syncing sync(params, paths, &signaler); if (event.getNumSkipped() <= params.maxSkipped) { emit lookingForRooms(sync, sigParseEvent); } paths = sync.evaluate(); } evaluatePaths(); }
void PathMachine::experimenting(const SigParseEvent &sigParseEvent) { ParseEvent &event = sigParseEvent.deref(); std::unique_ptr<Experimenting> exp = nullptr; const CommandIdType moveCode = event.getMoveType(); const auto dir = getDirection(moveCode); const Coordinate &move = RoomFactory::exitDir(dir); // only create rooms if no properties are skipped and // the move coordinate is not 0,0,0 if (event.getNumSkipped() == 0 && moveCode < CommandIdType::FLEE && !mostLikelyRoom.isFake() && !move.isNull()) { exp = std::make_unique<Crossover>(paths, dir, params, factory); std::set<const Room *> pathEnds{}; for (auto &path : *paths) { const Room *const working = path->getRoom(); if (pathEnds.find(working) == pathEnds.end()) { emit createRoom(sigParseEvent, working->getPosition() + move); pathEnds.insert(working); } } emit lookingForRooms(*exp, sigParseEvent); } else { auto pOneByOne = std::make_unique<OneByOne>(factory, sigParseEvent, params, &signaler); { auto &tmp = *pOneByOne; for (auto &path : *paths) { const Room *const working = path->getRoom(); tmp.addPath(path); tryExits(working, tmp, event, true); tryExits(working, tmp, event, false); tryCoordinate(working, tmp, event); } } exp = static_upcast<Experimenting>(std::exchange(pOneByOne, nullptr)); } paths = exp->evaluate(); evaluatePaths(); }
/* BEGIN TEMPLATE */ void run() { /* BEGIN SOLUTION */ evaluatePaths(); // write on each case the distance to the maze exit followShortestPath(); // make the buggle follow the shortest path pickupBaggle(); // enjoy the baggle! }