Skip to content

Fibonacci sequence derived levels #190

@Fluffy9

Description

@Fluffy9
    function fib(uint256 _n) internal pure returns (uint256) {
        if (_n == 0) {
            return 0;
        } else if (_n == 1 || _n == 2) {
            return 1;
        } else {
            uint256 fi_1 = 1;
            uint256 fi_2 = 1;
            for (uint256 i = 2; i < _n; i++) {
                uint256 fi = fi_2 + fi_1;
                fi_2 = fi_1;
                fi_1 = fi;
            }

            return fi_1;
        }
    }

...

            /**

 
             * First 10 Levels: 
             * 1. 300
             * 2. 500
             * 3. 800
             * 4. 1300
             * 5. 2100
             * 6. 3400 
             * 7. 5500 
             * 8. 8900 
             * 9. 14400
             * 10. 23300
             */        
        for(uint256 i = 1; i <= MAX_LEVEL; i++){
            console.log((fib(i+3) * 100));
            Levels.setExperience(i, (fib(i+3) * 100));
}

87ebcc5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions