<commit_before>/*
 * negamax.h
 *
 *  Created on: Nov 1, 2009
 *      Author: petergoodman
 *     Version: $Id$
 */

#include "negamax.h"

/**
 * Evaluate a game state.
 */
static int evaluate(board_t *board) {
    board_cell_t *cell = &(board->cells[0][0]);
    board_cell_t *max = cell + BOARD_NUM_CELLS;
    int max_threat = 0;
    int max_benefit = 0;

    for(; cell < max; ++cell) {
        if(cell->player_id == NO_PLAYER) {
            max_threat = MAX(max_threat, cell->threat);
            max_benefit = MAX(max_benefit, cell->benefit);
        }
    }

    return (max_threat > max_benefit ? -1 : 1) * cell->weight;
}

/**
 * Recursively calculate an approximation of the Negamax value of a the
 * successors of a given game state. This function yields the chosen next
 * move by means of max_cell.
 */<commit_msg>minor update to the evaluation function.<commit_after>/*
 * negamax.h
 *
 *  Created on: Nov 1, 2009
 *      Author: petergoodman
 *     Version: $Id$
 */

#include "negamax.h"

/**
 * Evaluate a game state.
 */
static int evaluate(board_t *board) {
    board_cell_t *cell = &(board->cells[0][0]);
    board_cell_t *max = cell + BOARD_NUM_CELLS;
    int max_threat = 0;
    int max_benefit = 0;
    int max_weight = 0;

    for(; cell < max; ++cell) {
        if(cell->player_id == NO_PLAYER) {
            max_threat = MAX(max_threat, cell->threat);
            max_benefit = MAX(max_benefit, cell->benefit);
            max_weight = MAX(max_weight, cell->weight);
        }
    }

    return (max_threat > max_benefit ? -1 : 1) * max_weight; /*cell->weight;*/
}

/**
 * Recursively calculate an approximation of the Negamax value of a the
 * successors of a given game state. This function yields the chosen next
 * move by means of max_cell.
 */
{'fraction_non_alphanumeric': 0.12803158488437677, 'fraction_numerical': 0.012972363226170333, 'mean_word_length': 2.6728778467908905, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, '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': '5024531', 'n_tokens_mistral': 651, 'n_tokens_neox': 608, 'n_words': 172}