<commit_before>package emil

import (
	"fmt"
)

type DTM struct {
	dtm  int // Depth to mate
	move *Move
}

func (d *DTM) String() string {
	return fmt.Sprintf("%d/%s", d.dtm, d.move)
}

type Analysis struct {
	board     *Board
	dtmWhite  []*DTM
	dtmWBlack []*DTM

	moves map[string]bool
}

func (a *Analysis) DTMs(player int) []*DTM {
	if player == WHITE {
		return a.dtmWhite
	}
	return a.dtmWBlack
}
func (a *Analysis) addDTM(move *Move, dtm int) {
	if _, ok = moves[move.String()]; ok {
		return // we have this move allready
	}
	moves[move.String()] = true

	if move.player == WHITE {
		a.dtmWhite = append(a.dtmWhite, &DTM{move: move, dtm: dtm})
	} else {
		a.dtmWBlack = append(a.dtmWBlack, &DTM{move: move, dtm: dtm})
	}
}

func (a *Analysis) playerHaveDTMs() bool {
	return (len(a.dtmWhite) + len(a.dtmWBlack)) > 0
}

func (a *Analysis) BestMove(player int) (bestMove *Move) {
	dtms := a.DTMs(player)
	minDTM := 9999

	// white minimizes DTM
	for _, d := range dtms {
		if d.dtm < minDTM {
			minDTM = d.dtm
			bestMove = d.move
		}
	}
	// TODO best move for black
	return bestMove
}

func (a *Analysis) Board() *Board {<commit_msg>do not add a move twice - fix<commit_after>package emil

import (
	"fmt"
)

type DTM struct {
	dtm  int // Depth to mate
	move *Move
}

func (d *DTM) String() string {
	return fmt.Sprintf("%d/%s", d.dtm, d.move)
}

type Analysis struct {
	board     *Board
	dtmWhite  []*DTM
	dtmWBlack []*DTM

	moves map[string]bool
}

func (a *Analysis) DTMs(player int) []*DTM {
	if player == WHITE {
		return a.dtmWhite
	}
	return a.dtmWBlack
}
func (a *Analysis) addDTM(move *Move, dtm int) {
	if _, ok := a.moves[move.String()]; ok {
		return // we have this move allready
	}
	a.moves[move.String()] = true

	if move.player == WHITE {
		a.dtmWhite = append(a.dtmWhite, &DTM{move: move, dtm: dtm})
	} else {
		a.dtmWBlack = append(a.dtmWBlack, &DTM{move: move, dtm: dtm})
	}
}

func (a *Analysis) playerHaveDTMs() bool {
	return (len(a.dtmWhite) + len(a.dtmWBlack)) > 0
}

func (a *Analysis) BestMove(player int) (bestMove *Move) {
	dtms := a.DTMs(player)
	minDTM := 9999

	// white minimizes DTM
	for _, d := range dtms {
		if d.dtm < minDTM {
			minDTM = d.dtm
			bestMove = d.move
		}
	}
	// TODO best move for black
	return bestMove
}

func (a *Analysis) Board() *Board {
{'fraction_non_alphanumeric': 0.15284411636995224, 'fraction_numerical': 0.004342162396873643, 'mean_word_length': 3.2905027932960893, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2581002', 'n_tokens_mistral': 1005, 'n_tokens_neox': 970, 'n_words': 262}