123

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="container">
  <h1>Player Experience Equations</h1>
  <section>
    <div>
      <p>
        The purpose here is to show how an algorithm could prevent the problem of overpowered players in a VRMMO like Domino Finn's "Reboot" series.  
      </p>
      <p>
          Even if the player at the top gained an enormous amount of experience, they wouldn't level until the average of other players started to rise. 
        </p>
      <p>Conversely, a newbie would have a much easier time leveling.</p>
      <h2>Base Experience Equation</h2>
      <p>
        Let the base experience (b) equal 1000 * the level of the player (cpl).
      </p>
      <p>$$b = 1000 * cpl$$</p>
      <p>In the event that the character's level is the same as the average level of other characters, the base experience equation shall be used.</p>
      <h2>Base Equation for Highest Level Player</h2>
      <p>For the highest leveled player who is not equal to the average level, let experience equal the base experience (b) times the highest level player (h) divided by the average level of other players (avl) raised to the power of (h) minus the next highest leveled player (nh) + 1.</p>
    </div>

    <div class="equation">
      
      <p>$$exp = b({({h \over avl})^{(h-nh+1)}})$$</p>
    </div>
    <div class="equation">
      <h2>Base Equation for Other Players</h2>
      <p>For a player who is not the highest leveled player and is not at the same level as the average player, let experience (exp) equal the base experience (b) divided by the current player level (cpl) over the average player's level (avl)</p>
      <p>
        $$exp = {b({cpl \over avl})} $$
      </p>
    </div>
  </section>
  <section class="col col-sm-12">
    
    <div class="input col">
      <label class="col-sm-9" for="highestLevelPlayer">
    Highest Level Player
  </label>
      <input class="col-sm-3" type="number" id='highestLevelPlayer' value='10' min='0'>
    </div>
    <div class="input col">
      <label class="col-sm-9" for="nextHighestLevelPlayer">Next Highest Level Player</label>
      <input class="col-sm-3" type="number" id='nextHighestLevelPlayer' value='8' min='0'>
    </div>
    <div class="input col">
      <label class="col-sm-9" for="averagePlayerLevel">Average Player Level</label>
      <input class="col-sm-3" type="number" id='averagePlayerLevel' value='5' min='0'>
    </div>
    <div class="input col">
      <label class="col-sm-9" for="otherPlayerLevel">Other Player Level</label>
      <input class="col-sm-3" type="number" id='otherPlayerLevel' value='1' min='0'>
    </div>
  </section>
  <section>
    <section>
      <h2>Results:</h2>
      <div>
        For the highest level player with a level of <span id="hplayer"></span>, the experience required will be <output id='highestLevelPlayerResult'></output> out of a base experience of <output id='baseExperienceHighestOutput2'></output>
      </div>
      <div>
        For the other player with a level of  <span id="oplayer"></span>, the experience required will be <output id="otherPlayerResult"></output> out of a base experience of <output id="otherPlayerOutput2"></output>
      </div>
      <div>
        <br/>
        <p>Equation visualized:</p> 
        <p><strong>Highest Player Formula: </strong><output id='totalExpHighestOutput'></output> = <output id='baseExperienceHighestOutput'></output>((<output id='highestLevelPlayerLevelOutput1'></output> / <output id='averagePlayerLevelOutput'></output>)<sup>(<output id='highestLevelPlayerLevelOutput2'></output>-<output id='nextHighestLevelOutput'></output>+1)</sup>)</p>

        </div>
    </section>
  </section>
</div>
            
          
!
            
              const d = document
const highestPlayerLevel = d.querySelector('#highestLevelPlayer')
const nextHighestPlayerLevel = d.querySelector('#nextHighestLevelPlayer')
const averagePlayerLevel = d.querySelector('#averagePlayerLevel')
const otherPlayerLevel = d.querySelector('#otherPlayerLevel')

const highestPlayerSpan = d.querySelector('#hplayer')
const playerResult = d.querySelector('#highestLevelPlayerResult')

const otherPlayerSpan = d.querySelector('#oplayer')
const otherPlayerResult = d.querySelector('#otherPlayerResult')
const otherPlayerOutput2 = d.querySelector('#otherPlayerOutput2')

const baseExperienceFunc = (level) => {
  return Number(level) * 1000
}

