0

Im trying to code a board thats 7x7 and I need to set and check the limits of the board, so I made de following function:

lim(X, Y) :- 
    X =< 7,
    X >= 1,
    Y =< 7,
    Y >= 1.

But it keeps giving me the error "uncaught exception: error(instantiation_error,(=<)/2)".

Does anyone have any idea of how to fix this?

I tried to change to:

lim(X, Y) :- 
    X < 8,
    X > 0,
    Y < 8,
    Y > 0.

But it gives me the error "uncaught exception: error(instantiation_error,(<)/2)", and I dont know what to do.

I tried to search the error as well and what I saw said that this error ocurs because I do not use the variables X and Y, so I changed it to X -> La and Y -> Ca, this are the variables that I use but the same error appears, so this is the new limit function:

lim(La, Ca) :- 
    La =< 7,
    La >= 1,
    Ca =< 7,
    Ca >= 1.

For more context the first part of the code is as follows:

% state -> e(AgentLine, AgentColumn, MachineLine, MachineColumn)

inicial_state(e(1, 2, 2, 2)).
final_state(e(_, _, 7, 2)).

%restrictions
obsta(e(6, 1)).
obsta(e(6, 3)).
obsta(e(7, 4)).
obsta(e(4, 4)).
obsta(e(3, 4)).
obsta(e(2, 4)).
obsta(e(6, 7)).

lim(La, Ca) :- 
    La =< 7,
    La >= 1,
    Ca =< 7,
    Ca >= 1.

equals(A, A).

%state operator -> op(actual_state, operator, next_state, cost)
op(e(La, Ca, Lm, Cm), up, e(Ls, Cs, Lms, Cms), 1) :-
    Ls is La + 1.
3
  • 1
    Lim is not a function but a predicate that need to run on instantiated La and Ça. Commented Apr 21, 2024 at 22:25
  • 1
    Just use: between(1, 7, X), between(1, 7, Y). Commented Apr 21, 2024 at 22:26
  • The "between" worked, thank u! Commented Apr 24, 2024 at 16:33

1 Answer 1

0

Just use: between(1, 7, X), between(1, 7, Y). Credits to: brebs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.