Code Monkey home page Code Monkey logo

node_mongodb_puzzlegame's Introduction

Puzzle-And-Dragons-Amen-Helper

About

This is a tool applying JavaScript, Node.js, and MongoDB to help you use one of the most challenging leaders in the game Puzzle & Dragons.

Puzzle & Dragons is a 7 years old mobile puzzle game. There are 30 orbs inside a 6*5 board. If you connect three or more identical orbs together, they'll form a combo.
10 Combo example

Meanwhile, Amen is one of the most difficult character in this game. You can get insane damage if you manage to achieve it's leader skill requirement: 7 combo AND the number of remaining orbs <= 3. You can destroy almost everything in the game as long as you activate this leader skill, but it's really hard for normal players to do this.
Damage reaching integer max

So I came up with this tool helping people to play with Amen. I referred to some tutorials in order to find general solutions for Amen puzzles. Finally, I found that I can solve this problem quite easily. For bicolor board, I can simply print out the solutions since there are only a few possible situations. And for tricolor or multi-color board, I can use backtracking to assign the color of each combo. There are 7 combos in total, I only have to check that the neighboring combos don't have identical color. And at the end, check the number of remaining orbs is not greater than three. That's it!

backtracking code

function pickColor(remain, combo, rules){
    function dfs(curAns, curCombo){
        if (Math.min(...remain) < 0)
            return;
        // check the neighbors spcified in rules to be different
        for(var i=0; i<rules.length; i++){
            if(curCombo > Math.max(rules[i][0], rules[i][1])){
                if(curAns[rules[i][0]] == curAns[rules[i][1]])
                    return;
            }
        }
        // found a valid solution
        if(curCombo == combo.length){
            // use the remain drops
            for(var i=0; i<remain.length; i++){
                for(var r=remain[i]; r>0; r--)
                    curAns.push(i);
            }
            permutes.push(curAns);
            return;
        }
        // backtracking
        for(var i=0; i<remain.length; i++){
            if(remain[i] >= combo[curCombo]){
                remain[i] -= combo[curCombo];
                dfs(curAns.concat([i]), curCombo+1);
                remain[i] += combo[curCombo];
            }
        }
    }
    dfs([], 0);
}

The tool is deployed on Heroku since 7/6/2019. It got more than 4000 views within one week, and it has about 150 views per day. Feel free to use it and please contact me if you have any suggestion!

GUI of the tool

References

Website Template
JQuery Session
View Counter

node_mongodb_puzzlegame's People

Contributors

happyman125 avatar joeychang0204 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.