<commit_before>use std::collections::LinkedList;
use std::iter;
use std::mem;
use std::sync::Arc;
use types::{Pos, Coord, CoordDiff, CoordSquare, CoordSum, Score};
use player::Player;
use cell::Cell;
use zobrist::Zobrist;

#[derive(Clone)]
struct FieldChange {
  score_red: Score,
  score_black: Score,
  hash: u64,
  points_changes: Vec<(Pos, Cell)>
}

#[derive(Clone, Copy, PartialEq)]
enum IntersectionState {
  None,
  Up,
  Target,
  Down
}

#[derive(Clone)]
pub struct Field {
  width: Coord,
  height: Coord,
  length: Pos,
  score_red: Score,
  score_black: Score,
  points_seq: Vec<Pos>,
  points: Vec<Cell>,
  changes: Vec<FieldChange>,
  zobrist: Arc<Zobrist>,
  hash: u64
}

pub fn length(width: Coord, height: Coord) -> Pos {
  (width as Pos + 2) * (height as Pos + 2)
}

pub fn to_pos(width: Coord, x: Coord, y: Coord) -> Pos {
  (y as Pos + 1) * (width as Pos + 2) + x as Pos + 1
}

pub fn to_x(width: Coord, pos: Pos) -> Coord {
  (pos % (width as Pos + 2) - 1) as Coord
}

pub fn to_y(width: Coord, pos: Pos) -> Coord {
  (pos / (width as Pos + 2) - 1) as Coord
}

pub fn n(width: Coord, pos: Pos) -> Pos {
  pos - width as Pos + 2
}

pub fn s(width: Coord, pos: Pos) -> Pos {
  pos + width as Pos + 2
}

pub fn w(pos: Pos) -> Pos {
  pos - 1
}

pub fn e(pos: Pos) -> Pos {
  pos + 1<commit_msg>Bugfix.<commit_after>use std::collections::LinkedList;
use std::iter;
use std::mem;
use std::sync::Arc;
use types::{Pos, Coord, CoordDiff, CoordSquare, CoordSum, Score};
use player::Player;
use cell::Cell;
use zobrist::Zobrist;

#[derive(Clone)]
struct FieldChange {
  score_red: Score,
  score_black: Score,
  hash: u64,
  points_changes: Vec<(Pos, Cell)>
}

#[derive(Clone, Copy, PartialEq)]
enum IntersectionState {
  None,
  Up,
  Target,
  Down
}

#[derive(Clone)]
pub struct Field {
  width: Coord,
  height: Coord,
  length: Pos,
  score_red: Score,
  score_black: Score,
  points_seq: Vec<Pos>,
  points: Vec<Cell>,
  changes: Vec<FieldChange>,
  zobrist: Arc<Zobrist>,
  hash: u64
}

pub fn length(width: Coord, height: Coord) -> Pos {
  (width as Pos + 2) * (height as Pos + 2)
}

pub fn to_pos(width: Coord, x: Coord, y: Coord) -> Pos {
  (y as Pos + 1) * (width as Pos + 2) + x as Pos + 1
}

pub fn to_x(width: Coord, pos: Pos) -> Coord {
  (pos % (width as Pos + 2) - 1) as Coord
}

pub fn to_y(width: Coord, pos: Pos) -> Coord {
  (pos / (width as Pos + 2) - 1) as Coord
}

pub fn n(width: Coord, pos: Pos) -> Pos {
  pos - width as Pos - 2
}

pub fn s(width: Coord, pos: Pos) -> Pos {
  pos + width as Pos + 2
}

pub fn w(pos: Pos) -> Pos {
  pos - 1
}

pub fn e(pos: Pos) -> Pos {
  pos + 1
{'fraction_non_alphanumeric': 0.15928189457601222, 'fraction_numerical': 0.012987012987012988, 'mean_word_length': 3.431472081218274, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 29, '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': '5723585', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1043, 'n_words': 339}