<commit_before>package main

import (
	"fmt"
	"log"
	"strconv"
	"strings"
	"time"
)

func XboardParse(line string, board *Board, verbose bool) (*Board, string) {
	if verbose {
		log.Println(line)
	}
	words := strings.Split(line, " ")
	if len(words) == 0 {
		return board, "\n"
	}
	switch words[0] {
	case "perft":
		if len(words) > 2 {
			depth, err := strconv.Atoi(words[1])
			if err != nil {
				return board, err.Error()
			}
			var expected uint64
			expected, err = strconv.ParseUint(words[2], 10, 64)
			if err != nil {
				return board, err.Error()
			}
			if Perft(depth, board, false) == expected {
				return board, "SUCCESS\n"
			} else {
				return board, "FAILURE\n"
			}
		}
	case "divide":
		if len(words) > 1 {
			res, err := strconv.Atoi(words[1])
			if err == nil {
				start := time.Now()
				nodes := Perft(res, board, true)
				elapsed := time.Since(start)
				log.Printf("Divide took %s", elapsed)
				return board, strconv.FormatUint(nodes, 10) + "\n"
			} else {
				return board, err.Error()
			}
		}
	case "setboard":
		board, _ = Parse(strings.TrimPrefix(line, "setboard "))
	case "usermove":
		if len(words) > 1 {
			move, err := ParseMove(board, words[1])
			if err == nil {
				MakeMove(board, move)
			} else {
				return board, err.Error()
			}
		}
	case "go":
		move := FindMove(board)
		return board, fmt.Sprintln("move", MoveToLongAlgebraic(move))
	case "d":
		return board, PrintBoard(board)
	}
	return board, "\n"
}<commit_msg>xboard handshaking noops<commit_after>package main

import (
	"fmt"
	"log"
	"strconv"
	"strings"
	"time"
)

func XboardParse(line string, board *Board, verbose bool) (*Board, string) {
	if verbose {
		log.Println(line)
	}
	words := strings.Split(line, " ")
	if len(words) == 0 {
		return board, "\n"
	}
	switch words[0] {
	case "perft":
		if len(words) > 2 {
			depth, err := strconv.Atoi(words[1])
			if err != nil {
				return board, err.Error()
			}
			var expected uint64
			expected, err = strconv.ParseUint(words[2], 10, 64)
			if err != nil {
				return board, err.Error()
			}
			if Perft(depth, board, false) == expected {
				return board, "SUCCESS\n"
			} else {
				return board, "FAILURE\n"
			}
		}
	case "divide":
		if len(words) > 1 {
			res, err := strconv.Atoi(words[1])
			if err == nil {
				start := time.Now()
				nodes := Perft(res, board, true)
				elapsed := time.Since(start)
				log.Printf("Divide took %s", elapsed)
				return board, strconv.FormatUint(nodes, 10) + "\n"
			} else {
				return board, err.Error()
			}
		}
	case "setboard":
		board, _ = Parse(strings.TrimPrefix(line, "setboard "))
	case "usermove":
		if len(words) > 1 {
			move, err := ParseMove(board, words[1])
			if err == nil {
				MakeMove(board, move)
			} else {
				return board, err.Error()
			}
		}
	case "go":
		move := FindMove(board)
		return board, fmt.Sprintln("move", MoveToLongAlgebraic(move))
	case "d":
		return board, PrintBoard(board)
	case "xboard", "post", "nopost", "random":
		return board, ""
	}
	return board, "\n"
}
{'fraction_non_alphanumeric': 0.16344873501997337, 'fraction_numerical': 0.011318242343541944, 'mean_word_length': 3.060810810810811, 'pattern_counts': {'":': 13, '<': 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': '5031796', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1138, 'n_words': 291}