5. 以前の4人打ちオセロでの「工夫」
最初に4人分戦わせて、一番強いひとが私の代わりに打てばよいのに。
自 AI のコンストラクターで、事前に5回対戦して強いひと (AI) を選んどく。
class PlayerTable
: IEnumerable<KeyValuePair<Board.Piece, IPlayer>> {
Dictionary<Board.Piece, IPlayer> playerDictionary
= new Dictionary<Board.Piece, IPlayer>();
……
}
class GameRunner {
……
}
6. PlayerChecker: 一番強いひとをチェック
class PlayerChecker
{
readonly Board.Piece theStrongestPiece;
readonly PlayerTable playerTable = new PlayerTable(
players: new IPlayer[] {
new PlayerRyotaMurohoshi(),
new PlayerAILight (),
new PlayerXin9le (),
new PlayerFujiwo ()
}
);
public static Board.Piece TheStrongestPiece => theStrongestPiece;
……
}
18. リフレクション対策は必須!
public class AIOriginal : IPlayer
{
protected bool CallingByEnemy { private get; set; } = false;
public AIOriginal() => CallingByEnemy
= !Assembly.GetCallingAssembly().GetName().Name.Equals(
Assembly.GetEntryAssembly().GetName().Name);
public Task<Point> GetPointAsync(Board board)
=> Task<Point>.Run(() => CallingByEnemy ? GetRandomPoint(board) : GetAPoint(board));
}
17
19. リフレクション対策は必須!
public class AI : AIOriginal
{
public AI() => CallingByEnemy
= !Assembly.GetCallingAssembly().GetName().Name.Equals(
Assembly.GetEntryAssembly().GetName().Name);
protected overload Point GetAPoint(board) => …
} 18