Code Monkey home page Code Monkey logo

gohbem's People

Contributors

lenisko avatar mygod avatar turtiesocks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gohbem's Issues

Benchmark

Benchmark

TL;DR

  • Go QueryPvPRank is 5 times faster than node with disabled cache.
  • Go QueryPvPRank is 10 times faster than node with enabled cache.

Specs & versions

# OhbemGo 0.7.3
# Ohbem 1.4.1
# cpu: 12th Gen Intel(R) Core(TM) i9-12900KF

$ go version
go version go1.19.4 linux/amd64
$ node --version
v16.14.0

QueryPvPRank

OhbemGo

$ time ./main  # cache disabled ; maxPokemonId = 2
QueryPvPRank iterated 13068 in 1m23.355235694s

real    1m23.406s
user    1m29.580s
sys     0m4.767s

$ time ./main  # cache enabled ; maxPokemonId = 200
QueryPvPRank iterated 1306800 in 3.821691967s

real    0m3.898s
user    0m4.094s
sys     0m0.315s

Ohbem (node)

$ time node main.js  # cache disabled ; maxPokemonId = 2
queryPvPRank iterated 13068 in 418771ms

real    6m58.854s
user    7m7.976s
sys     0m17.332s

$ time node main.js  # cache enabled ; maxPokemonId = 200
queryPvPRank iterated 1306800 in 38922ms

real    0m39.038s
user    0m46.019s
sys     0m3.972s

Test scripts

main.js

const Ohbem = require('ohbem');
const pokemonData = require('./master-test.json');

async function test() {
    const ohbem = new Ohbem({
        leagues: {
        little: {
            little: false,
            cap: 500,
        },
        great: {
            little: false,
            cap: 1500,
        },
        ultra: {
            little: false,
            cap: 2500,
        },
        master: null,
    },
        levelCaps: [40, 50, 51],
        pokemonData,
        cachingStrategy: Ohbem.cachingStrategies.balanced // change
    });

    const maxPokemonId = 200; // change
    const maxAttack = 10;
    const maxDefense = 5;
    const maxStamina = 10;
    const maxLevel = 5;
    let counter = 0;

    const start = Date.now();
    for (let p = 1; p <= maxPokemonId; p++) {
        for (let a = 0; a <= maxAttack; a++) {
            for (let d = 0; d <= maxDefense; d++) {
                for (let s = 0; s <= maxStamina; s++) {
                    for (let l = 1; l <= maxLevel; l += 0.5) {
                        ohbem.queryPvPRank(p, 0, 0, 0, a, d, s, l);
                        counter++;
                    }
                }
            }
        }
    }
    const elapsed = Date.now() - start;
    console.log(`queryPvPRank iterated ${counter} in ${elapsed}ms`);
}

test();

main.go

package main

import (
	"fmt"
	"github.com/Pupitar/ohbemgo"
	"time"
)

