Course:CPSC312-2021-RPGMaterialPlanner

From UBC Wiki

RPG Material Planner

Authors: Xindi Wei, Nawaratt Tonrungroj

What is the problem?

Inspired by the material planner in Arknights Toolbox (https://github.com/arkntools/arknights-toolbox) and can be played on https://arkn.lolicon.app/#/material

The materials dropped in each stage of a RPG game are important resources for upgrading characters. Players may be interested in knowing a plan of “which stage should they complete/clear?” in order to earn enough materials for upgrading to the career they want.

In our make-up RPG game, there are six stages with different amounts of attack, magic, and shield materials can be earned if users complete such stage. The stages are sorted in ascending order in term of difficulty, i.e. stage 1 is easier than 2 and 2 is easier than 3, and so on.

Materials dropped in each stage
Level/Stage magic shield attack Duration
stage 1 1 1 1 1 min
stage 2 1 1 2 1 min
stage 3 1 2 1 2 min
stage 4 2 2 2 2 min
stage 5 3 3 5 3 min
stage 6 4 6 4 4 min

Players can choose a character with a career as either knight, mage, or fighter. Upgrading to different careers require different amounts of materials. Knight is good at attacking and defending, so it requires more shield and attack for upgrading to it. Fighter is focusing on physical attack, so more attack is needed. And, mage requires the most magic and least shield and attack among the three.

Required materials for upgrading to each job
Job/Career required magic required shield required attack
knight 4 8 8
fighter 4 4 12
mage 14 2 4

This material planner allow users to ask questions/query the database. For example:

  • number of materials dropped in each stage
  • duration of a specific stage
  • how many materials needed for upgrading to a specific job

What is the something extra?

Besides, querying the database tables, users can also provide their information, e.g. number of material they currently own, the highest stage level they have cleared. This allows planner to provide more personalized answers to users. For example:

  • how many more materials they need for upgrading to the career they want
  • stages they have to clear in order to earn enough materials for upgrading, as well as number of times they have to clear such stage and total time duration

When suggesting the stages for users to clear, the planner will put a constraint on the stage level, and only suggest the ones that are either:

  • <= the highest stage level users have cleared OR
  • == the highest stage level users have cleared + 1

For example, if user's highest stage level is 3, the planner will include stages 1,2,3,4 in the suggestion.

Furthermore, users can also ask for the best solution which will take the least time (the one with minimum duration). If there is a tie, the planner will suggest the one with lowest stage level, since it should take less effort to complete.

List of questions/queries

  1. What materials required for upgrading to [career/job]? E.g. What materials required for upgrading to fighter?
  2. How many [material type] required for upgrading to [career/job]? E.g. How many attack required for upgrading to fighter?
  3. Can I upgrade to [career/job]? E.g. Can I upgrade to mage?
  4. How many [material type] I still need for upgrading to [career/job]? E.g. How many attack I still need for upgrading to knight?
  5. What materials can be earned from stage [integer from 1 to 6]? E.g. What materials can be earned from stage 6?
  6. How many [material type] can be earned from stage [integer from 1 to 6]? E.g. How many attack can be earned from stage 3?
  7. How many times do I have to clear stage [integer from 1 to 6] for upgrading to [career/job]? E.g. How many times do I have to clear stage 6 for upgrading to mage?
  8. How long does stage [integer from 1 to 6] take? E.g. How long does stage 6 take?
  9. How can I upgrade to [career/job]? E.g. How can I upgrade to mage?
  10. What is the best way for me to upgrade to [career/job]? E.g. What is the best way for me to upgrade to mage?

What did we learn from doing this?

This project definitely helps increase our understanding on Prolog. Although, we had a hard time trying to grab the gist of the language at the beginning. Once everything makes sense, we found it is an efficient tool for creating a rule-based query data system like ours.

Like Haskell, pattern matching in Prolog allows us to build a clean project structure with concise code. Using Prolog, it is possible to get some complicated things done with a few lines of code. For example, our min_duration(...) in planner.pl which takes a list of triples of (stage, times, duration) and returns the one with minimum duration. It is not as simple to do so in other languages, such as C, Java, JavaScript.

Some challenges we had:

  • It is not easy to debug with Prolog. The error messages are quite hard to understand sometimes.
  • String concatenation is not as simple as it should be.

But, overall we are satisfied with using Prolog for our project.

Links to code

https://github.com/cindywe/RPGmaterialPlanner