getcolor.m

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

M
30
字号
function color = getColor(from)
% findPos  Determines the color of a certain field
% The color (black or white) of the figure from a certain field is
% determined.
%
% Inputs:
% * from ... field in matrix notation, from which to obtain the color
% * board ... chess board and related information
%
% Outputs:
% * color ... figure color of a certain chess field (0..black,1...white)
%
% Example
% Assume there is a white knight on f3 [6 6], then |getColor([6 6])| 
% returns one for the white color.
%
% See also: Chess, stopCursor
%
%% Signature
% Author: W.Garn
% E-Mail: wgarn@yahoo.com
% Date: 2006/03/23 12:00:00 
% 
% Copyright 2006 W.Garn
%

global board;
f = board.figures(from(1),from(2));
if double(f)<double('a'), color=1; else color=0; end

⌨️ 快捷键说明

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