📄 addhistorymove.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -