<commit_before>/*
 * Fiahil
 * 25.05.2012
 */

#include <algorithm>
#include "AIView.hpp"

View::View(Elt::eElt elt, size_t i)
  : type(elt), pp(i)
{
}

View::View()
  : type(Elt::EMPTY), pp(0)
{
}

AIView::AIView(Map const& m)
  : _x(m.getX()),
    _y(m.getY())
{
  this->_view.resize(m.getMap().size());
  std::transform(m.getMap().begin(), m.getMap().end(), this->_view.begin(), &AIView::ctor);
}

View		AIView::ctor(char const c)
{
  return View(Elt::WALL, c - '0');
}

size_t		AIView::getX(void) const
{
  return this->_x;
}

size_t		AIView::getY(void) const
{
  return this->_y;
}

void		AIView::setBombAt(size_t x, size_t y)
{
  this->_view[AIPOS(x, y)].type = Elt::BOMB;
  this->_view[AIPOS(x, y)].pp = 0;
}

void		AIView::setBonusAt(size_t x, size_t y, BonusType::eBonus b)
{
  this->_view[AIPOS(x, y)].type = Elt::BONUS;
  this->_view[AIPOS(x, y)].pp = b;
}

View const&	AIView::at(size_t x, size_t y) const
{
  x = (x > 0) ? x : 0;
  x = (x < this->_x) ? x : this->_x - 1;
  y = (y > 0) ? y : 0;
  y = (y < this->_y) ? y : this->_y - 1;
  return this->_view.at(AIPOS(x, y));
}<commit_msg>Refactoring AIView<commit_after>/*
 * Fiahil
 * 25.05.2012
 */

#include <algorithm>
#include "AIView.hpp"

View::View(Elt::eElt elt, size_t i)
  : type(elt),
    pp(i)
{
}

View::View()
  : type(Elt::EMPTY),
    pp(0)
{
}

AIView::AIView(Map const& m)
  : _x(m.getX()),
    _y(m.getY())
{
  this->_view.resize(m.getMap().size());
  std::transform(m.getMap().begin(), m.getMap().end(), this->_view.begin(), &AIView::ctor);
}

View		AIView::ctor(char const c)
{
  return View(Elt::WALL, c - '0');
}

size_t		AIView::getX(void) const
{
  return this->_x;
}

size_t		AIView::getY(void) const
{
  return this->_y;
}

void		AIView::setBombAt(size_t x, size_t y)
{
  this->_view.at(AIPOS(x, y)).type = Elt::BOMB;
  this->_view.at(AIPOS(x, y)).pp = 0;
}

void		AIView::setBonusAt(size_t x, size_t y, BonusType::eBonus b)
{
  this->_view.at(AIPOS(x, y)).type = Elt::BONUS;
  this->_view.at(AIPOS(x, y)).pp = b;
}

View const&	AIView::at(size_t x, size_t y) const
{
  x = (x > 0) ? x : 0;
  x = (x < this->_x) ? x : this->_x - 1;
  y = (y > 0) ? y : 0;
  y = (y < this->_y) ? y : this->_y - 1;
  return this->_view.at(AIPOS(x, y));
}
{'fraction_non_alphanumeric': 0.23121907332433647, 'fraction_numerical': 0.015294646873594242, 'mean_word_length': 3.5387755102040814, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3253420', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1071, 'n_words': 201}