#include #include #include #include <3rd-party/linenoise.h> #include int main(int argc, char **argv) { reset_state(5); enum E_RESULT r = try_place(0, C_BLACK, STONE_FLAT); r = try_place(1, C_BLACK, STONE_FLAT); uint8_t drops[5] = {1,0,0,0,0}; r = try_move(1, M_LEFT, 1, drops); uint8_t location; enum STONE_VARIANT stone; r = parse_place(5, "Cb3", &location, &stone); printf("Place <%d>: stone %d at (%d,%d)\n",r,stone,location%5,location/5); enum MOVE_DIRECTION direction; uint8_t steps; r = parse_move(5, "3c2+12", &location, &direction, &steps, drops); printf("Move <%d>: from (%d,%d) step %d sequence [%d,%d,%d,%d,%d]\n", r,location%5,location/5, steps,drops[0],drops[1],drops[2],drops[3],drops[4]); char buf[10]; generate_move(5, 2+5*1, M_UP, 1, drops, buf); printf("Generated move: %s\n",buf); generate_place(5,1+5*2, STONE_CAPSTONE, buf); printf("Generated place: %s\n",buf); char *line; while((line = linenoise("hello> ")) != NULL) { /* Do something with the string. */ if (line[0] != '\0' && line[0] != '/') { printf("echo: '%s'\n", line); linenoiseHistoryAdd(line); /* Add to the history. */ /* linenoiseHistorySave("history.txt"); /\* Save the history on disk. *\/ */ } else if (!strncmp(line,"/historylen",11)) { /* The "/historylen" command will change the history len. */ int len = atoi(line+11); linenoiseHistorySetMaxLen(len); } else if (!strncmp(line, "/mask", 5)) { linenoiseMaskModeEnable(); } else if (!strncmp(line, "/unmask", 7)) { linenoiseMaskModeDisable(); } else if (line[0] == '/') { printf("Unreconized command: %s\n", line); } free(line); } return 0; }