Click here to Skip to main content
15,886,199 members
Articles / Artificial Intelligence

Nura Othello - A WTL Based Board Game

Rate me:
Please Sign up or sign in to vote.
4.40/5 (14 votes)
6 Feb 2007CPOL23 min read 79.3K   2.3K   29  
An example of using the WTL library in an artificial intelligence game.
///////////////////////////////////////////////////////////////////////////////
// OthelloCore1.cpp Ver. 1.5
// Programmer: PARK Youngho
///////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include <cstdlib>
#include <cassert>
#include "OthelloCore1.h"

OthelloCore1::OthelloCore1 (const char firstPlayer)
	:OthelloCore(firstPlayer)
{
}

OthelloCore1::OthelloCore1 (int diag, const char firstPlayer)
	:OthelloCore(diag, firstPlayer)
{
}

OthelloCore1::OthelloCore1 (OthelloCore1* that)
	:OthelloCore(that)
{
}

OthelloCore1::~OthelloCore1 (void)
{
}

bool OthelloCore1::SeekBestPoint (int* px, int* py, const int player)
{
	int		bestX = 0, bestY = 0, kill = 0, ret;

	for (int x = 0; x < OTHELLO_WIDTH; x++)
	{
		for (int y = 0; y < OTHELLO_WIDTH; y++)
		{
			ret = Evaluate(C[x], C[y], player);
			if (ret > kill)
			{
				bestX	= C[x];
				bestY	= C[y];
				kill	= ret;
			}
		}
	}
	if (!bestX)
		return false;

	if (px)
		*px = bestX;
	if (py)
		*py = bestY;

	return true;
}

#ifdef OTHELLO_IQ_TEST
OthelloCore1* OthelloCore1::CreateOthelloCoreTest (int diag, const char firstPlayer)
{
	return new OthelloCore1(diag, firstPlayer);
}
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Korea (Republic of) Korea (Republic of)
I like programming.
I am teaching at AUCA (American University of Central Asia) now.

Comments and Discussions