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 6907901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:29:36+00:00 2026-05-27T08:29:36+00:00

I have the problem to write the AI to game(like tron lightcycles). I write

  • 0

I have the problem to write the AI to game(like tron lightcycles).
I write all the graphics and movements on C using ncurses.
Now i need to write the bot’s ai on the prolog. I’m using swi prolog.

I save the current game field(all matrix), current human position and current bot position(like matrix cells i, j). They saves like predicats in the .pl file from c.

My game field is a matrix which contains 1 and 0( 1 – visited, 0 – unvisited ).
Like this:

human_current_position(0,1).
bot_current_position(1,2).
matrix([[1,1,0,0],
[1,1,1,0],
[0,0,0,0],
[0,0,0,0]]).

Then i need to analyze this matrix like:

analyze(matrix).

So the analyze function in prolog will return some direction(left, down, up or right) save into file and
my c program read this file and move the bot.

So I have the question – How i can analyze this matrix in Prolog.
I read something about min-max algorithm, but i can’t realize this in Prolog.
Can anyone helps or show the direction how to make work min max algorithm
with my matrix and current positions in Prolog?

  • 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-05-27T08:29:37+00:00Added an answer on May 27, 2026 at 8:29 am

    I am not sure whether min-max leads to good result for tron. Since on a grid one has
    usually many commutative moves, blowing up the search space. Maybe for a small
    field and/or a small search depth. But you could try to use negation as failure
    for min-max and you get alfa-beta pruning for free (I guess so).

    In games without uncertainty the min-max algorithm computes the minimal opponent gain supposed the opponent on the other hand tries to maximize his gain. Let i range over the players moves and j over the opponent moves. This leads to a recursive formula as follows:

    Worst-Opponents-Gain = min_i (max_j ( Worst-Opponents-Gain_i_j) )
    

    Since we deal with a zero sum game the opponents gain is our win. So that we have Opponents-Gain = – Win. We can re-formulate the min-max search into a max search. Each player is a maximizer.

    Best-Win = max_i ( - Best-Win_i).
    

    When your win values are in the range {-1, 0, 1} then you can use negation as failure. Just implement
    the following predicates to model your game:

    % move(+Board,+Player,-Board)  
    % init(+Board)  
    % win(+Board,+Player)  
    % oposite(+Player,-Player)  
    % tie(+Board,+Player)
    

    The above predicates will model the game completely in the Arguments, thus a game state will be stored in a local variable. The game is then “analyzed” via the following predicate:

    % best(+Board,+Player,-Board)  
    best(X,P,Y) :-  
      move(X,P,Y),  
      (win(Y,P) -> true;  
        oposite(P,Q),  
        \+ tie(Y,Q),  
        \+ best(Y,Q,_)).
    

    You might want to add additional parameters to limit the search depth, or to return
    a symbolic repesentation of the move.

    Bye

    P.S.: You find a tic-tac-toe example here.

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

Sidebar

Related Questions

I have a problem. I need to trace all read/write operations to the registry
Ok, so here's the problem I have to solve. I need to write a
I have a problem to write and read properly a CSV file composed of
I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
I have problem with fancybox. I want to write a function that will run
I have one problem, I learn how work with socket and I write programm
I am trying to write documentation comments however I have a problem. /// <summary>
I have to write an applet that brings up a password dialog. The problem
Got a problem with a query I'm trying to write. I have a table
I'm developing a small game in Java and I have run into a problem

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.