Chess/AIPlayer.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using FourWayClimbingDemo.Chess.Advice;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FourWayClimbingDemo.Chess
{
/// <summary>
/// AI选手
/// </summary>
public class AIPlayer:Player
{
public AIPlayer(string name) {
this._name = name;
_isAutoWantPlay = true;
}
public override (ChessPiece cp, Dir dir)? IWantPlay(ChessBoard chessBoard)
{
int socre = 0;
ChessPiece cp = null;
Dir dir = Dir.LEFT;
foreach (var item in _chessPieces) {
if (item.IsDead) continue;
var ca = new CurrentAdvice(chessBoard, this, item);
var ma = new MoveAdvice(chessBoard, this, item, Dir.LEFT);
var ra = new ResultAdvice(chessBoard, this, item, Dir.LEFT);
ca.SetNextAdvice(ma);
ma.SetNextAdvice(ra);
var s = ca.Execute();
if (s > socre) {
socre = s;
cp = item;
dir = Dir.LEFT;
}
ca = new CurrentAdvice(chessBoard, this, item);
ma = new MoveAdvice(chessBoard, this, item, Dir.RIGHT);
ra = new ResultAdvice(chessBoard, this, item, Dir.RIGHT);
ca.SetNextAdvice(ma);
ma.SetNextAdvice(ra);
s = ca.Execute();
if (s > socre){
socre = s;
cp = item;
dir = Dir.RIGHT;
}
ca = new CurrentAdvice(chessBoard, this, item);
ma = new MoveAdvice(chessBoard, this, item, Dir.TOP);
ra = new ResultAdvice(chessBoard, this, item, Dir.TOP);
ca.SetNextAdvice(ma);
ma.SetNextAdvice(ra);
s = ca.Execute();
if (s > socre){
socre = s;
cp = item;
后面还有 23 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。