Winrates for [Gen 9] Computer Generated Teams
`;
- const sorter = toID(query.shift() || 'alphabetical');
- if (!['alphabetical', 'level'].includes(sorter)) {
- throw new Chat.ErrorMessage(`Invalid sorting method. Must be either 'alphabetical' or 'level'.`);
- }
- const otherSort = sorter === 'alphabetical' ? 'Level' : 'Alphabetical';
- buf += `
`;
- buf += `Sort by ${otherSort} descending`;
- buf += `
`;
- const statData: MonCurrent[] = await cgtDatabase.all(
- 'SELECT species_id, wins, losses, level FROM gen9computergeneratedteams'
- );
- this.title = `[Winrates] [Gen 9] Computer Generated Teams`;
- let sortFn: (val: MonCurrent) => Utils.Comparable;
-
- if (sorter === 'alphabetical') {
- sortFn = data => [data.species_id];
- } else {
- sortFn = data => [-data.level];
- }
- const mons = Utils.sortBy(statData, sortFn);
- buf += `
| Pokemon | Level | Wins | Losses | `;
- for (const mon of mons) {
- buf += `
|---|
| ${Dex.species.get(mon.species_id).name} | `;
- buf += `${mon.level} | ${mon.wins} | ${mon.losses} |
`;
- }
- buf += `
`;
- return buf;
- } else if (mode === 'history') {
- // Restricted because this is a potentially very slow command
- this.checkCan('modlog', null, Rooms.get('development')!); // stinky non-null assertion
-
- let speciesID = query.shift();
- let buf;
- if (speciesID) {
- speciesID = getLevelSpeciesID({ species: speciesID || '' } as PokemonSet);
- const species = Dex.species.get(speciesID);
- if (!species.exists ||
- species.isNonstandard || species.isNonstandard === 'Unobtainable' ||
- species.nfe ||
- species.battleOnly && (!species.requiredItems?.length || species.name.endsWith('-Tera'))
- ) {
- this.errorReply('Species has no data in [Gen 9] Computer Generated Teams');
- }
- buf = `Level history for ${species.name} in [Gen 9] CGT
`;
- } else {
- buf = `
Level history for [Gen 9] Computer Generated Teams
`;
- }
- const history: MonHistory[] = await cgtDatabase.all(
- 'SELECT level, species_id, timestamp FROM gen9_historical_levels'
- );
- this.title = `[History] [Gen 9] Computer Generated Teams`;
-
- const MAX_LINES = 100;
- buf += `
| Pokemon | Level | Timestamp | `;
- for (let i = history.length - 1; history.length - i <= MAX_LINES; i--) {
- const entry = history[i];
- if (speciesID && entry.species_id !== speciesID) continue;
- buf += `
|---|
| ${entry.species_id} | ${entry.level} | `;
- const timestamp = new Date(entry.timestamp);
- buf += `${timestamp.toLocaleDateString()}, ${timestamp.toLocaleTimeString()} |
`;
- }
- buf += `
`;
- return buf;
- }
- },
-};
diff --git a/sim/teams.ts b/sim/teams.ts
index 6573141950..2dbc797d5b 100644
--- a/sim/teams.ts
+++ b/sim/teams.ts
@@ -630,9 +630,7 @@ export const Teams = new class Teams {
let mod = format.mod;
if (format.mod === 'monkeyspaw') mod = 'gen9';
const formatID = toID(format);
- if (formatID.includes('gen9computergeneratedteams')) {
- TeamGenerator = require(Dex.forFormat(format).dataDir + '/cg-teams').default;
- } else if (mod === 'gen9ssb') {
+ if (mod === 'gen9ssb') {
TeamGenerator = require(`../data/mods/gen9ssb/random-teams`).default;
} else if (formatID.includes('gen9donotuserandombattle')) {
TeamGenerator = require(`../data/random-battles/donotuse/teams`).default;
diff --git a/test/server/cg-teams.js b/test/server/cg-teams.js
deleted file mode 100644
index 4ec36257bc..0000000000
--- a/test/server/cg-teams.js
+++ /dev/null
@@ -1,61 +0,0 @@
-'use strict';
-
-const assert = require('assert').strict;
-const TeamGenerator = require('../../dist/data/cg-teams').default;
-
-describe('[Gen 9] Computer-Generated Teams', () => {
- it.skip('should give all species 4 or fewer moves', () => {
- const generator = new TeamGenerator();
- const pool = generator.dex.species
- .all()
- .filter(s => s.exists && !(s.isNonstandard || s.isNonstandard === 'Unobtainable') && !s.nfe);
- for (const species of pool) {
- const set = generator.makeSet(species, { hazardSetters: {} });
- assert(set.moves.length <= 4, `Species ${species.name} has more than 4 moves (set=${JSON.stringify(set)})`);
- assert(new Set(set.moves).size === set.moves.length, `Species ${species.name} has duplicate moves (set=${JSON.stringify(set)})`);
- }
- });
-
- // Skipped since it includes randomness; useful for debugging though
- it.skip('should have an accurate weighted picker', () => {
- const generator = new TeamGenerator();
- const numTrials = 100000;
- let error = 0;
- let trials = 0;
-
- for (const choices of [
- [{ choice: 'a', weight: 1 }, { choice: 'b', weight: 2 }],
- [{ choice: 'a', weight: 1 }, { choice: 'b', weight: 1 }],
- [{ choice: 'a', weight: 30 }, { choice: 'b', weight: 2000 }, { choice: 'c', weight: 7 }],
- // a big test case with lots of different weight values
- [
- { choice: 'a', weight: 1345 }, { choice: 'b', weight: 2013 }, { choice: 'c', weight: 3411 }, { choice: 'd', weight: 940 },
- { choice: 'e', weight: 505 }, { choice: 'f', weight: 10148 }, { choice: 'g', weight: 7342 }, { choice: 'h', weight: 8403 },
- { choice: 'i', weight: 9859 }, { choice: 'j', weight: 1042 }, { choice: 'k', weight: 1132 }, { choice: 'l', weight: 1200 },
- ],
- ]) {
- const results = {};
- for (let i = 0; i < numTrials; i++) {
- const res = generator.weightedRandomPick(choices.map(x => x.choice), c => choices.find(x => x.choice === c)?.weight || 0);
- // console.log(`"${res}"`);
- if (!results[res]) results[res] = 0;
- results[res]++;
- }
-
- let totalWeight = 0;
- for (const choice of choices) {
- totalWeight += choice.weight;
- }
-
- for (const [choice, count] of Object.entries(results)) {
- const c = choices.find(x => x.choice === choice);
- const expected = (c.weight / totalWeight) * numTrials;
- error += Math.abs(count - expected) / expected;
- trials++;
- }
- }
-
- const percentError = (error / trials) * 100;
- assert(percentError < 3, `Weighted picker error is too high: ${percentError.toFixed(1)}%`);
- });
-});