Chess with "Greedy Edi"

Play chess against "Greedy Edi".
Updated 24 Jan 2012

View License

Play chess against "Greedy Edi".

Get started...
1. extract zip file
2. change current directory to the new "chess" directory
3. Run "Chess" (optionally for text figures run Chess(2))

Some help ...
a) How to move the chess pieces ...
1. Position the mouse over the figure you like to move
2. Press the mouse button and keep it pressed
3. Move the mouse over the desired field and relase the mouse button
b) How to play chess ...
If you don't know anything about chess. I have included a little chess
tutorial (ChessTutorial.pdf).

c) Help about the functions
If you like to change the program or if you like to know more about the
implementation, then check out the html folder for help descriptions on
the functions. The "index.html" file gives an overview of all the functions
used. This help files were generated by using the "wg_publish_dir"
function, which can be found at the Central File Exchange Depot.

What I still intend to do...
- let "Greedy Edi" realize, when he is checked, that he can do
something else beside running away.
Additional Edi characters
a) Careful Edi ... which looks out, whether he will be eaten
b) Happy Edi ... looking tow and a half move ahead
c) Smart Edi ... knowing strategy, tricks and learning on its own

How could you help me...
1. By testing this program and telling me any wrong moves (
x2. There is a transparency issue, which I could not figure out ...
A transparent image with a patch as background colour???
I have include a m-script (TransparencyProblem.m), illustrating the problem.
-> Thank's to Jérôme. This problem is solved.
Add 2nd axes and send them to the back :)
3. Finding other chess sets
4. Other constructive comments and contributions ;)

I am proud of the following...
1. a kind of Matlab object orientated alternative concept ...
The chess figures m-functions represent objects. Of course I know that
Matlab offers OO programming. But, I do not like copying everything. Hence
I came out with the "persistent" structure idea.
For instance, let us have a look at the knights.
First we have only the "empty" function, which I call class.
When calling the function "Knight('init',...)", an instance is derived from
the class (actually: into the class). Assume you like to have a second
knight, just call the "method" again. The function "findPos" is sufficient
to identify the required instance (which is done internally).

2. the usage of function pointers
The usage of function pointers (@Knight, @Queen,...) saved me a lot of work.

3. the cursor events
I have never really used this Mouse events before, but it worked out pretty

Cite As

Wolfgang Garn (2024). Chess with "Greedy Edi" (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Board games in Help Center and MATLAB Answers

Inspired: ChessPeace

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

You can move chess pieces using the command line: stopCursor(c2m('d2-d4'))
Edi's move can be queried with: [from, to]=lastHalfMove

You can display your game in chess notation with: displayAllMoves (font installation explained in function)

Improved functionality for legal move; added undo move; new change player colour; other minor improvements