<commit_before>(ns tictactoe.logic.board
  (:require
    [cljs.spec :as s :include-macros true]
    [tictactoe.logic.constants :as cst]
    [tictactoe.utils.algo :as algo]))

(s/def ::pos #(and (integer? %) (< % cst/board-size)))
(s/def ::coord (s/tuple ::pos ::pos))
(s/def ::owner #{:cell/circle :cell/empty :cell/cross})
(s/def ::board (s/map-of ::coord ::owner))

(defn new-empty-board
  []
  (zipmap cst/coordinates (repeat :cell/empty)))

(defn convert-cell
  "Assign the cell [x y] to a new player"
  [board player x y]
  (assoc board [x y] player))

(defn has-owner?
  "Check whether the cell [x y] is empty"
  [board x y]
  (= (get board [x y]) :cell/empty))

(defn full-board?
  "Verifies whether the board has any empty cell left"
  [board]
  (not-any? #{:cell/empty} (map second board)))

(defn get-size [_] cst/board-size)
(defn get-owners-by-coord [board] board)<commit_msg>simplify board<commit_after>(ns tictactoe.logic.board
  (:require
    [tictactoe.logic.constants :as cst]
    ))

(defn new-empty-board
  []
  (zipmap cst/coordinates (repeat :cell/empty)))

(defn convert-cell
  "Assign the cell [x y] to a new player"
  [board player x y]
  (assoc board [x y] player))

(defn has-owner?
  "Check whether the cell [x y] is empty"
  [board x y]
  (= (get board [x y]) :cell/empty))

(defn full-board?
  "Verifies whether the board has any empty cell left"
  [board]
  (not-any? #{:cell/empty} (vals board)))

(defn get-size [_] cst/board-size)
(defn get-owners-by-coord [board] board)
{'fraction_non_alphanumeric': 0.16888297872340424, 'fraction_numerical': 0.0, 'mean_word_length': 3.703125, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '4993659', 'n_tokens_mistral': 598, 'n_tokens_neox': 587, 'n_words': 175}