Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8718763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:37:36+00:00 2026-06-13T06:37:36+00:00

So, I am developing a game with Unity3D, and I’m using Prolog for IA

  • 0

So, I am developing a game with Unity3D, and I’m using Prolog for IA planning.
My problem is very similar to the monkey and banana problem, but I’m having problems on asserting a new initial state.

By changing the initial state, my character would be able to plan again his actions whenever something important on the environment changed.

But let’s get back to my problem:

I’m passing a string to prolog, via socket, and I want to build a list of facts. Then, I’d like to use these facts as the initial state for my planning procedure.

I’m able to write the socket’s input stream on the SWI terminal by transforming the byte array into a list of chars. I am also able to get a string back from the prolog server, by writing something on the output stream.
But I don’t know how I am supposed to turn those characters/string into a list of facts.

Also, I’d like to use that list of facts as an initial state, by passing it to the planning procedure like I would pass an argument to a function in an imperative programming language (if that were the case).

What I’d like to do is something like this (pseudocode):

% on the prolog server, we have a main function
% we get a bytestream (In), 
% turn it into a list of facts
% use it as the initial state
% and write Plan to the output stream (Out).

loopback(In, Out) :-    
    \+at_end_of_stream(In),     
    read_pending_input(In, Codes, []),              
    atom_codes(AtomList, Codes),       %bytes into a list of atoms
    toFacts(Init, AtomList),           %??? Init = AtomList to list of facts
    test(Init, Plan),                  %pass Init as the initial state
    format(Out, '~s', Plan),            %Get the plan back and write to the output
    flush_output(Out),
    loopback(In, Out).

% Init should look like this - a mere list of facts:
Init = [on(monkey, floor),
        on(box, floor),
        at(monkey, a),
        at(box, b),
        at(bananas, c),
        status(bananas, hanging)].

% The planning predicate - Init as an argument, Plan is the result
test(Init, Plan):- 
    write('Initial state:'),nl, 
    write_sol(Init),
    Goal = [status(bananas, grabbed)],
    nl,write('Goal state:'),nl,
    write(Goal),nl,
        solve(Init,Goal,Plan).

I am really stuck right now, I hope someone can help me. Thank you!

References:

Full monkey banana problem code.

SWI socket server code example.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:37:37+00:00Added an answer on June 13, 2026 at 6:37 am

    You have many choices: the simplest seems to be read_from_codes

    test :-  
      S = "[on(monkey, floor),
            on(box, floor),
            at(monkey, a),
            at(box, b),
            at(bananas, c),
            status(bananas, hanging)].",
      read_from_codes(S, T),
      writeln(T).
    

    results in

    ?- test.
    [on(monkey,floor),on(box,floor),at(monkey,a),at(box,b),at(bananas,c),status(bananas,hanging)]
    true.
    

    But the exchange of structured data could be easier using a devoted protocol like JSON. I used it just via AJAX/jQuery. Maybe overkill for your use case…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi i am developing game level editor.Currently I am using win32 with directX.But with
I am developing a game using Cocos2d FrameWork in Android. I encountered a problem
I am developing a game for iOS. The memory I am using is around
I'm developing a game using the libGDX Framework. I'd like to implement an icon
I am developing game editor in c++.I have implemented reflection mechanism using DiaSDK.Now I
I'm developing a game with android using andengine. Basically, I'm using 2 ArrayList to
i am developing a game.i want to display score on button click.but it should
I am starting with game dev using Unity3d and I can see there's 3
I'm developing a game for iPhone and is pretty far along, but one thing
Developing a game with AndEngine GLES2 I am having an issue trying to change

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.