<commit_before>
package org.godfat.mine

import org.psmonkey.product.client.mine.vo.GameInfo
import org.psmonkey.product.server.mine.AI_Interface
import org.psmonkey.product.server.mine.MineGM

class Godfat extends AI_Interface{
  override def guess(info: GameInfo, xy: Array[Int]){
    val result = think(info.getMap())
    xy.update(0, result._1)
    xy.update(1, result._2)
  }

  def think(map: Array[Array[Int]]): (Int, Int) = (0, 0)
}<commit_msg>discarded approach...... only committed for history<commit_after>
// package org.godfat.mine

import org.psmonkey.product.client.mine.vo.GameInfo
import org.psmonkey.product.server.mine.AI_Interface
import org.psmonkey.product.server.mine.MineGM

import scala.collection.immutable.TreeMap

class Godfat extends AI_Interface{
  override def guess(info: GameInfo, xy: Array[Int]){
    val result = Imp(info.getMap()).pick
    xy.update(0, result._1)
    xy.update(1, result._2)
  }
}

case class Imp(val map_raw: Array[Array[Int]]){
  type Priority = Double
  type MineSize = Int

  type Choices  = TreeMap[Pos, Priority]
  type MineMap  = TreeMap[Pos, MineSize]

  val  Choices = TreeMap
  val  MineMap = TreeMap

  type Idx = Int
  type Pos = (Idx, Idx)

  val available: Int = -1

  def width : Int = map_raw.size
  def height: Int = map_raw.head.size

  // pick the most priority
  def pick: Pos = choices.max(Ordering[Priority].on[(Pos, Priority)](_._2))._1

  // all choices (available block) with calculated priority
  def choices:      Choices = map_dug.foldRight(init_choices)(think(_, _))

  // all choices (available block) with 0 priority
  def init_choices: Choices = map.filter(_._2 == available).mapValues(_ => 0).
    asInstanceOf[Choices]

  // blocks that have already been dug
  def map_dug: MineMap = map.filter(_._2 > 0)

  // our map data structure
  def map: MineMap =
    Range(0, width).foldRight(MineMap[Pos, MineSize]())(
      (x: Idx, m: MineMap) => Range(0, height).foldRight(m)(
        (y: Idx, m: MineMap) => m.insert((x, y), map_raw(x)(y))
      )
    )

  // calculate priorities with a dug block
  def think(pos_size: (Pos, MineSize), result: Choices): Choices =
    Range(-1, 1).foldRight(result)(
      (x: Int, result: Choices) => Range(-1, 1).foldRight(result)(
        (y: Int, result: Choices) => nearby()
      )
    )
    nearby(pos_size._1).
    result.insert()

  // take nearby blocks
  def nearby(pos: Pos): List[Pos]
}

println(Imp(Array(Array(0,1), Array(2,3))).map)
{'fraction_non_alphanumeric': 0.14030819140308193, 'fraction_numerical': 0.011759935117599351, 'mean_word_length': 3.5769944341372915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2037290', 'n_tokens_mistral': 888, 'n_tokens_neox': 855, 'n_words': 215}