Ejemplo n.º 1
0
Point move(const Table& table, Point pos, Point dest) {
    auto candidate_moves = {p10, p01, -p10, -p01};
    auto min_dist = 1000;
    Point best;
    for (auto i : randomizedRange(candidate_moves)) {
        Point candidate = pos - i;
        auto d = distance(dest, candidate);
        //std::cerr << "  " << candidate << "[" << d << "]\n";
        if (isInsideArray(table, candidate) && min_dist > d) {
            //std::cerr << "  update\n";
            best = candidate;
            min_dist = d;
        }
    }
    //std::cerr << "  --> " << best << "\n";
    return best;
}
void test_getFix() {
	int count = 200;

	while (count--)
	{ assertTrue("Fix should be inside {16, 64, 256, 1024, 4 * 1024, 16 * 1024}", isInsideArray (fixArray, size, getFix() ) ); }
}