I'm programming a chess game and I've got a cell of strings which the GUI uses to draw the boards, but want to convert this into an array for the calculations.
tmp = {... 'rook:2','knight:2','bishop:2','queen:2','king:2','bishop:2','knight:2','rook:2';... 'pawn:2','pawn:2','pawn:2','pawn:2','pawn:2','pawn:2','pawn:2','pawn:2';... 'none:0','none:0','none:0','none:0','none:0','none:0','none:0','none:0';... 'none:0','none:0','none:0','none:0','none:0','none:0','none:0','none:0';... 'none:0','none:0','none:0','none:0','none:0','none:0','none:0','none:0';... 'none:0','none:0','none:0','none:0','none:0','none:0','none:0','none:0';... 'pawn:1','pawn:1','pawn:1','pawn:1','pawn:1','pawn:1','pawn:1','pawn:1';... 'rook:1','knight:1','bishop:1','queen:1','king:1','bishop:1','knight:1','rook:1' };
What I want is a matrix that looks like:
[5 3 3 9 200 3 3 5... 1 1 1 1 1 1 1 1...etc.]
Where the numbers correspond to the relative value of the pieces. And I also need to be able to change these back again to a cell of strings.
Additionally, the reason for doing this is that at the moment I keep on getting "failed to retrieve exception message" if I look two steps ahead. The size of tmp is 7938mb and there are four additional versions of it which need to be constantly updated, so I wondered if this is what was causing the java heap storage to fail. I have already increased the storage in the .opts file to as much as I can, as well as downloading and using the jheapcl function and still no luck.
If you can help at all with either queries it would be much appreciated!
Thanks in advance,
Chris
Best Answer