Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create user interface for prolog program [closed]

Tags:

prolog

I am creating a game based on prolog logic base and i would like to create a user interface for it. Any ideas what programming language integrates with prolog?

like image 676
user3034845 Avatar asked Jan 14 '14 12:01

user3034845


2 Answers

It might seem a little counter-intuitive at first, but I actually recommend making a web-based GUI. Once you think it through (and check out the http functionality of eclipse clp, http://eclipseclp.org/doc/bips/lib/http/index.html) you'll realize that Prolog is actually rather well suited as language to write an application server in. I've done that to great success and it avoid the uphill battle of convincing someone to look at a non-standard UI framework. Plus it enables mobile right away and separates concerns really well.

Here is a minimalist example. When you run it (eclipse -s http.pl, then invoke runserver), you can open your browser at localhost:8000 to invoke the route predicates defined in processURL below:

http.pl:

:- lib(http),
    use_module(http_method).

runserver :-
    http_server(8000).

http_method.pl:

:- module(http_method).

http_method("GET", Url, Params, Contents, 200, [contentLength(CL), contentType(mt(text, html))]):-
    printf("%w\n", [http_method(Url, Params)]), flush(output),
    http_process(Url, Contents),
    string_length(Contents, CL).

http_process(Url, Contents) :-
    split_string(Url, "/", "/", L),
    printf("URL split: %w\n", [L]), flush(output),
    processURL(L, Contents).

processURL([""], "Hello World!").
processURL(["route1"], "You are at /route1").
like image 116
Christian Fritz Avatar answered Sep 21 '22 11:09

Christian Fritz


If you use SWI-Prolog, and know Qt, you could use QtCreator designer. An example is online here.

like image 41
CapelliC Avatar answered Sep 21 '22 11:09

CapelliC