This crate implements currently just a parser and serializer for the Go Text Protocol as needed for writing a GTP controller to control a GTP engine.
See also:
Sending commands:
use gtp;
let mut c = gtp::Command::new("list_commands");
assert_eq!(c.to_string(), "list_commands\n");
Sending commands with entities:
use gtp::Command;
assert_eq!(Command::new("clear_board").to_string(), "clear_board\n");
assert_eq!(Command::new_with_args("boardsize", |eb| eb.i(19)).to_string(),
"boardsize 19\n");
Receiving Responses:
``` let mut rp = gtp::ResponseParser::new(); rp.feed("= o"); rp.feed("k\n\n"); rp.feed("=\nA\nB\n\n= white b3\n\n");
asserteq!(rp.getresponse().unwrap().unwrap().text(), "ok"); asserteq!(rp.getresponse().unwrap().unwrap().text(), "\nA\nB\n");
// And processing entities in the response:
let mut ep = gtp::EntityParser::new(&rp.getresponse().unwrap().unwrap().text()); let res = ep.mv().result().unwrap(); asserteq!(res[0].to_string(), "w B3");
match res[0] { gtp::Entity::Move((color, (h, v))) => { asserteq!(color, gtp::Color::W); asserteq!(h, 2); assert_eq!(v, 3); }, _ => {}, } ```
Currently I work on a GTP controller via tokio_process, as the dependency on tokio is quite heavy I would not like to burden this little crate with that. But what I could see is a GTP controller based on std::process which uses threads for communicating with the GTP engine in the background.
This project is licensed under the GNU General Public License Version 3 or later.
Picking a license for my code bothered me for a long time. I read many discussions about this topic. Read the license explanations. And discussed this matter with other developers.
First about why I write code for free at all:
Those are the reasons why I write code for free. Now the reasons why I publish the code, when I could as well keep it to myself:
Most of those reasons don't yet justify GPL. The main point of the GPL, as far as I understand: The GPL makes sure the software stays free software until eternity. That the user of the software always stays in control. That the users have at least the means to adapt the software to new platforms or use cases. Even if the original authors don't maintain the software anymore. It ultimately prevents "vendor lock in". I really dislike vendor lock in, especially as developer. Especially as developer I want and need to stay in control of the computers I use.
Another point is, that my work has a value. If I give away my work without any strings attached, I effectively work for free. Work for free for companies. I would compromise the price I can demand for my skill, workforce and time.
This makes two reasons for me to choose the GPL:
Please contact me if you need a different license and really want to use my code. As long as I am the only author, I can change the license. We might find an agreement.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in WLambda by you, shall be licensed as GPLv3 or later, without any additional terms or conditions.
WeirdConstructor
on the Rust Discord.)