Add package-lock.json and simplify ChessEngine move selection
Added package-lock.json to track exact versions of dependencies. Simplified the logic in ChessEngine to always use the best move, removing randomness based on difficulty.
This commit is contained in:
@@ -10,7 +10,7 @@ public class ChessEngine
|
||||
|
||||
public ChessEngine()
|
||||
{
|
||||
var channel = Channel.CreateUnbounded<string>(new UnboundedChannelOptions
|
||||
var channel = Channel.CreateUnbounded<object>(new UnboundedChannelOptions
|
||||
{
|
||||
SingleReader = true,
|
||||
SingleWriter = true
|
||||
@@ -42,24 +42,6 @@ public class ChessEngine
|
||||
var depth = difficulty - 1;
|
||||
var result = _engine.IDDFS(depth, 10);
|
||||
_engine.Game.ResetCurrentPositionToBeforeSearchState();
|
||||
|
||||
if (ShouldUseBestMove(difficulty))
|
||||
{
|
||||
// If difficulty is higher than 5, we should use the best move
|
||||
return result.BestMove.ToEPDString(positionClone);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Randomly choose one of the moves
|
||||
return result.Moves[new Random().Next(result.Moves.Count)].ToEPDString(positionClone);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ShouldUseBestMove(int difficulty)
|
||||
{
|
||||
// For difficulties 1-6, gradually increase the probability of returning true
|
||||
var probability = (difficulty - 1) / 5.0; // 0.0 for 1, 0.2 for 2, ..., 1.0 for 6
|
||||
var random = new Random();
|
||||
return random.NextDouble() < probability;
|
||||
return result.BestMove.ToEPDString(positionClone);
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
{
|
||||
"name": "wwwroot",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "wwwroot",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@aiursoft/autodark.js": "^1.2.0",
|
||||
"@chrisoakman/chessboardjs": "^1.0.0",
|
||||
"@fortawesome/fontawesome-free": "^6.5.1",
|
||||
"chess.js": "^1.0.0-beta.6",
|
||||
"clipboard": "^2.0.11",
|
||||
"jquery-validation": "^1.19.5",
|
||||
"jquery-validation-unobtrusive": "^3.2.12"
|
||||
}
|
||||
},
|
||||
"node_modules/@aiursoft/autodark.js": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://npm.aiursoft.cn/@aiursoft/autodark.js/-/autodark.js-1.2.0.tgz",
|
||||
"integrity": "sha512-3EZh7AaT2ns2DGq24HMcNxAjSVSST49t/tZhR2MV0pxrwYgb+1SCk6zj9qv4TJB1bAixM0K/5nsH0YazZzfvng==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bootstrap": "^4.6.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@chrisoakman/chessboardjs": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://npm.aiursoft.cn/@chrisoakman/chessboardjs/-/chessboardjs-1.0.0.tgz",
|
||||
"integrity": "sha512-JHXHoQwwc86xW3F0YIdFcEWLnPldee5mHkqwJbOTeDh5gvNmYXyBj6AkeecDkj2WtORF959yaWYlpyZHUl3LCQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"jquery": ">=3.4.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@fortawesome/fontawesome-free": {
|
||||
"version": "6.6.0",
|
||||
"resolved": "https://npm.aiursoft.cn/@fortawesome/fontawesome-free/-/fontawesome-free-6.6.0.tgz",
|
||||
"integrity": "sha512-60G28ke/sXdtS9KZCpZSHHkCbdsOGEhIUGlwq6yhY74UpTiToIh8np7A8yphhM4BWsvNFtIvLpi4co+h9Mr9Ow==",
|
||||
"license": "(CC-BY-4.0 AND OFL-1.1 AND MIT)",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/bootstrap": {
|
||||
"version": "4.6.2",
|
||||
"resolved": "https://npm.aiursoft.cn/bootstrap/-/bootstrap-4.6.2.tgz",
|
||||
"integrity": "sha512-51Bbp/Uxr9aTuy6ca/8FbFloBUJZLHwnhTcnjIeRn2suQWsWzcuJhGjKDB5eppVte/8oCdOL3VuwxvZDUggwGQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/twbs"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/bootstrap"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"jquery": "1.9.1 - 3",
|
||||
"popper.js": "^1.16.1"
|
||||
}
|
||||
},
|
||||
"node_modules/chess.js": {
|
||||
"version": "1.0.0-beta.8",
|
||||
"resolved": "https://npm.aiursoft.cn/chess.js/-/chess.js-1.0.0-beta.8.tgz",
|
||||
"integrity": "sha512-UngzUMXmexcQaQA/UEJuJj5vatEy34awYMD5YMOp/FW3HM7lqspp7ymYs5JAmquDq0WROtURRfSffoa/vrCCyw==",
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/clipboard": {
|
||||
"version": "2.0.11",
|
||||
"resolved": "https://npm.aiursoft.cn/clipboard/-/clipboard-2.0.11.tgz",
|
||||
"integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"good-listener": "^1.2.2",
|
||||
"select": "^1.1.2",
|
||||
"tiny-emitter": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/delegate": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://npm.aiursoft.cn/delegate/-/delegate-3.2.0.tgz",
|
||||
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/good-listener": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://npm.aiursoft.cn/good-listener/-/good-listener-1.2.2.tgz",
|
||||
"integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"delegate": "^3.1.2"
|
||||
}
|
||||
},
|
||||
"node_modules/jquery": {
|
||||
"version": "3.7.1",
|
||||
"resolved": "https://npm.aiursoft.cn/jquery/-/jquery-3.7.1.tgz",
|
||||
"integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/jquery-validation": {
|
||||
"version": "1.21.0",
|
||||
"resolved": "https://npm.aiursoft.cn/jquery-validation/-/jquery-validation-1.21.0.tgz",
|
||||
"integrity": "sha512-xNot0rlUIgu7duMcQ5qb6MGkGL/Z1PQaRJQoZAURW9+a/2PGOUxY36o/WyNeP2T9R6jvWB8Z9lUVvvQWI/Zs5w==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"jquery": "^1.7 || ^2.0 || ^3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/jquery-validation-unobtrusive": {
|
||||
"version": "3.2.12",
|
||||
"resolved": "https://npm.aiursoft.cn/jquery-validation-unobtrusive/-/jquery-validation-unobtrusive-3.2.12.tgz",
|
||||
"integrity": "sha512-kPixGhVcuat7vZXngGFfSIksy4VlzZcHyRgnBIZdsfVneCU+D5sITC8T8dD/9c9K/Q+qkMlgp7ufJHz93nKSuQ==",
|
||||
"license": "https://aka.ms/jqueryunobtrusivelicense",
|
||||
"dependencies": {
|
||||
"jquery": "^3.5.1",
|
||||
"jquery-validation": ">=1.16"
|
||||
}
|
||||
},
|
||||
"node_modules/popper.js": {
|
||||
"version": "1.16.1",
|
||||
"resolved": "https://npm.aiursoft.cn/popper.js/-/popper.js-1.16.1.tgz",
|
||||
"integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==",
|
||||
"deprecated": "You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/popperjs"
|
||||
}
|
||||
},
|
||||
"node_modules/select": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://npm.aiursoft.cn/select/-/select-1.1.2.tgz",
|
||||
"integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tiny-emitter": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://npm.aiursoft.cn/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
|
||||
"integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user