Code covered by the BSD License  

Highlights from
Chess with "Greedy Edi"

image thumbnail

Chess with "Greedy Edi"

by

 

07 Nov 2009 (Updated )

Play chess against "Greedy Edi".

chess2matrix(str)
function [row,col] = chess2matrix(str)
% chess2matrix chess notation to matrix
% A position is given in chess notation and the matrix notation is determined
%
% Inputs:
% * str ... string in chess notation (e.g. 'd2')
%
% Outputs:
% * row,col ... matrix notation (e.g. 'd2' becomes row=7  and col=4)
%
% Example
% Transform a position from chess notation into matrix notation
%+ [row, col] = chess2matrix('d2') % i.e. row=7 and col=2
%
% Note: works only for chess boards with a size smaller than 10.
%
% See also: matrix2xy
%
%% Signature
% Author: W.Garn
% E-Mail: wgarn@yahoo.com
% Date: 2010/11/11 12:00:00 
% 
% Copyright 2010 W.Garn
%
colStr = lower(str(1)); 
rowStr = str(2);
col = double(colStr-'a')+1;
row = 9 - double(rowStr-'0');

Contact us