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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:09:58+00:00 2026-05-18T12:09:58+00:00

Background Assume that we have a game where monsters and weapons are generated randomly.

  • 0

Background

Assume that we have a game where monsters and weapons are generated “randomly”.

A weapon could be defined like this:

  • type: axe (1.2) / sword (1.4) / spear (1) / club (0.7)
  • range: 1 – 3
  • magic: ice (10) / fire (10) / none (1)
  • state: sharp (2) / normal (1) / dull (0.5)

Some of these values could have dependencies (e.g. type and range).

Using a random generator we could get for example a dull Axe of Fire (range 2). Then we could have a formula that calculates the level of this weapon. Example formula:

level = floor(type * range * magic * state)

The dull Axe of Fire (range 2) would then have level floor(1.2 * 2 * 10 * 0.5) = 12.

Simple, but nice!

We could also have a world where the player goes deeper and deeper down into the dangerous caves, starting at cave level 1.

The question

Let’s say the player is at cave level 12. (S)he has entered a room where we want to place a weapon in a chest.

What would be a good algorithm to generate a level 12 weapon? (or any other level of course)

I.e. we have the level and want to use a level calculation (our simple one, or another more sophisticated) backwards to generate good values for the different elements of the weapon.

Minor or major changes to the definition of a weapon can be made to facilitate a better solution.

EDIT:

It seems like High Performance Mark‘s solution is the best where there are a reasonably limited set of combinations. If not, or if we have continuous values and an “unlimited” set of combinations, one of the other answers might be better suited. I say “might” since maybe a lookup table could be used even in a continuous version for a subset of the values to pick a good starting point and then one could add a small random delta to fill in.

Example: range is continuous between 10 and 200. The lookup table contains values (10, 20, 30, …, 190, 200). The algorithm picks 110 for range and then adds random(-5.0, 5.0) to it for a final value of, say, 108.72. Then the final level of the weapon would be close enough to the desired value to do. How does that sound?

  • 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-18T12:09:59+00:00Added an answer on May 18, 2026 at 12:09 pm

    If you have, say, 5 choices each of type, range, magic and state then you have 5^4 choices of weapon. This is quite a small number and you could easily store them all in a lookup table, indexed on the level of weapons. When you want a random level 12 weapon, you choose uniformly from the available level 12 weapons.

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

Sidebar

Related Questions

Assume I have a CI app that does the following: Allow users to log
I have an H3 heading that I'd like to style as having a particular
Background: I have a little video playing app with a UI inspired by the
Background: At my company we are developing a bunch applications that are using the
Background I have a massive db for a SharePoint site collection. It is 130GB
Background I am trying to create a copy of a business object I have
Background I have been asked by a client to create a picture of the
I have an iPhone VOIP app that copes with multi-multi transmit and receive (ie
Background: Some time ago, I built a system for recording and categorizing application crashes
Background: I need to reserve an amount of memory below 0xA0000 prior to my

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.