value_of_figure.m

来自「国际象棋程序,解压到当前目录,在matlab窗口输入chess即可应用」· M 代码 · 共 40 行

M
40
字号
function value = Value_of_Figure(fig)
% Value_of_Figure  Returns the value of a chess figure in pawns unit.
% The value of a chess figure in pawn units is returned.
% 
% Inputs:
% * fig ... abbreviated name of the chess figure (i.e. 'B')
%
% Outputs:
% * value ... value of the chess figure in pawn units
%
% Example
% To find out the value of a bishop type:
%+ value = Value_of_Figure('B')
%
% See also: Chess, Bishop
%
%% Signature
% Author: W.Garn
% E-Mail: wgarn@yahoo.com
% Date: 2006/03/23 12:00:00 
% 
% Copyright 2006 W.Garn
%
f = lower(fig);
switch f
    case 'p'
        value = 1;
    case 'n'
        value = 3;
    case 'b'
        value = 3;
    case 'r'
        value = 5;
    case 'q'
        value = 9;
    case 'k'
        value = inf;        
    otherwise 
        value = 0; 
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?