基本上我有我的问题MinMax
如预期的算法是不是真的工作。
我需要的是让我的阵列块复制到newPieces
使pieces
在不改变newPieces
是。
下面是一个摘录MinMax
算法:
private int MinMax(
int depth, Piece[] pieces, bool blacksTurn,
List<Move> Moves, Game game, int alpha, Move nextMove) {
Piece[] newPieces=new Piece[24];
Moves=Game.possibleMoves(pieces, blacksTurn, false);
if(depth==0||Moves.Count==0) {
return Evaluation(ref pieces);
}
int value;
if(blacksTurn==true) {
foreach(Move i in Moves) {
newPieces=DeepCopy.ObjectExtensions.Copy(pieces);
game.MovePiece(newPieces, blacksTurn, i.Moving, i.Destination, true);
game.DisplayBoard(pieces);
value=minMax(depth-1, newPieces, !blacksTurn, Moves, game, alpha, nextMove);
if(alpha>value) {
alpha=value;
nextMove=i;
}
// ...
这里是件类。
[StructLayout(LayoutKind.Sequential)]
public class Piece
{
public CellReference Location;
public bool isBlack { get; set; }
public bool isKing { get; set; }
private int Value { get; set; }
public bool taken { get; set; }
public Piece()
{
}
public Piece(int i, bool isBlack, bool isKing, int CellsEast, int CellsNorth, bool taken)
{
this.Value = i;
Location.CellsEast = CellsEast;
Location.CellsNorth = CellsNorth;
this.isBlack = isBlack;
this.isKing = isKing;
this.taken = taken;
}
}