Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <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>
              
            
!

CSS

              
                
              
            
!

JS

              
                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

Console