diff options
-rw-r--r-- | battle.c | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -4,24 +4,31 @@ #define __GPROLOG_FOREIGN_STRICT__ #include "gprolog.h" -char player(char *algorithm, char a, char b) +int player(char *algorithm, PlTerm *history, char *c, PlTerm *in, PlTerm *out) { - char move = -1; - PlTerm arg[3]; + PlTerm arg[4]; int func = Pl_Find_Atom(algorithm); + printf("player\n"); + Pl_Query_Begin(PL_TRUE); - arg[0] = Pl_Mk_List(); + arg[0] = *history; arg[1] = Pl_Mk_Variable(); + arg[2] = *in; + arg[3] = Pl_Mk_Variable(); if (Pl_Query_Call(func, 3, arg)) { - move = Pl_Rd_char(arg[1]); + printf("read char\n"); + move = Pl_Rd_Char_Check(arg[1]); + move = Pl_Rd_List_Check(arg[3]); } + + printf("end\n"); Pl_Query_End(PL_RECOVER); - return move; + return 0; } int pay(char a, char b) @@ -51,7 +58,11 @@ main(int argc, char *argv[]) Pl_Start_Prolog(argc, argv); printf("pay: %d\n", pay('d', 'c')); - printf("move: %c\n", player("tit4tat", 'd', 'c')); + + PlTerm history = Pl_Mk_List(NULL); + PlTerm in = Pl_Mk_List(NULL); + PlTerm out = Pl_Mk_List(NULL); + printf("move: %c\n", player("tit4tat", &history, &in, &out)); Pl_Stop_Prolog(); return 0; |