GithubHelp home page GithubHelp logo

Realm Rank is wrong? about uthgard-herald HOT 3 CLOSED

thekroko avatar thekroko commented on August 15, 2024
Realm Rank is wrong?

from uthgard-herald.

Comments (3)

burfo avatar burfo commented on August 15, 2024

Not the first time I've heard somebody say that. I suspect the splits are wrong within the API.

from uthgard-herald.

andir avatar andir commented on August 15, 2024

@thekroko The current code has a classic off-by-one issue which can be fixed by handling the zero RP case dfiferently and adding 10 to each n-i'th value:

func getRRForRP(rp int32) int {                                                                           
        if rp > 0 {                                                                                       
                n := len(rpForLevel)                                                                      
                for i := range rpForLevel {                                                               
                        idx := n - i - 1                                                                  
                        if rpForLevel[idx] <= rp {                                                        
                                return (n - i) + 10                                                       
                        }                                                                                 
                }                                                                                         
        }                                                                                                 
        return 10                                                                                         
}

(based of http://pastebin.com/7cAwJUUQ)

You should probably add some tests to your test suites. The following cases turned out to be useful:

                                                                                                          
func main() {                                                                                             
        type Test struct {                                                                                
                rp   int32                                                                                
                rank int                                                                                  
        }                                                                                                 
                                                                                                          
        tests := []Test{                                                                                  
                Test{0, 10},                                                                              
                Test{25, 12},                                                                             
                Test{750, 15},                                                                            
                Test{73683, 31},                                                                          
                Test{1668226, 69},                                                                        
                Test{66181501, 130},                                                                      
        }                                                                                                 
                                                                                                          
        for _, test := range tests {                                                                      
                rr := getRRForRP(test.rp)                                                                 
                if rr != test.rank {                                                                      
                        fmt.Printf("%v shoule be %v (%v)\n", rr, test.rank, test.rp)
                } else {              
                        fmt.Printf("    ✓ %v is %v (%v)\n", rr, test.rank, test.rp)                       
                }                                                                                         
        }                                                                                                 
                                                                                                          
}

from uthgard-herald.

thekroko avatar thekroko commented on August 15, 2024

Fixed with next push. Thank you! :)

from uthgard-herald.

Related Issues (20)

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.