breakds / monster-avengers

Monster Hunter Armor Searcher
https://mhxx.us.breakds.org
MIT License
25 stars 12 forks source link
algorithm armor-search monster-hunter search-algorithm

monster-avengers - The MH4G/MH4U/MHX Armor Set Search Tool

Introduction

This is a hobby project of mine, which impelements an algorithm and a web based UI that finds armor sets to satisfy certain requirements in the game Monster Hunter 4 Ultimate (Japanese Version: Monster Hunter 4G).

Monster Hunter has an unique skill system, and in order to active a certain skill, we need to craft a combination of armors including a weapon, a helmet, a body armor, a waist armor, an arm armor, a legs armor and an amulet, whose total contribution to the desired skill exceeds a skill points level. Finding the right set of armor pieces that activates the required skills is difficult, as there are ~ 150 different skill trees, ~ 600 candidate armors for each of the pieces, and each armor contributes to several skills, positively or negatively. What makes the problem more interesting is that armors may have slots, where different decorations contributing to different skills can be plugged in.

monster-avengers is such a tool to efficiently find the right armor combinations given the desired set of skills. With a carefully designed algorithm, it

  1. supports fast search from all 3,000+ different armors in the databse.
  2. outputs armor combinations with decorations.
  3. consideres Torso up armors.
  4. supports adding custom amulets in the query.
  5. considers the number of slots on the weapon.
  6. supports filtering on the search result to exclude certain armor pieces.
  7. communicates with a simple lisp-based query language.
  8. suggests skills that are still achievable based the current selected skills.

It also comes with a web based UI.

Supported Interfaces

Web App

There is currently one instance of this tool running on a server with very limited computational resource. You can find it at http://mh4u.breakds.org.

C# API

Located in csharp/winbind_wrapper. A C# wrapper class implemented via DLLImport.

RESTful API

Work in progress.

Algorithm

I am working on a series of posts discussing the algorithm behind this project on my blog. Take a look if you are curious and interested.

Codebase

For those who is interested in either the algorithm or the implementaion, you can find a brief description below. Note that the code is still not very well documented yet, and I am working on adding the comments and documentations to the code as much as possible with the limited time budget.

The code is mainly divided into 2 parts:

  1. cpp/ A C++ implementation of the search algorithm, where we have
    • lisp/ provides the parser and reader of lisp objects, in which format query and database entries are stored.
    • data/ defines the data structs that are involved, e.g. the skills, the armors, the jewels ,etc.
    • core/ implements the search algorithm, where you can find the member method ArmorUp::Search is the main entry point to the algorithm.
  2. lisp/ui/ implements the web based UI for this armor search tool. This webapp is written in Common Lisp based on the web framework reaLispic. Specifically,
    • widgets/ contains the definitions of all the widgets in the web. The code should be very straightforward if you are familiar with React.js.
    • backend.lisp defines the RPC that talks to the C++ backend to handle queries. This is a super naive implementation that does the message passing via files on disk.

Build and Run

The C++ code is managed by CMake. To build the C++ binary:

cd cpp/
mkdir build
cd build
cmake ..

Now, you can either run make to build the binary serve_query, or ccmake . to configure the Makefile generation. You can toggle the build type to be RELEASE to build a much more efficient binary.

To run the web server that serves the UI, you need a lisp implementation (e.g. SBCL), and quicklisp. After having them configured, you can place the project folder (or a symbolic link to the folder) under quicklisp/local-projects, and start sbcl. At the Common Lisp top-level, run

(ql:quickload 'monster-avengers)
(monster-avengers.simple-web:armor-tools :start)

to start the web server. You should now be able to access the web app locally at localhost:16384/app?lang=en. Note that this project depends on several of other projects, which should be downloaded at placed at quicklisp/local-projects:

Limitations and Futrue Work

There are currently some limitations in the current implementations, and I will work on improve over them. Those that I am aware of are:

  1. The webapp does not support custom guild armors.
    • The algorithm supports guild armors, of course.
    • I am a terribly bad designer and I cannot think of a way to add such options to the page, without making it look very complicated.
    • This functionality will be added soon.
  2. The communication between backend and web server are file-based
    • This is going to be replaced by a real RPC framework.
  3. The webapp does not store any information to personalization features, such as personal armor sets library, personal amulets library, etc.
    • To be honest, I am not experienced enough to implement this efficiently and securely. Will add those features in the future, but with no promise.
  4. Hunter progress options.
    • I think it is a good idea to filter out armors based the player's progress. I am lacking the data to implement this feature.
  5. JSON and Lisp parser/composer should go into other packages (or not?).

Acknowledgement

  1. Credit to Ping An, the author of Ping's Dex. His effort on composing the data are source to many other related projects.
  2. Credit to the project MonsterHunter4UDatabase, where all the data (armors, skills and decorations) are from their database. Completing the database requires a lot of work and without their effort, I would not have accomplished this.
  3. Credit to Cassandra Qi, my wife and my Monster Hunter game partner, for working on the art and design of the UI.
  4. Thanks to my friends who inspired me, encouraged me, disccussed the ideas with me and helped with the tests:
    • Frank Xiao Lin
    • Zommie Dev
    • Hui Guo
    • KIRANICO
    • Epona Yunlu Guo
    • Wybaby

License

All the codes in this project are under the MIT License.