45 : xsize_(horz), ysize_(vert), cells(horz * vert,
Cell_Empty)
63 return cells.at(x + xsize_ * y);
69 return cells.at(x + xsize_ * y);
75 return (*
this)(p.first, p.second);
81 return (*
this)(p.first, p.second);
90 template <
class Visitor>
91 void scan(Visitor visitor)
const
93 visitor (0, 0, cells[0]);
94 for (
Index x = 0, i = 1, sz = cells.size(); i < sz; ++i)
97 visitor (1 - xsize_, 1, cells[i]), x = 0;
99 visitor (1, 0, cells[i]);
104 Index xsize_, ysize_;
105 std::vector<Cell> cells;
168 if (field.
xsize() <= new_head.first || field.
ysize() <= new_head.second)
179 switch (
const Cell next_cell = field[new_head])
189 field[new_head] = Cell_Snake;
200 typedef std::vector<Position> Positions;
211 for (
Index i = 0; i < snake_len; ++i)
213 const Position block(snake_len - i - 1, 0);
215 field[block] = Cell_Snake;
220 Position
moved(
const Position &p)
const
222 return Position(p.first + vx, p.second + vy);
269 operator Score()
const {
return number;}
271 const std::string&
str()
const {
return repr; }