|
#region Using directives
using System;
using System.Collections;
using System.Text;
#endregion
namespace gma.Reversi
{
public abstract class Player
{
public int Score(Board aBoard)
{
int dominance = aBoard.CounterWhite - aBoard.CounterRed;
if (_playerColor != gma.Reversi.Board.PLAYER_WHITE) dominance = -dominance;
int weight = aBoard.WeightWhite - aBoard.WeightRed;
if (_playerColor != gma.Reversi.Board.PLAYER_WHITE) weight = -weight;
int mobility = aBoard.GetAvailableMoves(aBoard.CurrentPlayer).Count;
if (aBoard.CurrentPlayer == _playerColor) mobility = -mobility;
int stability = aBoard.GetIrreversibleCount(_playerColor) - aBoard.GetIrreversibleCount(-_playerColor);
return dominance + 10 * weight + 3 * mobility + 5 * stability;
}
public Player(BoardComplex Board)
{
this.Board=Board;
}
protected BoardComplex _board = null;
public BoardComplex Board
{
get { return _board;}
set
{
_board=value;
_board.OnMoveTransferred+=new OnMoveTransferredEvent(_board_OnMoveTransferred);
}
}
private int _playerColor = gma.Reversi.Board.PLAYER_WHITE;
public int PlayerColor
{
get { return _playerColor; }
set { _playerColor = value; }
}
protected abstract void _board_OnMoveTransferred(int aNextPlayer, int anAvailableMoveCount);
}
}
|
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.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here