Commit 09d52e27 authored by Emil's avatar Emil

added 3 functions to utility.cpp

parent 981fa8c7
......@@ -90,7 +90,7 @@ namespace std
namespace gameengine // resume namespace gameengine
{
using BitPieces = std::bitset<detail::computeBoardSize()>;
using BitBoard = std::array<BitPieces, 2>;
using BitBoard = std::array<BitPieces, 4>;
using BitPosSet = std::unordered_set<BitPos>;
......
#include "engine/utility.h"
//#include "engine/basic_types.h"
// stl
#include <numeric>
#include <iostream>
#include <functional>
#include <algorithm>
namespace gameengine::utility
{
BitPieces occupiedPositions(const BitBoard& /*board*/) { return {}; }
BitPieces occupiedPositions(const BitBoard& board)
{
return std::accumulate(std::cbegin(board),std::cend(board), gameengine::BitPieces(), std::bit_or()) ;
}
bool occupied(const BitPieces& /*pieces*/, const BitPos& /*board_pos*/)
bool occupied(const BitPieces& pieces, const BitPos& board_pos)
{
return true;
return pieces.test(board_pos.value());
}
bool occupied(const BitBoard& /*board*/, const BitPos& /*board_pos*/)
bool occupied(const BitBoard& board, const BitPos& board_pos)
{
return false;
return occupied(occupiedPositions(board),board_pos);
}
BitPos nextPosition(const BitPos& /*board_pos*/, const MoveDirection& /*dir*/)
BitPos nextPosition(const BitPos& board_pos, const MoveDirection& dir)
{
return {};
if (dir.value()== N && board_pos.value() < 55)
return board_pos.value()+8;
}
BitPosSet legalMoves(const BitBoard& /*board*/, const PlayerId& /*player_id*/)
......
......@@ -120,13 +120,13 @@ INSTANTIATE_TEST_CASE_P(
ValidMoves_DataSet_0, NextPosition,
testing::Values(NextPositionParams{BitPos(0), MoveDirection::N, BitPos(8)},
NextPositionParams{BitPos(9), MoveDirection::S,
BitPos(1)}), );
BitPos(1)}) );
INSTANTIATE_TEST_CASE_P(
InvalidMoves_DataSet_0, NextPosition,
testing::Values(
NextPositionParams{BitPos(1), MoveDirection::S, BitPos::invalid()},
NextPositionParams{BitPos(61), MoveDirection::N, BitPos::invalid()}), );
NextPositionParams{BitPos(61), MoveDirection::N, BitPos::invalid()}) );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment