From 35075a693dff1156ef71849585efe8df4c882dcb Mon Sep 17 00:00:00 2001 From: L50six <137829522+L50six@users.noreply.github.com> Date: Sat, 11 May 2024 12:02:38 +0200 Subject: [PATCH] Update ch6_horseplay.cpp Main code before refinemenrs --- src/06/Challenge/ch6_horseplay.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/06/Challenge/ch6_horseplay.cpp b/src/06/Challenge/ch6_horseplay.cpp index bb3dafe..73d1c68 100644 --- a/src/06/Challenge/ch6_horseplay.cpp +++ b/src/06/Challenge/ch6_horseplay.cpp @@ -25,10 +25,24 @@ std::vector knight_moves(std::string knight){ } vector KnightMoves = { - {1,2},{-1,2},{-1,-2}, {-1,2}, + {1,2},{-1,2},{-1,-2}, {1,-2}, {2,1},{-2,1},{-2,-1},{2,-1} }; + x = static_cast(knight[[0]); + y = static_cast(knight[[1]); + + // needs assci offset + + for (const KnightMove& move: KnightMoves) { + x += move.dx; + y += move.dy; + if ((x > 0) && (x<9) && (y > 0) && (y<9)) { + moves.push_back(std::itos(x),std::itos(y)) + // columns need to be converrted to letterw. + } + } + return moves; }