예제 #1
0
	bool UnitTests::TileManager_Test2()
	{
		// GetStartPosition
		bool _result = true;
		bool _placed = false;
		TA::TileManager *tlm = TA::Game::getInstance()->GetTileManager();

		sf::Vector2f _startTile = tlm->GetStartPosition();
		if(_startTile.x == 9999 && _startTile.y == 9999) // No existing start tile found, add one
		{
			// Place start tile
			std::shared_ptr<TileRoad> _tile(new TileRoad(99, 666, 666));
			tlm->Add(666, 666, _tile);
			_placed = true;
		}
		_startTile = tlm->GetStartPosition();
		bool* _startPos = tlm->Get(unsigned int(_startTile.x), unsigned int(_startTile.y))->GetMovableDirections();
		// If GetStartPosition returned the start tile position, we can check the movable directions of it
		_result = (!_startPos[0] && !_startPos[1] && _startPos[2] && !_startPos[3]);
		
		// Clean up
		if(_placed)
			tlm->Remove(666, 666);

		return _result;
	}
예제 #2
0
	bool UnitTests::TileManager_Test1()
	{
		// CheckMovable
		bool _result = true;
		TA::TileManager *tlm = TA::Game::getInstance()->GetTileManager();

		// Place start tile
		std::shared_ptr<TileRoad> _tile(new TileRoad(99, 666, 666));
		tlm->Add(666, 666, _tile);

		// Check that we get true for movable(right)
		_result = tlm->CheckMovable(666, 666, "right");

		// Check that we get false for movable(up)
		if(_result) _result = !(tlm->CheckMovable(666, 666, "up"));

		// Check that we get false for movable(left)
		if(_result) _result = !(tlm->CheckMovable(666, 666, "left"));

		// Check that we get false for movable(down)
		if(_result) _result = !(tlm->CheckMovable(666, 666, "down"));
		
		// Clean up
		tlm->Remove(666, 666);

		return _result;
	}
예제 #3
0
inline std::atomic<Ob> &SymmetricFunction::value(Ob i, Ob j) const {
    sort(i, j);
    POMAGMA_ASSERT5(support().contains(i), "unsupported lhs: " << i);
    POMAGMA_ASSERT5(support().contains(j), "unsupported rhs: " << j);
    std::atomic<Ob> *tile = _tile(i / ITEMS_PER_TILE, j / ITEMS_PER_TILE);
    return _tile2value(tile, i & TILE_POS_MASK, j & TILE_POS_MASK);
}
예제 #4
0
 typename types::numpy_expr_to_ndarray<E>::type tile(E const& expr, int reps)
 {
     size_t n = expr.flat_size();
     typename types::numpy_expr_to_ndarray<E>::type out(types::array<long, 1>{{long(n * reps)}}, __builtin__::None);
     auto out_iter = out.fbegin();
     _tile(expr.begin(), expr.end(), out_iter, utils::int_<types::numpy_expr_to_ndarray<E>::N>());
     for(int i = 1; i< reps; ++i)
         out_iter = std::copy(out.fbegin(), out.fbegin() + n, out_iter);
     return out;
 }
예제 #5
0
	bool UnitTests::Tile_Test1()
	{
		// GetMovable
		bool _result = true;
		
		// Place start tile
		std::shared_ptr<TileRoad> _tile(new TileRoad(99, 666, 666));

		// Check the directions for the start tile
		_result = !(_tile->GetMovable("up")) && _tile->GetMovable("right");

		return _result;
	}
예제 #6
0
            types::ndarray<typename types::numpy_expr_to_ndarray<E>::T, N> tile(E const& expr, types::array<long, N> const& reps)
            {
                size_t n = expr.flat_size();
                types::array<long, N> shape;
                for(size_t i=0; i<N; ++i)
                    shape[N - i - 1] = reps[N - i - 1] * ((E::value > i)?expr.shape[i]:1);
                types::ndarray<typename types::numpy_expr_to_ndarray<E>::T, N> out(shape, __builtin__::None);
                auto out_iter = out.fbegin();
                _tile(expr.begin(), expr.end(), out_iter, utils::int_<types::numpy_expr_to_ndarray<E>::N>());

                size_t nreps = out.flat_size() / n;
                for(size_t i = 1; i< nreps; ++i)
                    out_iter = std::copy(out.fbegin(), out.fbegin() + n, out_iter);
                return out;
            }
예제 #7
0
	bool UnitTests::Tile_Test2()
	{
		// GetMovableDirections
		bool _result = true;
		bool _placed = false;
		TA::TileManager *tlm = TA::Game::getInstance()->GetTileManager();

		// Place start tile
		std::shared_ptr<TileRoad> _tile(new TileRoad(99, 666, 666));

		bool* _startPos = _tile->GetMovableDirections();
		// If GetStartPosition returned the start tile position, we can check the movable directions of it
		_result = (!_startPos[0] && !_startPos[1] && _startPos[2] && !_startPos[3]);

		return _result;
	}
예제 #8
0
 void _tile(I begin, I end, O& out, utils::int_<N>)
 {
     for(; begin != end; ++begin)
         _tile((*begin).begin(), (*begin).end(), out, utils::int_<N - 1>());
 }