Chess/ChessBoard.cs
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FourWayClimbingDemo.Chess
{
/// <summary>
/// 棋盘
/// </summary>
public class ChessBoard
{
private int[] _positions = new int[16]; //棋盘所有坐标位置
private List<ChessPiece> _player1ChessPieces = null; //选手1的棋子
private List<ChessPiece> _player2ChessPieces = null; //选手2的棋子
public ChessBoard() {
}
/// <summary>
/// 初始化棋盘
/// </summary>
public void Init(List<ChessPiece> player1ChessPieces, List<ChessPiece> player2ChessPieces)
{
this._player1ChessPieces = player1ChessPieces;
this._player2ChessPieces = player2ChessPieces;
}
/// <summary>
/// 将选手的棋子摆到棋盘中
/// </summary>
private void SetBoard()
{
for (int i=0;i<_positions.Length;i++) {
_positions[i] = 0;
}
_player1ChessPieces.ForEach(item=> {
if (!item.IsDead) {
var pos = item.GetPosition();
_positions[PositionsIndex(pos.row, pos.col)] = 1;
}
});
_player2ChessPieces.ForEach(item=> {
if (!item.IsDead)
{
var pos = item.GetPosition();
_positions[PositionsIndex(pos.row, pos.col)] = -1;
}
});
}
/// <summary>
/// 棋盘坐标和真是数据位置的转换
/// </summary>
private int PositionsIndex(int row,int col) {
return (row * 4) + col;
后面还有 130 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。