Jump to content


>>> PROLOG <<<


  • You cannot reply to this topic
1 reply to this topic

#1 rego

    Member

  • Members
  • PipPip
  • 46 posts

Posted 11 January 2005 - 08:37 PM

hey,

i'm having trouble causing a program to stop running or halt when an event is triggered for example winning a game. i tried using the fail. predicate but that just causes backtracking and makes the program really messy!
does anyone have any other solutions?

many thanks

#2 Trident

    New Member

  • Members
  • PipPip
  • 25 posts

Posted 12 January 2005 - 05:33 PM

rego said:

hey,

i'm having trouble causing a program to stop running or halt when an event is triggered for example winning a game. i tried using the fail. predicate but that just causes backtracking and makes the program really messy!
does anyone have any other solutions?

many thanks

View Post


Depends on the version. But generally you launch your program with a question with one variable and when it ends just instantiate that variable and cut.

stop_game:-X is ok,!.
start_game(X):-%your game here.
?- start_game(X);

Or, if you do not want to lug that X around and do not care about start_game evaluating to false you may just !,fail when needed, IIRC (note that, fail,!. is obviously pointless.) As I already said I nearly forgot the whole thing...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users