Advertisement
Guest User

Untitled

a guest
Oct 5th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. overview: this is a mod that is a tweaked version of the Generation 1 Random Battle format. Its gimmick is that instead of using preset pokemon levels, it starts all pokemon at level 50 and then tracks their win/loss records. Pokemons' levels are gradually adjusted based on their win rates so that they eventually become balanced. The goal is to reach a perfect state of balance, better than the rather flawed tier-based set-up in the original Generation 1 Random Battle format. The mod functions by storing win/loss records and pokemon levels in a file and updating that file after every battle.
  2.  
  3. the full code: https://github.com/panpawn/Gold-Server
  4.  
  5. the most current version of the stats file: https://drive.google.com/file/d/1pJUkPAu_-UQSLWyMEeVjj0c0luzUQy4W/view?usp=sharing
  6.  
  7. relevant code for the mod:
  8.  
  9. - config/formats.js lines 2120-2126: adds the format to the list of formats
  10.  
  11. - config/pokemon-match-records-initial.tsv: defines the initial version of the stats file, if a current one does not exist
  12.  
  13. - data/mods/gen1/random-teams.js:
  14. - line 243: randomSet now takes an optional usePokemonRecord argument for when the mod is being played
  15. - line 361: usePokemonRecord causes us to draw the level from the pokemon record instead of the tier list
  16. - line 401: a simple function for modded team generation that avoids a bunch of safeguards used by the non-modded gen 1 random battle format, since they shouldn't be as relevant if the pokemon are actually balanced
  17.  
  18. - server/pokemon-record.js: contains the logic to load the pokemon record from the appropriate TSV config file and store it in a global variable. This loads from either the initial config or the updated config depending on whether the 'initial' flag is passed. We should only read from the initial config if the updated config doesn't exist.
  19.  
  20. - server/room-battle.js:
  21. - line 16: imports the 'fs' library for file manipulation
  22. - line 25: imports the pokemon-record module for access to the pokemon record
  23. - line 436: loads the pokemon record on creating a room if the format is the mod format
  24. - line 761: when the battle is over, updates the pokemon record if the format is the mod format
  25. - line 772: defines the function to update the pokemon record. This function fetches each pokemon in the winner's and the loser's team, and updates the pokemon record by adding a win for each winner's pokemon and a loss for each loser's pokemon. It also does a probabilistic update to the pokemon's levels if their win records are lopsided: pokemon that are winning over 51% of the time have a chance to have their level decremented, while pokemon that are winning under 49% of the time have a chance to have their level incremented. This chance of changing the pokemon level decreases as the number of recorded battles increases, in order to avoid see-sawing (i.e. in order to allow the levels to stabilize over time). The 'fs' library is used here to write the new version of the pokemon record TSV file. The 'saving' variable is used to avoid multiple writes at the same time.
  26.  
  27. - server/gold-plugins/gold.js line 1802: defines a chat command, "/randombattleadjusted", which shows the current stats file to the user. Easy way for people without access to the server code to see how the level balancing is going.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement