[Michael Jacobson] ~ 2003/04/03 After reading a Microsoft case study on [.NET] on the [PocketPc] with a chess game (that could also be run on the PC with no code changes)[http://www.microsoft.com/resources/casestudies/CaseStudy.asp?CaseStudyID=13778]. I remembered [Chess in Tcl] on the Wiki and figured out how to resize and color it, in '''9 lines of Tcl code''', so it looked better on the [PocketPC]. Then I saw in the article, that the author uses a web service to implete online play against a computer. So I found the service on http://www.xmethods.net [http://www.xmethods.net/ve2/ViewListing.po?key=uuid:D48B0254-670B-E876-FDBC-2D3DBB330E5D] and wrote my first TclSOAP interface code ever (took a hour ~ most of the time to read the docs - only '''4 line of Tcl code'''). Then with another couple of lines of code I added online play to [Chess in Tcl]. ''I do so like this language Sam I Am!!!'' There are a couple of problems because Chess in Tcl does not support all the valid moves but this is my first crack at the code. Please feel free to make changes... ### Mike's Add for Smart Network Opponent to Chess in Tcl proc InitChessServer {} { package require SOAP set uri "urn:BorlandChess-IBorlandChess#XML_GetNextMove" set proxy "http://www.danmarinescu.com/WebServices/ChessCGIServer.exe/soap/IBorlandChess" #SOAP::configure \ # -transport http -proxy host:port \ # -headers { "Proxy-Authorization" "Basic XXYYZZ" } SOAP::create XML_GetNextMove \ -uri $uri -proxy $proxy \ -params {"Position" "string" "WhiteMovesNext" "boolean" "SearchDepth" "integer"} # example from the danmainescu site #set a "rnbqkbnrpppppppp[string repeat { } 32]PPPPPPPPRNBQKBNR" #XML_GetNextMove $a true 3 ;# returns "e2e4 OK" } proc GetNextMove {} { global game set board {} foreach row {8 7 6 5 4 3 2 1} { foreach col {A B C D E F G H} { if {$game($col$row) == "."} { append board " " } else { append board $game($col$row) } } } set result [string toupper [XML_GetNextMove $board false 3]] return "[string range [lindex $result 0] 0 1]-[string range [lindex $result 0] 2 3]" } InitChessServer after 1000 CheckBoard set game(autoMove) 1 proc CheckBoard {} { global game if {$game(toMove) == "black" && $game(autoMove)} { set ::game(results) [GetNextMove] if {$::game(results) != "A1-A1"} { puts [uplevel {chess::move game $::game(results)}] game drawBoard .c } else { #some prompt that game is over so you want to play somemore } set game(autoMove) 0 } return [after 1000 CheckBoard] } proc MoveInfo {- - -} { set ::info "$::game(toMove) to move - [chess::values ::game]" set ::game(autoMove) 1 }