<commit_before>
# pragma once

#include "board.h"
#include "move.h"
#include "policy.h"

class LastGoodReply : public Policy {
	Move goodreply[2][Board::max_vecsize];
	int enabled;
public:

	LastGoodReply(int _enabled = 2) : enabled(_enabled) {
		for(int p = 0; p < 2; p++)
			for(int i = 0; i < Board::max_vecsize; i++)
				goodreply[p][i] = M_UNKNOWN;
	}

	Move choose_move(const Board & board, const Move & prev) const {
		if (enabled && prev != M_SWAP) {
			Move move = goodreply[board.toplay()-1][board.xy(prev)];
			if(move != M_UNKNOWN && board.valid_move_fast(move))
				return move;
		}
		return M_UNKNOWN;
	}

	void rollout_end(const Board & board, const MoveList & movelist, int won) {
		if(!enabled)
			return;
		int m = -1;
		for(const MovePlayer * i = movelist.begin(), * e = movelist.end(); i != e; i++){
			if(m >= 0){
				if(i->player == won && *i != M_SWAP)
					goodreply[i->player - 1][m] = *i;
				else if(enabled == 2)
					goodreply[i->player - 1][m] = M_UNKNOWN;
			}
			m = board.xy(*i);
		}
	}
};<commit_msg>Unneeded check, but make it similar to games that can tie.<commit_after>
# pragma once

#include "board.h"
#include "move.h"
#include "policy.h"

class LastGoodReply : public Policy {
	Move goodreply[2][Board::max_vecsize];
	int enabled;
public:

	LastGoodReply(int _enabled = 2) : enabled(_enabled) {
		for(int p = 0; p < 2; p++)
			for(int i = 0; i < Board::max_vecsize; i++)
				goodreply[p][i] = M_UNKNOWN;
	}

	Move choose_move(const Board & board, const Move & prev) const {
		if (enabled && prev != M_SWAP) {
			Move move = goodreply[board.toplay()-1][board.xy(prev)];
			if(move != M_UNKNOWN && board.valid_move_fast(move))
				return move;
		}
		return M_UNKNOWN;
	}

	void rollout_end(const Board & board, const MoveList & movelist, int won) {
		if(!enabled || won <= 0)
			return;
		int m = -1;
		for(const MovePlayer * i = movelist.begin(), * e = movelist.end(); i != e; i++){
			if(m >= 0){
				if(i->player == won && *i != M_SWAP)
					goodreply[i->player - 1][m] = *i;
				else if(enabled == 2)
					goodreply[i->player - 1][m] = M_UNKNOWN;
			}
			m = board.xy(*i);
		}
	}
};
{'fraction_non_alphanumeric': 0.17411764705882352, 'fraction_numerical': 0.010823529411764706, 'mean_word_length': 3.374485596707819, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 11, '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': '6926703', 'n_tokens_mistral': 925, 'n_tokens_neox': 822, 'n_words': 208}