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

  • Home
  • SEARCH
  • 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 160897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:06:59+00:00 2026-05-11T11:06:59+00:00

I am looking now for some time about how can a programmer simulate a

  • 0

I am looking now for some time about how can a programmer simulate a AI decision based on percentages of actions for the final fantasy tactic-like games (strategy game).

Say for example that the AI character has the following actions:

Attack 1: 10%
Attack 2: 9%
Magic : 4%
Move : 1%

All of this is far from equaling 100%

Now at first I though about having an array with 100 empty slots, attack would have 10 slots, attack 2 9 slots on the array. Combining random I could get the action to do then. My problem here is it is not really efficient, or doesn’t seem to be. Also important thing, what do I do if I get on an empty slot. Do I have to calculate for each character all actions based on 100% or define maybe a ‘default’ action for everyone ?

Or maybe there is a more efficient way to see all of this ? I think that percentage is the easiest way to implement an AI.

  • 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. 2026-05-11T11:07:00+00:00Added an answer on May 11, 2026 at 11:07 am

    The best answer I can come up with is to make a list of all the possible moves you want the character to have, give each a relative value, then scale all of them to total 100%.

    EDIT:

    For example, here are three moves I have. I want attack and magic to be equally likely, and fleeing to be half as likely as attacking or using magic:

    • attack = 20
    • magic = 20
    • flee = 10

    This adds up to 50, so dividing each by this total gives me a fractional value (multiply by 100 for percentage):

    • attack = 0.4
    • magic = 0.4
    • flee = 0.2

    Then, I would make from this a list of cumulative values (i.e. each entry is a sum of that entry and all that came before it):

    • attack = 0.4
    • magic = 0.8
    • flee = 1

    Now, generate a random number between 0 and 1 and find the first entry in the list that is greater than or equal to that number. That is the move you make.

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

Sidebar

Ask A Question

Stats

  • Questions 105k
  • Answers 105k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Any answer to this question is exceptionally subjective. In regard… May 11, 2026 at 8:41 pm
  • Editorial Team
    Editorial Team added an answer Here is a link on how to extract audio using… May 11, 2026 at 8:41 pm
  • Editorial Team
    Editorial Team added an answer Cannot be done. You can try to hide your JavaScript… May 11, 2026 at 8:41 pm

Related Questions

There are quite a number of modules on CPAN relating to the creation and
I am a .NET developer now and have come from Foxpro /VB6/COM background. Over
I have been supporting a web application at work for our Call Center unit
Possible Duplicate: How can I pre-set arguments in JavaScript function call? (Partial Function Application)

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.