const playerOutput = () => {
  highestPlayerSpan.innerHTML = highestPlayerLevel.value
}

const otherPlayerOutput = () => {
  otherPlayerSpan.innerHTML = otherPlayerLevel.value
}

const otherPlayerEquation = () => {
  const playerLevel = Number(otherPlayerLevel.value)
  const highestLevel = Number(highestPlayerLevel.value)
  const averageLevel = Number(averagePlayerLevel.value)
  const baseExperience = baseExperienceFunc(playerLevel)

  if (playerLevel === highestLevel) {
    return baseExperience
  }
  if (playerLevel > highestLevel) {
    alert("ERROR!  The other player cannot be higher leveled than the highest player!")
    return
  }
  otherPlayerOutput2.innerHTML = baseExperience.toLocaleString()
  otherPlayerResult.innerHTML = Number(Math.round(baseExperience * (playerLevel / averageLevel))).toLocaleString()
}

const highestLevelPlayerEquation = () => {
  const playerLevel = Number(highestPlayerLevel.value)
  const baseExperience = baseExperienceFunc(playerLevel)
  const nextHighestLevel = Number(nextHighestPlayerLevel.value)
  const averageLevel = Number(averagePlayerLevel.value)
  if (playerLevel === averageLevel) {
    return baseExperience
  }
  if (playerLevel < averageLevel) {
    alert("ERROR!  The average level cannot be higher than the highest leveled player!")
    return
  }
  const base = (playerLevel / averageLevel)
  const expo = (playerLevel - nextHighestLevel + 1)
  const exponent = Math.pow(base, expo)
  const result = Math.round(baseExperience * exponent)
  playerResult.innerHTML = result.toLocaleString()
}

highestLevelPlayerEquation()
otherPlayerEquation()
playerOutput()
otherPlayerOutput()


highestPlayerLevel.addEventListener('change', playerOutput)
otherPlayerLevel.addEventListener('change', otherPlayerOutput)
highestPlayerLevel.addEventListener('change', highestLevelPlayerEquation)
nextHighestPlayerLevel.addEventListener('change', highestLevelPlayerEquation)
averagePlayerLevel.addEventListener('change', highestLevelPlayerEquation)
averagePlayerLevel.addEventListener('change', otherPlayerEquation)
otherPlayerLevel.addEventListener('change', otherPlayerEquation)

const totalExpHighestOutput = d.querySelector('#totalExpHighestOutput') 
const baseExperienceHighestOutput = d.querySelector('#baseExperienceHighestOutput')
highestLevelOutput1 = d.querySelector('#highestLevelPlayerLevelOutput1') 
highestLevelOutput2 = d.querySelector('#highestLevelPlayerLevelOutput2')
averagePlayerOutput = d.querySelector('#averagePlayerLevelOutput')
nextHighestLevelOutput = d.querySelector('#nextHighestLevelOutput')

const baseExperienceHighestOutput2 = d.querySelector('#baseExperienceHighestOutput2')


const changeHighestLevelFormula = () => {
  const playerLevel = Number(highestPlayerLevel.value)
  const baseExperience = baseExperienceFunc(playerLevel)
  const nextHighestLevel = Number(nextHighestPlayerLevel.value)
  const averageLevel = Number(averagePlayerLevel.value)
  const base = (playerLevel / averageLevel)
  const expo = (playerLevel - nextHighestLevel + 1)
  const exponent = Math.pow(base, expo)
  const result = Math.round(baseExperience * exponent)
  totalExpHighestOutput.innerHTML = result.toLocaleString()
  baseExperienceHighestOutput.innerHTML = baseExperience.toLocaleString()
  baseExperienceHighestOutput2.innerHTML = baseExperience.toLocaleString()
  highestLevelOutput1.innerHTML = playerLevel
  highestLevelOutput2.innerHTML = playerLevel
  averagePlayerOutput.innerHTML = averageLevel
  nextHighestLevelOutput.innerHTML = nextHighestLevel
}

changeHighestLevelFormula()

highestPlayerLevel.addEventListener('change', changeHighestLevelFormula)
nextHighestPlayerLevel.addEventListener('change', changeHighestLevelFormula)
averagePlayerLevel.addEventListener('change', changeHighestLevelFormula)


            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console