addhistorymove.m
来自「国际象棋程序,解压到当前目录,在matlab窗口输入chess即可应用」· M 代码 · 共 53 行
M
53 行
function addHistoryMove(from,to)
% addHistoryMove Adds a move to the history structure.
%
% Inputs:
% * from ... field in matrix notation (i.e [1 2]~b8)
% * to ... field in matrix notation (i.e [3 3]~c6)
% * global board ... chess board and related information
%
% Outputs:
% * global history ... a move is added to the game history
%
% Example
% Add the knigth move from b8 to c6:
% |addHistoryMove([1 2],[3 3])|
%
% 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
global history
color = getColor(to);
fig = upper(board.figures(to(1),to(2)));
if color %white
k = size(history.white,1) + 1;
history.white_pos{k,1} = from;
history.white_pos{k,2} = to;
history.white_fig{k} = fig;
if board.last2field == ' ' %empty
cs = ' - ';
else
cs = ' x ';
end
history.white{k,1} = [fig matrix2chess(from) cs matrix2chess(to)];
else %black
k = size(history.black,1) + 1;
history.black_pos{k,1} = from;
history.black_pos{k,2} = to;
history.black_fig{k} = fig;
if board.last2field == ' ' %empty
cs = ' - ';
else
cs = ' x ';
end
history.black{k,1} = [fig matrix2chess(from) cs matrix2chess(to)];
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?