Show / Hide Table of Contents

Class Engine

Blazor component wrapping an UCI compliant WebAssembly Chess Engine

The component uses the WebAssembly port of Nathan Rugg of ((https://github.com/nmrugg/stockfish.js) Stockfish 14.1

NOTE: Stockfish.js 14.1 reqiures some of the latest features and does not work in every browser.
As it uses the latest WebAssembly threading proposal it requires these HTTP headers on the top level response:

Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
And the following header on the included files:
 
Cross-Origin-Embedder-Policy: require-corp

The UI of the engine component consists of 3 parts:

  • Info Panel showing the engine's evaluation info (score, depth and principal variation)
  • Evaluation Bar showing the current evaluation graphically
  • Log Panel showing the uci communication
Those 3 UI parts can be activated by the parameters ShowEvaluationInfo, ShowEvaluationbar and ShowLog. It's possible to set all 3 of those parameters to false. In that case the engine can be run completely faceless.
To have more flexibiliyt regarding the UI setup, the evaluation bar and the log panel are offered as independent components: EvaluationGauge and EngineLog

There is only one Engine Process available per window. So by using 2 Engine components, you will not get 2 engine workers, but only one. All UCI commands you to one of your engine commands will reach the same engine.

Inheritance
System.Object
Engine
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: PonzianiComponents
Assembly: PonzianiComponents.dll
Syntax
public class Engine

Properties

| Improve this Doc View Source

Name

Engine name (only available after engine has been initialized)

Declaration
public string Name { get; }
Property Value
Type Description
System.String
| Improve this Doc View Source

NumberOfLines

Number of lines to be analyzed

Declaration
[Parameter]
public int NumberOfLines { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

OnEngineInfo

Engine reports new, updated analysis info

Declaration
[Parameter]
public EventCallback<UCIEngine.Info> OnEngineInfo { get; set; }
Property Value
Type Description
Microsoft.AspNetCore.Components.EventCallback<UCIEngine.Info>
| Improve this Doc View Source

OtherAttributes

Other HTML Attributes, which are applied to the root element of the rendered scoresheet.

Declaration
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary<string, object> OtherAttributes { get; set; }
Property Value
Type Description
System.Collections.Generic.Dictionary<System.String, System.Object>
| Improve this Doc View Source

Score

Score from white's point of view in centipawns. Mate scores are converted to very high scores

Declaration
public int Score { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

ShowEvaluationbar

Shows engine evaluation Bar

Declaration
[Parameter]
public bool ShowEvaluationbar { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

ShowEvaluationInfo

Shows evaluation output (score, depth and principal variation)

Declaration
[Parameter]
public bool ShowEvaluationInfo { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

ShowLog

Shows engine evaluation Bar

Declaration
[Parameter]
public bool ShowLog { get; set; }
Property Value
Type Description
System.Boolean

Methods

| Improve this Doc View Source

EngineMessageAsync(String)

Declaration
[JSInvokable]
public async Task EngineMessageAsync(string msg)
Parameters
Type Name Description
System.String msg
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

GetScore(Int32)

Score from white's point of view

Declaration
public int GetScore(int index)
Parameters
Type Name Description
System.Int32 index

zero-based index of line

Returns
Type Description
System.Int32

score in centipawns, mate scores are converted to very high scores

| Improve this Doc View Source

OnAfterRenderAsync(Boolean)

Declaration
protected override async Task OnAfterRenderAsync(bool firstRender)
Parameters
Type Name Description
System.Boolean firstRender
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

ScoreText(Int32)

Textual representation of Score (with representations for mate scores and upper-/lowerbound scores)

Declaration
public string ScoreText(int index)
Parameters
Type Name Description
System.Int32 index

zero-based index of line

Returns
Type Description
System.String

Score as text

| Improve this Doc View Source

SendAsync(String)

Send UCI message to the engine process

Attention: Sending an incorrect or invalid UCI message might break the engine process, there is no input validation!

Declaration
public async Task SendAsync(string command)
Parameters
Type Name Description
System.String command

UCI message

Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

StartAnalysisAsync(String)

Start analysing a position

Declaration
public async Task<bool> StartAnalysisAsync(string fen)
Parameters
Type Name Description
System.String fen

Position to be analyzed in FEN representation

Returns
Type Description
System.Threading.Tasks.Task<System.Boolean>
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX