Apple's Chess 2.0 Source Code Available
Petrochard writes "For all of you programmers who are big chess fans, check out Apple's release of Chess 2.0's source code. It would be cool if somebody could make a Simpson's Chess mod." Chess is based on sjeng (logic) and glChess (interface).
This is the source code for Apple's Chess.app Version 2.0, as shipped
in MacOS X 10.3 "Panther". This project consists of two components:
The Chess engine, "sjeng", and the graphical frontend.
"sjeng", contained in the "sjeng" subdirectory, is distributed under the
terms of the GNU General Public License. See sjeng/COPYING for
details.
The graphical frontend, i.e., all files not in the "sjeng"
subdirectory (including files derived from glChess which Apple has
permission to relicense under the following terms), are distributed
under the terms of the Apple Sample Code License:
IMPORTANT: This Apple software is supplied to you by Apple Computer,
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
redistribute this Apple software.
In consideration of your agreement to abide by the following terms,
and subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
"Apple Software"), to use, reproduce, modify and redistribute the
Apple Software, with or without modifications, in source and/or binary
forms; provided that if you redistribute the Apple Software in its
entirety and without modifications, you must retain this notice and
the following text and disclaimers in all such redistributions of the
Apple Software. Neither the name, trademarks, service marks or logos
of Apple Computer, Inc. may be used to endorse or promote products
derived from the Apple Software without specific prior written
permission from Apple. Except as expressly stated in this notice, no
other rights or licenses, express or implied, are granted by Apple
herein, including but not limited to any patent rights that may be
infringed by your derivative works or by other works in which the
Apple Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS
USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT,
INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE,
HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Electronic Music Made Using Linux http://soundcloud.com/polyp
2.0 is the newer version that was released with panther
Creationists are a lot like zombies. Slow, but powerful and numerous. And they all want to eat our brains.
After taking a look at the source I found out that the floating window can be activated without making any modifications to the application. Here's how to enable the transparent window:
/Applications/Chess.app/
Open Terminal.app and set MBC_DEBUG as an environment variable to 16:
With bash:
set MBC_DEBUG=16
with tcsh:
setenv MBC_DEBUG 16
Now, open Chess.app from the Terminal:
open
There will be a new menu item (Floating Board) under the "Game" menu. Selecting this menu item will toggle the floating board on and off.
There seems to be a bug with the mouse behavior (I can't move any pieces) and I assume this is why this feature was removed. I found that you can get around this bug by doing the following:
Start a game with the normal window.
Play at least one move.
Switch to the floating board.
Select "Take Back Move" from the "Moves" window.
You should now be able to move the pieces as normal.
infested with jello like fishes no melotron wishes
Well, I downloaded the source and examined it and I can tell you how to turn the transparent window back on.
;)
.profile, but I'm not certain how those parameters affect Gui apps. Quick run to the terminal and running Chess.app from there had no effect, but then, perhaps I'd have to log out and back in.
Comment out lines 741 through 744 of MBCController.mm -- funny, you've gotta love Objective-C++ -- half my work's in it too. You listening apple? Hire me
Specifically:
[[fFloatingMenuItem menu] removeItem:fFloatingMenuItem];
[[fFloatingView window] release];
fFloatingMenuItem = nil;
fFloatingView = nil;
I found these pretty quickly -- particularly since the menu item *is* in the nib file, that meant I could just run a search for [someMenu removeItem: ] and whammo, there it was. You can thank me later.
Above those lines is a call to getenv() looking up the string "MBC_DEBUG" so I gather you could simply set the parameter in your
Anyway, the above instructions will return the command-F floating window effect.
Try to use it... then you'll understand why apple took it out. It's sad, because from a performance standpoint it's *fine*, the trouble is there's no way to drag or resize the window!
lorem ipsum, dolor sit amet
Ah, thanks for finding the key! No coding needed for this one - just dig into the Chess.app package, find the Info.plist ( only one level down ) and edit it. Apple has generaly pretty good documentation. The environment variable stuff is documented ( for the most part ) here : http://developer.apple.com/documentation/MacOSX/Co nceptual/BPRuntimeConfig/Concepts/EnvironmentVars. html
The bit at the bottom of the page on setting application-specific environment variables says something about "The second way to associate environment variables with an application is to include the LSEnvironment key in the application's information property list." and includes a link to http://developer.apple.com/documentation/MacOSX/Co nceptual/BPRuntimeConfig/Concepts/PListKeys.html#/ /apple_ref/doc/uid/20001431/BCIJIJBH for more information.
Anyway, by setting LSEnvironment in the Info.plist to include "MBC_DEBUG=(whatever)", you should be able to set up any of the associated behaviors. It looks like you want (MBC_DEBUG &16) to eval to false... so LSEnvironment "MBC_DEBUG=16" should do the trick.
eh. Forget I said anything, it's probably easier to just comment out those lines and recompile...
Some versions of Chess 2.0 distributed with early builds of Panther did this. It had bugs (didn't calculate bounding box correctly, chopped off parts of the board if rotated the wrong way, etc.) and I guess they decided to take it out rather than fix it. (At least they got board rotation fixed .. that was unusable in early versions too.)
-- Tim Buchheim
It probably doesn't hurt that Sjeng takes advantage of multiple processors and GnuChess does not.
Ian