<commit_before>package ru.org.codingteam.icfpc.visual

import java.awt.{Color, Graphics2D, Graphics}
import javax.swing.JPanel


class Board(val rowsCount: Int, val colsCount: Int) extends JPanel {
  private val cells = Array.fill(rowsCount, colsCount)(Color.WHITE)

  override def paintComponent(g: Graphics): Unit = {
    val g2 = g.asInstanceOf[Graphics2D]
    renderCells(g2)
    renderGrid(g2)
  }


  private def renderGrid(g2: Graphics2D): Unit = {
    val cellWidth = getWidth / colsCount.toFloat
    val cellHeight = getHeight / rowsCount.toFloat

    g2.setColor(Color.BLACK)

    for (i <- 1 until colsCount) {
      g2.drawLine((i * cellWidth).toInt, 0, (i * cellWidth).toInt, getHeight)
    }

    for (i <- 1 until rowsCount) {
      g2.drawLine(0, (i * cellHeight).toInt, getWidth, (i * cellHeight).toInt)
    }
  }

  private def renderCells(g2: Graphics2D): Unit = {
    val cellWidth = getWidth / colsCount.toFloat
    val cellHeight = getHeight / rowsCount.toFloat

    for (row <- 0 until rowsCount) {
      for (col <- 0 until colsCount) {
        g2.setColor(cells(row)(col))
        g2.fillRect((col * cellWidth).toInt, (row * cellHeight).toInt,
          cellWidth.toInt, cellHeight.toInt)
      }
    }
  }

  def putCell(row: Int, col: Int, color: Color): Unit = {
    cells(row)(col) = color
  }
}<commit_msg>Visualizator: implement cell shift<commit_after>package ru.org.codingteam.icfpc.visual

import java.awt.{Color, Graphics2D, Graphics}
import javax.swing.JPanel


class Board(val rowsCount: Int, val colsCount: Int) extends JPanel {
  private val cells = Array.fill(rowsCount, colsCount)(Color.WHITE)

  override def paintComponent(g: Graphics): Unit = {
    val g2 = g.asInstanceOf[Graphics2D]
    g2.setColor(Color.GRAY)
    g2.fillRect(0, 0, getWidth, getHeight)

    renderCells(g2)
  }


  private def renderGrid(g2: Graphics2D): Unit = {
    val cellWidth = getWidth / colsCount.toFloat
    val cellHeight = getHeight / rowsCount.toFloat

    g2.setColor(Color.BLACK)

    for (i <- 1 until colsCount) {
      g2.drawLine((i * cellWidth).toInt, 0, (i * cellWidth).toInt, getHeight)
    }

    for (i <- 1 until rowsCount) {
      g2.drawLine(0, (i * cellHeight).toInt, getWidth, (i * cellHeight).toInt)
    }
  }

  private def renderCells(g2: Graphics2D): Unit = {
    val cellWidth = getWidth / (colsCount + 1).toFloat
    val cellHeight = getHeight / rowsCount.toFloat

    for (row <- 0 until rowsCount) {
      for (col <- 0 until colsCount) {
        val shift = if (row % 2 == 0) {
          0.0
        } else {
          cellWidth / 2.0
        }

        g2.setColor(cells(row)(col))
        g2.fillRect((col * cellWidth + shift).toInt, (row * cellHeight).toInt,
          cellWidth.toInt, cellHeight.toInt)

        g2.setColor(Color.BLACK)
        g2.drawRect((col * cellWidth + shift).toInt, (row * cellHeight).toInt,
          cellWidth.toInt, cellHeight.toInt)

      }
    }
  }

  def putCell(row: Int, col: Int, color: Color): Unit = {
    cells(row)(col) = color
  }
}
{'fraction_non_alphanumeric': 0.12520647505781302, 'fraction_numerical': 0.017178724810042945, 'mean_word_length': 2.8524173027989823, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1214933', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1043, 'n_words': 243}