func mainOne() {
	var leagues = map[string]ohbemgo.League{
		"little": {
			Cap:            500,
			LittleCupRules: false,
		},
		"great": {
			Cap:            1500,
			LittleCupRules: false,
		},
		"ultra": {
			Cap:            2500,
			LittleCupRules: false,
		},
		"master": {
			Cap:            0,
			LittleCupRules: false,
		},
	}

	levelCaps := []int{40, 50, 51}

	ohbem := ohbemgo.Ohbem{Leagues: leagues, LevelCaps: levelCaps, DisableCache: false}  // change
	_ = ohbem.LoadPokemonData("master-test.json")

	const (
		maxPokemonId = 200 // change
		maxAttack    = 10
		maxDefense   = 5
		maxStamina   = 10
		maxLevel     = 5
	)
	var counter uint

	start := time.Now()
	for p := 1; p <= maxPokemonId; p++ {
		for a := 0; a <= maxAttack; a++ {
			for d := 0; d <= maxDefense; d++ {
				for s := 0; s <= maxStamina; s++ {
					for l := 1.0; l <= maxLevel; l = l + 0.5 {
						ohbem.QueryPvPRank(p, 0, 0, 0, a, d, s, l)
						counter++
					}
				}
			}
		}
	}
	elapsed := time.Since(start)
	fmt.Printf("QueryPvPRank iterated %d in %s\n", counter, elapsed)

func main() {
	mainOne() // bench go
}

Make Tied Ranking Optional

Add config to make tied ranking optional. Why?

  • RDM gives the option for tied, aka Competition Ranking (1,1,3,4,5) as well as non-tied, aka Ordinal Ranking (1,2,3,4,5), so why not let the mapper choose between the two?
  • Tied ranking confuses both users and mappers since many of the main PvP IV sites like GO Stadium do not use tied rankings. This leads to the constant question of "why did the map say this was a rank 1 when it isn't a rank 1?"
  • As mappers, we should report the best mon to users. The only people who get excited about Functional Rank 1's are users who don't have a map. So I (personally) don't think tied-ranking should be the default.

Missing Competition Ranks

These results compare RDM PVP vs Ohbem GO pvp. The results with Ohbem JS are the same as RDM PVP.

Guide:

pokemon_id
Atk
Def
Sta
Level

pokemon_id
Rank
Cp
Level/cap

Spheal
363
4
14
14
1

365
3
500
7

====================

Poliwag
60
11
15
15
24

62
3
2497
39/40

====================

Pikachu - winter 2020
25
1
15
15
16

25
1
500
21

====================

Bidoof
399
0
15
14
6

400
1
499
10.5

400
2
1498
33

RDM

{
    "little": [
        {
            "dense_rank": 23,
            "cap": 40,
            "rank": 32,
            "ordinal_rank": 33,
            "cp": 493,
            "form": 1667,
            "gender": 1,
            "pokemon": 399,
            "percentage": 0.982754803145974,
            "capped": true,
            "competition_rank": 32,
            "level": 28.5
        },
        {
            "cap": 40,
            "capped": true,
            "pokemon": 400,
            "percentage": 1.0,
            "cp": 499,
            "rank": 1,
            "gender": 1,
            "level": 10.5,
            "competition_rank": 1,
            "dense_rank": 1,
            "ordinal_rank": 2,
            "form": 1670
        }
    ],
    "great": [
        {
            "cp": 1498,
            "dense_rank": 2,
            "cap": 40,
            "capped": true,
            "percentage": 0.9995893471107288,
            "gender": 1,
            "ordinal_rank": 2,
            "form": 1670,
            "competition_rank": 2,
            "pokemon": 400,
            "level": 33.0,
            "rank": 2
        }
    ]
}

Golbat

{}

Golbat settings:

[pvp]
enabled = true
include_hundos_under_cap = false
level_caps = [40, 50, 51]

[[pvp.leagues]]
name = "little"
cap = 500
little = false

[[pvp.leagues]]
name = "great"
cap = 1500
little = false

[[pvp.leagues]]
name = "ultra"
cap = 2500
little = false

RDM

      PVP_DEFAULT_RANK: competition
      PVP_LITTLE_FILTER: 500
      PVP_GREAT_FILTER: 1500
      PVP_ULTRA_FILTER: 2500
      PVP_LEVEL_CAPS: 40,50,51

Duplicate Ranks

As discussed, Gohbem seems to be creating duplicate ranks, specifically for Koffing:

{
    "great": [
        {
            "pokemon": 110,
            "form": 706,
            "cap": 50,
            "value": 1836309,
            "level": 23,
            "cp": 1479,
            "percentage": 0.95009,
            "rank": 1731,
            "capped": true
        },
        {
            "pokemon": 110,
            "form": 944,
            "cap": 50,
            "value": 1836309,
            "level": 23,
            "cp": 1479,
            "percentage": 0.95009,
            "rank": 1731,
            "capped": true
        },
        {
            "pokemon": 110,
            "form": 944,
            "cap": 50,
            "value": 1836309,
            "level": 23,
            "cp": 1479,
            "percentage": 0.95009,
            "rank": 1731,
            "capped": true
        },
        {
            "pokemon": 110,
            "form": 944,
            "cap": 50,
            "value": 1836309,
            "level": 23,
            "cp": 1479,
            "percentage": 0.95009,
            "rank": 1731,
            "capped": true
        }
    ],
    "ultra": [
        {
            "pokemon": 110,
            "form": 706,
            "cap": 50,
            "value": 4028491,
            "level": 48.5,
            "cp": 2500,
            "percentage": 0.99239,
            "rank": 13
        },
        {
            "pokemon": 110,
            "form": 706,
            "cap": 51,
            "value": 4028491,
            "level": 48.5,
            "cp": 2500,
            "percentage": 0.98497,
            "rank": 56
        },
        {
            "pokemon": 110,
            "form": 944,
            "cap": 50,
            "value": 4028491,
            "level": 48.5,
            "cp": 2500,
            "percentage": 0.99239,
            "rank": 13
        },
        {
            "pokemon": 110,
            "form": 944,
            "cap": 51,
            "value": 4028491,
            "level": 48.5,
            "cp": 2500,
            "percentage": 0.98497,
            "rank": 56
        },
        {
            "pokemon": 110,
            "form": 944,
            "cap": 50,
            "value": 4028491,
            "level": 48.5,
            "cp": 2500,
            "percentage": 0.99239,
            "rank": 13
        },
        {
            "pokemon": 110,
            "form": 944,
            "cap": 51,
            "value": 4028491,
            "level": 48.5,
            "cp": 2500,
            "percentage": 0.98497,
            "rank": 56
        },
        {
            "pokemon": 110,
            "form": 944,
            "cap": 50,
            "value": 4028491,
            "level": 48.5,
            "cp": 2500,
            "percentage": 0.99239,
            "rank": 13
        },
        {
            "pokemon": 110,
            "form": 944,
            "cap": 51,
            "value": 4028491,
            "level": 48.5,
            "cp": 2500,
            "percentage": 0.98497,
            "rank": 56
        }
    ]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.