Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 99 | pmbaty | 1 | /* |
| 2 | Texel - A UCI chess engine. |
||
| 3 | Copyright (C) 2012 Peter Ă–sterlund, peterosterlund2@gmail.com |
||
| 4 | |||
| 5 | This program is free software: you can redistribute it and/or modify |
||
| 6 | it under the terms of the GNU General Public License as published by |
||
| 7 | the Free Software Foundation, either version 3 of the License, or |
||
| 8 | (at your option) any later version. |
||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, |
||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | GNU General Public License for more details. |
||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License |
||
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
| 17 | */ |
||
| 18 | |||
| 19 | /* |
||
| 20 | * uciprotocol.hpp |
||
| 21 | * |
||
| 22 | * Created on: Mar 4, 2012 |
||
| 23 | * Author: petero |
||
| 24 | */ |
||
| 25 | |||
| 26 | #ifndef UCIPROTOCOL_HPP_ |
||
| 27 | #define UCIPROTOCOL_HPP_ |
||
| 28 | |||
| 29 | #include "position.hpp" |
||
| 30 | #include "enginecontrol.hpp" |
||
| 31 | |||
| 32 | #include <vector> |
||
| 33 | #include <string> |
||
| 34 | #include <iosfwd> |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Handle the UCI protocol mode. |
||
| 38 | */ |
||
| 39 | class UCIProtocol { |
||
| 40 | private: |
||
| 41 | // Data set by the "position" command. |
||
| 42 | Position pos; |
||
| 43 | std::vector<Move> moves; |
||
| 44 | |||
| 45 | // Engine data |
||
| 46 | std::shared_ptr<EngineControl> engine; |
||
| 47 | |||
| 48 | // Set to true to break out of main loop |
||
| 49 | bool quit; |
||
| 50 | |||
| 51 | public: |
||
| 52 | static void main(bool autoStart); |
||
| 53 | |||
| 54 | UCIProtocol(); |
||
| 55 | |||
| 56 | void mainLoop(std::istream& is, std::ostream& os, bool autoStart); |
||
| 57 | |||
| 58 | private: |
||
| 59 | void handleCommand(const std::string& cmdLine, std::ostream& os); |
||
| 60 | |||
| 61 | void initEngine(std::ostream& os); |
||
| 62 | |||
| 63 | /** Convert a string to tokens by splitting at whitespace characters. */ |
||
| 64 | void tokenize(const std::string& cmdLine, std::vector<std::string>& tokens); |
||
| 65 | }; |
||
| 66 | |||
| 67 | |||
| 68 | #endif /* UCIPROTOCOL_HPP_ */ |