Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "NintendoSwitch/Inference/NintendoSwitch_UpdatePopupDetector.h"
#include "NintendoSwitch/Programs/Typewriter/NintendoSwitch_Typewriter_Tests.h"

#include "Pokemon/Navigation/Pokemon_Navigation_Tests.h"
#include "VideoGames/PokemonHome/PokemonHome_Tests.h"
#include "VideoGames/PokemonSwSh/PokemonSwSh_Tests.h"
#include "VideoGames/PokemonLA/PokemonLA_Tests.h"
Expand All @@ -46,7 +47,7 @@



UnitTestDatabase make_UNIT_TESTS_ALL(){

Check warning on line 50 in SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::ComputerPrograms::make_UNIT_TESTS_ALL(): function_lines=29 (advisory above 25, limit 50)
UnitTestDatabase ret;

add_tests_QtEventThreadPool(ret, GlobalThreadPools::computation_normal());
Expand All @@ -60,6 +61,7 @@
add_tests_LabControl(ret);
OCR::add_tests(ret);
Kernels::add_tests(ret);
Pokemon::add_tests_LegPlanner(ret);
NintendoSwitch::add_tests_CheckOnlineDetector(ret);
NintendoSwitch::add_tests_FailedToConnectDetector(ret);
NintendoSwitch::add_tests_UpdatePopupDetector(ret);
Expand Down
49 changes: 49 additions & 0 deletions SerialPrograms/Source/Pokemon/Navigation/Pokemon_Grid.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* Grid
*
* From: https://github.com/PokemonAutomation/
*
*/

#include "Pokemon_Grid.h"

namespace PokemonAutomation{
namespace Pokemon{


const char* direction_name(Direction direction){
switch (direction){
case Direction::NORTH:
return "north";
case Direction::EAST:
return "east";
case Direction::SOUTH:
return "south";
case Direction::WEST:
return "west";
}
return "?";
}


TilePos TilePos::next(Direction direction) const{
switch (direction){
case Direction::NORTH:
return {x, y - 1};
case Direction::EAST:
return {x + 1, y};
case Direction::SOUTH:
return {x, y + 1};
case Direction::WEST:
return {x - 1, y};
}
return *this;
}

std::string to_string(const TilePos& pos){
return "(" + std::to_string(pos.x) + ", " + std::to_string(pos.y) + ")";
}



}
}
57 changes: 57 additions & 0 deletions SerialPrograms/Source/Pokemon/Navigation/Pokemon_Grid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* Grid
*
* From: https://github.com/PokemonAutomation/
*
* Tiles and directions on an overworld grid, shared by the games that
* move the player a tile at a time.
*
*/

#ifndef PokemonAutomation_Pokemon_Grid_H
#define PokemonAutomation_Pokemon_Grid_H

#include <cstddef>
#include <functional>
#include <string>

namespace PokemonAutomation{
namespace Pokemon{


// Row 0 is the top of a map, so SOUTH increases y.
enum class Direction{
NORTH,
EAST,
SOUTH,
WEST,
};
constexpr Direction ALL_DIRECTIONS[] = {
Direction::NORTH, Direction::EAST, Direction::SOUTH, Direction::WEST,
};
const char* direction_name(Direction direction);


struct TilePos{
int x = 0;
int y = 0;

TilePos next(Direction direction) const;
bool operator==(const TilePos& other) const = default;
};
std::string to_string(const TilePos& pos);



}
}


template <>
struct std::hash<PokemonAutomation::Pokemon::TilePos>{
size_t operator()(const PokemonAutomation::Pokemon::TilePos& pos) const{
return std::hash<long long>()(((long long)pos.x << 32) ^ (unsigned)pos.y);
}
};


#endif
Loading
Loading