quote:
Originally posted by Bill819
The problem is how to pass parameters back and forth to Hal.
If I had a VB engine, here's how I'd do it:
If Hal detects a chess move, he calls the engine, passing that move, and parrots the response back to the User. The engine's main routine is encapsulated by a function called "ChessEngine", which accepts the User's move as its argument, and returns the engine's move.
This code is grossly simplified:
UserChessMove = HalBrain.SearchPattern(OriginalSentence, "*MY MOVE IS *", 2)
If UserChessMove <> "" Then
HalChessMove = ChessEngine(UserChessMove)
If HalChessMove = "invalid" Then
GetResponse = "That move's illegal!"
Else
GetResponse = "My move is " & HalChessMove & "."
End If
End If
This assumes
no graphical interface. My personal priority would be just getting Hal to play, without worrying yet about pretty chess boards [

] So only the chess engine goes into ChessEngine(). (Having a chess board would probably be best
not directly linked to the chess engine - Hal would check the board for user moves, and pass them onto the engine as needed. Otherwise you really may as well just be running a chess game beside Hal. Just IMHO [

])
If someone can find an VB engine where the main routine can be adjusted to run like this, I'm happy to do the interface code (i.e. between the User and Hal, and between Hal and the engine).
By the way, a smaller/simpler engine's probably best for Hal if possible, because the script isn't compiled, so it will run slower than a normal chess engine (unless there's a way to compile the engine code and link into it from Hal). The code eaxmple above will freeze Hal until the engine makes its move. We don't need a pro engine (given that state of the art engines will beat 99.999% of the people on the planet). Plus, Hal appears slightly dim in other areas, so being non-expert at chess isn't too unrealistic [

]
Afterthought: The engine has to either maintain its own board memory, or receive/return the board. One solution is to have the board encoded into a string, which gets passed to the engine along with the User's move. The engine would then return its move with an updated board string.
(Example: The beginning setup of the board could be encoded like this (black pieces in capitals, dot for an empty square, from top-left to bottom-right):
"RNBQKBNRPPPPPPPP................................pppppppprnbqkbnr" After User moves 1.e4, and the engine moves 1...e5, the engine would return this encoded board:
"RNBQKBNRPPPP.PPP............P.......p...........pppp.ppprnbqkbnr")
Second afterthought: You'd also have to encode whether each side can castle, and if any en passant captures are possible. This encoding means "black can castle queenside and kingside, white can castle kingside only, and black's d-pawn can be captured en passant": "QK.Kd"
Third afterthought:
AND a flag to tell the engine whether it's black to move or white.
I think that's all the info a chess engine would need to find a move!! [:p]