SlideShare a Scribd company logo
1 of 83
Download to read offline
Item Generation Using Rule-Based Randomization
Algorithms in Role Playing Games
Rejosh Varghese Samuel
A dissertation submitted in partial fulfilment of the requirement for
the award of the degree of MSc in Computer Games Technology
University of Abertay Dundee
Institute of Arts, Media and Computer Games
December 2011
0
University of Abertay Dundee
Permission to copy
Author: Rejosh Varghese Samuel
Title: Item Generation Using Rule-Based Randomization
Algorithms in Role Playing Games
Qualification sought: M.Sc.
Year: 2011
(i) I certify that the above mentioned project is my original work
(ii) I agree that this dissertation may be reproduced, stored or
transmitted, in any form and by any means without the written
consent of the undersigned.
Signature …………………….........................
Date …………………………..
1
ABSTRACT
Have you ever wondered about what makes a treasure chest to have unique and powerful items
in your favourite Role Playing Game? Or have you ever had the urge to go “Item Farming” to
make that perfect suit of armour or to have that complete arsenal of weapons at your disposal?
The game mechanic for customizing your character to suit the players‟ needs initially introduced
in Role Playing Games has been successful in appealing to players and has found its way to other
genres of games as well. Whether it is a rare enchanted sword, power-up to boost the characters‟
skills or a currency system which allows the player to buy merchandise from in-game stores,
collecting loot has become a critical way to play most games.
Even though many players have asked the question “Why did it drop this item?” or “Why didn‟t
I get a better one?” many of them don‟t understand how it works. If you‟re wondering about it,
then it would seem interesting to know how the game decides to give you this random loot. This
would require an understanding of how items are created and the algorithms involved in
randomly generating a collectable item. This is called “Item drop mechanics”, referring to items
being dropped from a chest or a monster once it has been slain. This falls under a category of
Artificial Intelligence (AI), which require bounding to certain rules to create an appropriate item
while playing the game. These rules help to define the limits of the possibility of creating any
item. With a suitable randomization algorithm it would be possible to have unpredictable
outcome with coherence.
This research discusses the available randomization algorithms as compared to rule-based
randomized algorithm and also discusses current and past games with such mechanics. Based on
this research, an item generation mechanic was developed in a prototype game which was
repeatedly tested to generate a 200 player simulated test cases. Based on the analysis of this
output, a conclusion was drawn out as to how it can affect the game play and replay ability for
player satisfaction and in turn prolong the shelf life of the game. This research also sheds light
on the importance of the item generation mechanic and its usefulness in post production. Join me
in taking the next step into darkness to see what light uncovers!
2
ACKNOWLEDGEMENT
I would sincerely like to thank Dr. Suheyl Ozveren for his guidance and feedback which helped
me in improving my approach to my research. I would also like to thank Dr. Euan Dempster for
helping me to remain on track within my deadlines.
I would also like to acknowledge that I have used a lot of content from the game Diablo 2,
including item pictures, various effects and a few sounds files. This has been used only for
educational purposes. This content is under the sole ownership of Blizzard Entertainment.
And lastly I would like to thank my parents for supporting my goals and encouraging me to excel
in my field.
3
CONTENTS
Chapter 1: Introduction................................................................................................ 9
1.1 Background............................................................................................................. 9
1.2 Aim of the project................................................................................................. 10
1.2.1 Research question ........................................................................................................... 10
1.3 Project significance............................................................................................... 10
1.4 Objectives.............................................................................................................. 11
1.5 Structure of dissertation ...................................................................................... 12
Chapter 2: Games using Item Generation Mechanics .............................................. 13
2.1 Diablo..................................................................................................................... 13
2.1.1 The Drop Process............................................................................................................ 15
2.2 Diablo 2.................................................................................................................. 16
2.3 Fate......................................................................................................................... 17
2.4 Torchlight.............................................................................................................. 19
2.5 Dragon Age and Dragon Age 2............................................................................ 20
Chapter 3: Literature Review ..................................................................................... 22
3.1 Randomized Algorithm........................................................................................ 22
3.2 Markov Chain Processes...................................................................................... 23
3.2.1 Markov Chains................................................................................................................ 23
3.2.2 Markov Process .............................................................................................................. 24
3.3 Monte-Carlo Method............................................................................................ 26
3.3.1 Defining Characteristics ................................................................................................. 27
3.3.2 Types of Monte-Carlo Algorithms.................................................................................. 27
3.4 Las Vegas Algorithm............................................................................................ 30
3.4.1 Relation to Monte-Carlo Algorithm................................................................................ 30
3.5 Rule-Based Random Algorithm .......................................................................... 31
3.5.1 Rules ............................................................................................................................... 31
3.5.2 Probability Space............................................................................................................ 31
3.5.3 Practical Application....................................................................................................... 32
Chapter 4: Methodolgy ............................................................................................... 33
4.1 Approach............................................................................................................... 33
4.2 Rule-Based Random Algorithm .......................................................................... 33
4.2.1 Game Parameters............................................................................................................ 34
4.2.2 Defining Rules................................................................................................................ 35
4.2.2.1 Application Design.............................................................................36
4.2.3 Input Attributes............................................................................................................... 37
4.2.4 User Interface and World Environment .......................................................................... 38
4.2.5 Testing Scenario: (Arrow keys to move and Space bar to interact with chests)..............38
4.2.6 Application Screenshots ................................................................................................. 39
4.2.6.1 Inputs ..............................................................................................39
4.2.6.2 Initial Scene ......................................................................................39
4.2.6.3 Mode 1.............................................................................................39
4
4.2.6.4 Mode 2.............................................................................................40
4.2.7 Limitations...................................................................................................................... 40
4.3 Completely Randomized Algorithm ................................................................... 40
Chapter 5: Evaluation and Results ............................................................................ 41
5.1 Testing Approach ................................................................................................. 41
5.1.1 Testing Parameters.......................................................................................................... 41
5.2 Results.................................................................................................................... 42
5.3 Analysis.................................................................................................................. 44
5.3.1 Item Effects Chart........................................................................................................... 44
5.3.1.1 Item Quality (Rule 5) ..........................................................................44
5.3.1.2 Number of Effects (Quantitative) (Rule 3 and Rule 4) ...............................44
5.3.1.3 Item Effect Charts ..............................................................................45
5.3.2 Error Chart...................................................................................................................... 46
5.3.2.1 Level Check (Rule 1 and Rule 2)...........................................................46
5.3.2.2 Requirement Check (Rule 9 and Rule 10)................................................47
5.3.2.3 Effects Check (Rule 6, Rule 7 and Rule 8) ..............................................47
5.3.2.4 Final Error Check...............................................................................48
5.3.2.5 Error Charts ......................................................................................49
5.3.3 Final Error Table............................................................................................................. 50
5.3.4 Complete Analysis.......................................................................................................... 50
Chapter 6: Conclusion and Future Work.................................................................. 51
6.1 Conclusion............................................................................................................. 51
6.2 Unimplemented Ideas........................................................................................... 52
6.3 Future Work ......................................................................................................... 53
References and Bibliography...................................................................................... 54
Appendix A: Betrand’s Paradox................................................................................. 56
Appendix B: Simpson’s Paradox................................................................................ 57
Appendix C: Short Explainations of Drop Process................................................... 58
Appendix D: Results Tables........................................................................................ 59
Appendix E: Analysis Charts...................................................................................... 60
Appendix F: Code Segments....................................................................................... 75
Appendix G: Questiannaire........................................................................................ 80
5
List of Tables
Table 4.1: Game Parameters Table....................................................................................... 34
Table 4.2: Rules Table.......................................................................................................... 36
Table 4.3: Input Attributes Table.......................................................................................... 37
Table 5.1: Results from ExcelReport.xls after structuring into a Table............................... 42
Table 5.2: Results from ExcelReport.xls contd. ................................................................... 42
Table 5.3: Item Quality Formula........................................................................................... 44
Table 5.4: Number of Effects (Quantitative) Formula.......................................................... 44
Table 5.5: Level Check Formula........................................................................................... 46
Table 5.6: Requirement Check Formula................................................................................47
Table 5.7: Effects Check Formula......................................................................................... 48
Table 5.8: Final Error Check Formula...................................................................................48
Table 5.9: Table of Errors between the two Modes...............................................................50
Table B.1: Example for Simpson‟s Paradox..........................................................................57
Table D.1: Completely Random Algorithm (Mode 1) Items................................................ 59
Table D.2: Rule-based Random Algorithm (Mode 2) Items................................................. 59
Table E.1: Item Type Classification...................................................................................... 74
6
List of Figures
Figure 2.1: Diablo Final Boss Fight.......................................................................................13
Figure 2.2: Diablo, Beta, PR-Demo and Hellfire Items.........................................................14
Figure 2.3: Diablo, Beta, PR-Demo and Hellfire Items.........................................................14
Figure 2.4: Diablo 2 - Diablo Boss Fight...............................................................................16
Figure 2.5: Items in Diablo 2 and the gambling window from a Merchant...........................17
Figure 2.6: Items in Diablo 2 and the gambling window from a Merchant...........................17
Figure 2.7: Final Boss battle in Fate......................................................................................18
Figure 2.8: Items in Fate........................................................................................................18
Figure 2.9: Boss Fight in Torchlight......................................................................................19
Figure 2.10: Dragon Age 1 ................................................................................................... 20
Figure 2.11: Dragon Age 2 ................................................................................................... 20
Figure 2.12: Inventory and items in DA: Origins..................................................................21
Figure 2.13: Inventory and items in DA2............................................................................. 21
Figure 3.1: Monte-Carlo Method: n = 3,000......................................................................... 26
Figure 3.2: Monte-Carlo Method: n= 12,000........................................................................ 26
Figure 3.3: Monte-Carlo Method: n = 21,000....................................................................... 26
Figure 3.4: Monte-Carlo Method: n= 30,000........................................................................ 26
Figure 3.5: Acceptance-Rejection Monte Carlo method....................................................... 28
Figure 3.6: Stratified Sampling Monte Carlo method........................................................... 29
Figure 3.7: Importance Sampling Monte Carlo method........................................................ 29
Figure 4.1: Model of a Rule based random algorithm...........................................................33
Figure 4.2: Player entering the inputs...................................................................................39
Figure 4.3: Player entering the inputs....................................................................................39
Figure 4.4: Player investigating a room with chests..............................................................39
Figure 4.5: Player investigating a room with chests..............................................................39
Figure 4.6: Opening chest 2 in Mode 1................................................................................. 39
Figure 4.7: Opening chest 4 in Mode 1................................................................................. 39
Figure 4.8: Opening chest 7 in Mode 2................................................................................. 40
Figure 4.9: Opening chest 10 in Mode 2............................................................................... 40
7
Figure 5.1: Results from TestCases.txt..................................................................................43
Figure 5.2: Chart 1 - Item Effect Chart for Chest 1 using Mode 1........................................45
Figure 5.3: Chart 2 – Item Effect Chart for Chest 1 using Mode 2....................................... 45
Figure 5.4: Chart 3 – Error Chart for Chest 1 using Mode 1.................................................49
Figure 5.5: Chart 4 – Error Chart for Chest 1 using Mode 2.................................................49
Figure A.1: Three ways of choosing a chord.........................................................................56
Figure E.1: Item Effect Chart for chests 1 using Mode 1...................................................... 60
Figure E.2: Item Effect Chart for chests 2 using Mode 1...................................................... 60
Figure E.3: Item Effect Chart for chests 3 using Mode 1...................................................... 60
Figure E.4: Item Effect Chart for chests 4 using Mode 1...................................................... 61
Figure E.5: Item Effect Chart for chests 5 using Mode 1......................................................61
Figure E.6: Item Effect Chart for chests 6 using Mode 1...................................................... 61
Figure E.7: Item Effect Chart for chests 7 using Mode 1..................................................... 62
Figure E.8: Item Effect Chart for chests 8 using Mode 1...................................................... 62
Figure E.9: Item Effect Chart for chests 9 using Mode 1...................................................... 62
Figure E.10: Item Effect Chart for chest 10 using Mode 1....................................................63
Figure E.11: Item Effect Chart for chests 1 using Mode 2....................................................63
Figure E.12: Item Effect Chart for chests 2 using Mode 2....................................................63
Figure E.13: Item Effect Chart for chests 3 using Mode 2....................................................64
Figure E.14: Item Effect Chart for chests 4 using Mode 2....................................................64
Figure E.15: Item Effect Chart for chests 5 using Mode 2....................................................64
Figure E.16: Item Effect Chart for chests 6 using Mode 2....................................................65
Figure E.17: Item Effect Chart for chests 7 using Mode 2....................................................65
Figure E.18: Item Effect Chart for chests 8 using Mode 2....................................................65
Figure E.19: Item Effect Chart for chests 9 using Mode 2....................................................66
Figure E.20: Item Effect Chart for chests 10 using Mode 2..................................................66
Figure E.21: Error Chart for chests 1 using Mode 1............................................................. 67
Figure E.22: Error Chart for chests 2 using Mode 1............................................................. 67
Figure E.23: Error Chart for chests 3 using Mode 1............................................................. 67
Figure E.24: Error Chart for chests 4 using Mode 1............................................................. 68
Figure E.25: Error Chart for chests 5 using Mode 1............................................................. 68
Figure E.26: Error Chart for chests 6 using Mode 1............................................................. 68
8
Figure E.27: Error Chart for chests 7 using Mode 1..............................................................69
Figure E.28: Error Chart for chests 8 using Mode 1..............................................................69
Figure E.29: Error Chart for chests 9 using Mode 1..............................................................69
Figure E.30: Error Chart for chest 10 using Mode 1............................................................. 70
Figure E.31: Error Chart for chests 1 using Mode 2..............................................................70
Figure E.32: Error Chart for chests 2 using Mode 2..............................................................70
Figure E.33: Error Chart for chests 3 using Mode 2..............................................................71
Figure E.34: Error Chart for chests 4 using Mode 2..............................................................71
Figure E.35: Error Chart for chests 5 using Mode 2..............................................................71
Figure E.36: Error Chart for chests 6 using Mode 2..............................................................72
Figure E.37: Error Chart for chests 7 using Mode 2..............................................................72
Figure E.38: Error Chart for chests 8 using Mode 2..............................................................72
Figure E.39: Error Chart for chests 9 using Mode 2..............................................................73
Figure E.40: Error Chart for chests 10 using Mode 2............................................................73
9
- Chapter 1 -
Introduction
1.1 Background
Role-playing games (RPG) were invented as a pen-and-paper story based game. Their popularity
with certain people skyrocketed due to the amount of detail in the layout, plot and story that lets
them completely immerse in the game. A fantasy world where you could slay your enemies,
become a knight or a wizard and rescue a princess sounds magical and unreal. That was the point
of such games; experience the impossible.
However it wasn‟t too long for them to catch up with technology and make video based role
playing games, where you don‟t have to rely on your imagination so much anymore. The
interactive game lets you see and hear the world around you on your computer. The game lets
you collect loot and customize your character to your liking. You could learn spells and become
a mage or learn to fight with a sword and become a warrior. This lets you relate with the
character as you can choose from many available options to your liking.
Out of the many game mechanics introduced in this genre, there was one mechanic that was an
instant success; collecting loot for your character. Loot refers to weapons, armour, spells, books
and other rare artefacts. They are usually dropped from a slain enemy or as a reward for
completing a task. But to keep the excitement in the game, loot could be found in almost any
kind of storage like chests scattered around the world. This gives the player an incentive to
explore the map to find such rare chests. But since an important aspect of these games is the
replay ability of the game, it seemed uninteresting to always find the same loot from the same
sources every time you play the game. This led to the invention of randomized algorithms to
generate the loot while playing the game also known as item generation mechanics.
While exploring a few randomized algorithms, this project will describe them and help to decide
which one would be suitable for an item generation mechanic.
10
1.2 Aim of the Project
The aim of this project is to build and analyze the significance of a suitable item drop mechanic
using a rule-based randomization algorithm for improving game play value in role playing
games.
1.2.1 Research Question
What is the need for rules or constraints in a randomized algorithm for any item generation
mechanic in role playing games?
1.3 Project Significance
This project will shed light to the approach behind the item generation mechanic used in role
playing games and to analyze which rules or constraints are suitable to enforce to have a
meaningful yet unpredictable randomized item generation mechanic.
The qualitative and quantitative significance of this research when implemented in a game will
include:
 Increased game play value
 Longer shelf life of the game due to increased play time
 More value for money
 Ease to implement an expansion pack to the game mechanic.
The expected outcome of this project is to evaluate the importance of the randomized mechanic
for item generation by testing the research application with some participants by conducting a
blind test where they are expected to test two algorithms; a rule based randomized algorithm and
a completely randomized algorithm without knowing which ones they are testing. Their honest
feedback will be collected and analyzed. For the purpose of extensive testing of the mechanic, it
will also have an automated testing tool to collect large amounts of data quickly.
11
1.4 Objectives
1. Conduct research on existing randomized algorithms and determine their effectiveness
for item drop mechanics.
2. Game mechanics like item drops in RPG use a certain amount of randomness to create a
feeling of uncertainness in the game. This project will research and experiment with the
level of constraints/rules that need to be applied to the random factor in order to make the
game play realistic and improve its replay value for these mechanics.
3. To develop a prototype application that will implement the following game mechanics:
Item drops from chests using a rule based randomized algorithm and the following
constraints will be tested in it experimentally:
a. Level Based Constraints: Both the player and chest levels are factors for the
level of the item being dropped and the individual item effects as well.
b. Class Type Constraints: Specific item drops based on the player‟s class type.
c. Magic Find Percentage: Chance of finding a better item also depends on the
Magic find percentage of the player and the chest.
d. Item Level Constraint: Based on the level of the item, specific effects can be
applied and the values of the effects are affected.
e. Item Requirements Constraints: Every item will have certain requirements
needed to equip them. These requirements will be calculated from the items level.
f. Item Type Constraints: Based on the type of the item, specific effects can be
applied to the item.
4. The experimental analysis would be conducted after the application generates a report of
200 simulated players in an excel sheet. The output of the analysis will be graphical
tables and charts. The application will also be tested by a few participants who will test
the game mechanics with and without the constraints enabled. They would then have to
complete a questionnaire which will ask them they‟re feedback and to rate each
mechanic.
12
5. A conclusion will be drawn from the result of this analysis and will be presented. The
possibility of future work on this topic will be discussed as well as the current trends to
this mechanic.
1.5 Structure of dissertation
The background review for this dissertation is broken up in to two chapters: Chapter 2: Games
using Item Generation Mechanics and Chapter 3: Literature Review. Following chapters will be
Methodology, Analyses and Result, and the final chapter will contain Conclusion and Future
Work which will conclude the dissertation and list possible future work in the area. There will be
Appendices at the end to elaborate on key points throughout the dissertation.
13
- Chapter 2 -
GAMES USING ITEM GENERATION MECHANICS
Ever since role playing video games were invented, players always had the ability to customize
their characters to make them more interesting or powerful. Whether that involved equipping
various kinds of armour, weapons or managing skills, depended on the game. Listed below are a
few games that have over time proved that the item generation mechanic has become crucial to
customizing a playable character.
2.1 Diablo:
One of the most famous games ever made which uses the item generation mechanic is Diablo
developed by Blizzard North in 1996 (Blizzard, 1996).
Figure 2.1: Diablo Final Boss Fight
This game introduced the concept of generating random levels each time you play the game as
well as randomized loot from chests and monsters. Ever since then, game developers have been
trying to recreate their success in role playing games by improving their randomization
14
algorithms for various game mechanics like items, monster and map generations. Diablo:
Hellfire was an official expansion pack to this game made by Sierra On-Line with more items,
characters and quests.
Game designers have always wanted to introduce newer features that could use randomized
algorithms to enhance the game play and so they have. The game Fate by WildTangent for
instance allows the player to fish from a pond. There is a chance the player could find a special
item inside the fish. Another game called Torchlight by Runic Games has an open ended system
where certain non-playing characters can generate random quests based on the level of the
player.
Arsenault has described in his research abstract about its success. “Diablo provides a wonderful
example of how successful a game can be, even without emergence. Do the three different
character classes and 26 spells, along with the 31 armour pieces and 39 weapons – each one
possibly enchanted with one or two of the 285 possible magical effects – provide an emergent
game-play system? But in truth, there is very little difference between playing a Sorcerer
attacking his enemies with a Venom Quarterstaff of the Bat, and playing a Warrior attacking his
enemies with a Soldier‟s Long Sword of Thunder. Sorcerers can wear plate mails and wield
heavy axes, Warriors can cast advanced spells, and Rogues can have their weapons repaired at
the blacksmith” (Arsenault, 2005).
Figure 2.2 and 2.3: Diablo, Beta, PR-Demo and Hellfire Items (Kronika, 2009)
15
So he asks “Why is Diablo successful? As the player goes deeper in the labyrinth, he faces
increasingly challenging monsters, and gets to buy and find increasingly stronger equipment. The
carefully-crafted balance makes the game addicting: the player is always fairly challenged, yet
never over-powered. The success of Diablo is due to the fact that a progression-based game-play
system matches the linear, pre-written story of an adventurer descending deeper in a dungeon to
defeat the evil Lord of Terror” (Arsenault, 2005). Somewhere down the line, the player gets
addicted to hoarding and perfecting his arsenal of weapons and armour. This single game play
mechanic can cause the player to play the game for hours on end. The game also re-spawns slain
monsters and bosses which allows the players to hunt them down again in order to get more
items. In this context this is called „item farming‟. Playing on Battle.net allowed up to 4 players
to play in a single game which increasing both the number of monsters to kill and their difficulty
levels. This in turn also increases the chance to get better rewards from them too.
2.1.1 The Drop Process:
So what actually happens when you kill a boss in Diablo? An algorithm or a sequence of
operations is performed to create and drop one or more items. Flux from DiabloWiki.net has
described the steps that are performed (Flux, Dec, 2008). The algorithm:
1. Calculates the number of items to drop
2. Selects the item types
3. Selects the item qualities
4. Based on chance selects certain unique items
5. Selects item properties based on prefixes and suffixes
6. Generates names for the items
7. Drops them as Unidentified items
Please see Appendix-C for a detailed explanation of this process described by Flux.
16
2.2 Diablo 2:
This sequel to Diablo has a further in-depth story line and a game play framework that has
reused a lot of the mechanics from the first but also introduced many new ones. The random
algorithms for generating maps, monsters and items were back, but now there were some distinct
rules applied to the game which made it very distinguishable. For instance, five distinct classes
were created with different abilities and spells. This meant that the player has to have a different
strategy for each character class that he plays as since each class has its own strengths and
weaknesses. They also designed class specific items and effects so that customisation of the
player became more unique. This introduced a whole new dimension to item farming, where in
class specific items would be better off traded to other players who might need them.
Figure 2.4: Diablo 2 - Diablo Boss Fight
In Diablo 2 Blizzard introduced a new classification of Item quality called Set Items, which are a
collection of items when equipped with their matching set gives additional bonus effects to the
player. The chance to find such items is the same as for unique items. This concept yet again
affected the way a player would want to item farm because now they are collecting set item parts
by storing them in the limited storage chest in town while trying to find their matching sets.
17
Figure 2.5 and 2.6: Items in Diablo 2 and the gambling window from a Merchant (Krakou, 2003)
The drop process remains the same for Diablo 2; however the decision to drop a set item is
calculated the same time when the algorithm is choosing a unique item. They even introduced a
merchant NPC in every town that will “Gamble” with the player for the chance to buy a
rareuniqueset item for a low price. Blizzard released the expansion for Diablo 2 called Lord of
Destruction in June of 2001. Besides expanding the item database they also introduced
2.3 Fate:
Here is another example of an RPG that specializes in randomized dungeon crawler and quest
based mechanics. The Fate series by WildTangent includes Fate, Fate: Undiscovered Realms,
Fate: The Traitor Soul and their latest instalment Fate: The Cursed King. They revolve around
the player accepting a main quest to slay a random boss monster on a dungeon level somewhere
below the ground. Along the way the player can pick up random quests from NPC and on
successfully completing those missions they can claim their reward.
18
Figure 2.7: Final Boss battle in Fate
Having been closely designed to Diablo 2, it uses a lot of the same mechanics including
randomized map generation, item generation, melee and spell casting fighting mechanics.
However randomized algorithms for quest and reward generation were newly introduced. The
order or the number of quests undertaken is not important, but just the level of the player for that
quest since it is based on the level that the quest is generated.
Figure 2.8: Items in Fate
19
The items were generated the same way as in Diablo (refer Appendix- C). The chance to find
magic item increases based on the characters level and by equipping items that enhance that
property. The enemy or chests level is also a factor in the quality of the item being generated.
The developers also created the gambling system similar to Diablo‟s merchant gamble for rare or
unique items. They did however introduce a new concept for finding items by fishing. Even
though the chances of finding a usable item are low this way, it does give you an alternate way to
get items without killing monsters and the item obtained this way are pretty rare also.
2.4 Torchlight:
Torchlight is an action role playing game made by Runic Games and released in 2009 which also
follows in the footsteps of Diablo. The development of this game was led by Travis Baldree,
designer of Fate and joined by Max Schaefer and Erich Schaefer Co-designers of Diablo and
Diablo 2. Unlike Fate this game had direction and plots much like the original features of Diablo.
However they did port over the Fate mechanic for randomized side quest and reward generation.
Figure 2.9: Boss Fight in Torchlight
20
Besides having a smooth game play, Torchlight had amazing graphics and artwork to
compliment its randomized dungeons and caverns. The game was built to be capable of running
on almost any computer adjusting the effects if necessary.
It had three character classes each having their own equipment types but not restricting any on
the others. The game had random algorithms for map, quest, item, monster and reward
generations etc. It had normal, magical, rare, unique and set items. Besides that every item had
various grade levels based on the item level.
2.5 Dragon Age (DA) and Dragon Age 2 (DA2):
Here is a game franchise that revolutionized role playing games. Dragon Age was designed to
capture the sense of the player and make him feel he is in the fantasy world of Fereldan. Even
though the random algorithms were only implemented to item and enemy generation mechanics,
they did introduce complex rule based algorithms for dialog selection and decision making,
which had consequences in the game itself.
Figure 2.10 and 2.11: Dragon Age 1 and 2
This game introduced a complex structure of dialogues to affect the choices of the player and
thereby affecting the outcome of the game. This creates another dimension of uncertainty to the
game. So now the players must ask “How will my decision affect the outcome?” Rewards,
Quests, Friendships and rivalries with characters or the storyline itself can be affected as a result
of this.
21
This game differs from the examples mentioned above in terms of randomness. Most rare or
unique items in the game are defined to drop from certain bosses or chest or even bought from
certain merchants. This means that no matter how many times you play the game or in any
scenario, the player will still receive those items. So even though this game doesn‟t have a
completely random item generation algorithm, it still appears to be random. This is due to the
rules by which the game is governed which have been carefully chosen. The official expansion
pack to Dragon Age (DA) was DA: Origins, which took off with a new story line and mission,
with new companions and a lot more loot to collect.
Figure 2.12 and 2.13: Inventory and items in DA: Origins and DA2
A blog post by hijo_del_escorpion on IGN.com describes his take on the item and inventory
system in DA 2. “The item and inventory system suffered some improvements. It is very similar
to DA: O but a little friendlier. The developers even decided to help new RPG players by
providing a star rating system for equip able items so as to make it easier to identify when some
piece of armour or ring you acquired may upgrade what your characters already have equipped.
My advice is to be careful with these star systems, because they can be very inaccurate especially
with the jewellery items. In normal this is fine, but in higher difficulties these stat boosts can be
the difference between victory and kicking the bucket. I found that the overall stats of a unique
item rated with zero stars was more desirable than another item rated with five stars, although
that ultimately depends on the characters strengths and weaknesses. But for newer players it
might be a nice thing to have.” (hijo_del_escorpion, 2011)
22
- Chapter 3 -
Literature Review
Unpredictability has always been a curious phenomenon to humans, since there always exist an
element of surprise with it. A procedural algorithm always has a predefined outcome because
they are designed to perform a certain task a certain way. In order to create unpredictability a
random element must be introduced to the algorithm. These algorithms are called randomized
algorithms and a few relevant ones are described below.
3.1 Randomized Algorithm
A randomized algorithm is a set of instructions that uses a random factor to compute and get an
unpredictable output. Using the same randomized algorithm, if different computers keep getting
the same output, is it truly random? Computers are in principle deterministic machines and
should not exhibit random behaviour (Cleve, Feb 2008). So to mimic random behaviour, the
algorithm must use a truly unpredictable input and process it to generate the random outcome.
There have been many randomized algorithms created for the purpose of unpredictability or
uncertainty. The multiplicative congruential algorithm which is the basis for many of the random
number generations in use today was invented by Berkeley professor D. H. Lehmer a pioneer in
computing and especially computational number theory. Lehmer's number generator algorithms
involve three integer parameters, a, c, and m, and an initial value, x0, called the seed (Cleve, Feb
2008). The series can be calculated by using the formula:
xk+1 = axk + c mod m:
where k>0 and xk is the current number
and xk+1 is the next number to be calculated
Randomized algorithms have also been developed for creating Artificial Intelligence due to the
nature of their unpredictable outcome. An example of this is Markov chain. In 1907, A. A.
Markov began the study of an important new type of chance process. In this process, the
23
outcome of a given experiment can affect the outcome of the next experiment. This type of
process is called a Markov chain (Virginia, Aug 2006).
Another type of randomized algorithm is the Monte Carlo algorithm. These algorithms have a
deterministic running time but whose output may be incorrect with a small amount of
probability. The name refers to the grand casino in the Principality of Monaco at Monte Carlo,
which is well-known around the world as an icon of gambling (Max Libbrecht, Sept 2011).
A variant of the Monte Carlo algorithm is the Las Vegas Algorithm. It is also randomized, but in
a different way. They take an amount of time that varies randomly, but always produce the
correct answer. A Monte Carlo algorithm can be converted into a Las Vegas algorithm whenever
there exists a procedure to verify that the output produced by the algorithm is indeed correct. If
so, then the resulting Las Vegas algorithm is merely to repeatedly run the Monte Carlo algorithm
until one of the runs produces an output that can be verified to be correct (Max Libbrecht, Sept
2011).
3.2 Markov Chain processes
Important classes of stochastic processes are Markov chains and Markov processes. A Markov
chain is a discrete-time process for which the future behaviour given the past and the present
only depends on the present and not the past. A Markov process is the continuous-time version
of a Markov chain. Markov chain and Markov processes focuses on these characteristics that are
needed for the modelling and analysis of queuing problems (Buzacott & Shanthikumar, 1993).
3.2.1 Markov chains:
A Markov chain is characterized by a set of states S and the transition probabilities pij between
the states. Here, pij is the probability that the Markov chain is at the next time point in state j,
given that it is at the present time point at state i. The matrix P with elements pij is called the
transition probability matrix of the Markov chain. Note that the definition of the pij implies that
the row sums of P are equal to 1. Under the conditions that
24
 All states of the Markov chain communicate with each other (i.e., it is possible to go from
each state, possibly in more than one step, to every other state),
 The Markov chain is not periodic (a periodic Markov chain is a chain in which, e.g., you
can only return to a state in an even number of steps),
 The Markov chain does not drift away to infinity,
the probability pi(n) that the system is in state i at time point n converges to a limit in as n tends
to infinity. These limiting probabilities, or equilibrium probabilities, can be computed from a set
of so-called balance equations. The balance equations balance the probability of leaving and
entering a state in equilibrium. This leads to the equations
∑ ∑
Or
∑
where
In vector-matrix notation this becomes, with π the row vector with elements πi,
Together with the normalized equation
∑
The solution of the set of equations above is unique (Buzacott & Shanthikumar, 1993).
3.2.2 Markov processes:
In a Markov process we also have a discrete set of state S. However, the transition behaviour is
different from that in a Markov chain. In each state there are a number of possible events that can
cause a transition. The event that causes a transition from state i to j, where j ≠ i, takes place after
an exponential amount of time, say with parameter qij. As a result, in this model transitions take
place at random points in time. According to the properties of exponential random variables we
have:
 In state i, a transition takes place after an exponential amount of time with parameter
∑j≠iqij.
 The system makes a transition to state j with probability
25
∑
Define
∑
The matrix Q with elements qij is called the generator of the Markov process. Note that the
definition of the qii implies that the row sums of Q are 0. Under the conditions that:
 All states of the Markov process communicate with each other,
 The Markov process does not drift away to infinity,
the probability pi(t) that the system is in state i at time t converges to a limit pi as t tends to
infinity. Note that, different from the case of a discrete time Markov chain, we do not have to
worry about periodicity. The randomness of the time the system spends in each state guarantees
that the probability pi(t) converges to the limit pi.
The limiting probabilities, or equilibrium probabilities, can again be computed from the balance
equations. The balance equations now balance the flow out of a state and the flow into that state.
The flow is the mean number of transitions per time unit. If the system is in state i, then events
that cause the system to make a transition to state j occur with a frequency or rate qij . So the
mean number of transitions per time unit from i to j is equal to piqij. This leads to the balance
equations:
∑ ∑
Or
∑
In vector-matrix notation this becomes, with p the row vector with elements pi,
Together with the normalization equation
∑
The solution of the set of equations above is unique (Buzacott & Shanthikumar, 1993).
26
3.3 Monte-Carlo method
Monte-Carlo methods are a class of computational algorithms that rely on repeated random
sampling to compute their results. They are often used in computer simulations of physical and
mathematical systems. These methods are most suited to calculation by a computer and tend to
be used when it is infeasible to compute an exact result with a deterministic algorithm. They are
especially useful for simulated systems with many coupled degrees of freedom, such as fluids,
disoriented materials, strongly coupled solids and cellular structures (Wikipedia, Nov 2011).
Figure 3.1 and 3.2: Monte-Carlo Method: n = 3,000, n=12,000
Figure 3.3 and 3.4: Monte-Carlo Method: n=21,000 and n=30,000
27
The above example shows how random samples within the limits (1.0, 1.0) can be calculated
with the function to determine if they lie within the function curve or outside. This can be
interpreted as meaningful data. Terrain generation, fluid mechanics, particle effects and other
similar mechanics can be implemented using this type of algorithm.
As stated by Pengelly, Monte Carlo methods provide approximate solutions to a variety of
mathematical problems by performing statistical sampling experiments. They can be loosely
defined as statistical simulation methods, where statistical simulation is defined in quite general
terms to be any method that utilizes sequences of random numbers to perform the simulation.
Thus Monte Carlo methods are a collection of different methods that all basically perform the
same process. This process involves performing many simulations using random numbers and
probability to get an approximation of the answer to the problem (Pengelly, Feb 2002).
3.3.1 Defining Characteristics:
 Use of random numbers in its simulations
 It can provide an approximate answer quickly
 It only provides an approximation of the answer.
 The more simulations performed, the more accurate the approximation is.
3.3.2 Types of Monte Carlo Algorithms:
1. Crude Monte Carlo:
For N random samples we take the summation of their function values and divide by
N to get the mean value of the samples, then multiply it with the interval (b-a) to get
the integral.
∑ Where (a, b) is the approximate limits of the sample x
N is the number of random samples taken for one output.
The next step is to calculate the accuracy of the approximate output (I) otherwise the
answer will not be meaningful without a description of its uncertainty (Pengelly, Feb
2002).
28
2. Acceptance – Rejection Monte Carlo:
This algorithm uses the same formula used in Crude Monte Carlo. In the (a, b)
interval for any given value of x the function you must find the upper limit. You then
enclose this interval with a rectangle that is high enough to be above the upper limit,
so we can be sure that the entire function for this interval is within the rectangle. We
now begin taking random points within the rectangle and evaluate this point to see if
it is below the curve or not. If the random point is below the curve then it is treated as
a successful sample. Thus, you take N random points and perform this check,
remembering to keep count of the number of successful samples there have been.
Now, once you have finished sampling, you can approximate the integral for the
interval (a, b) by finding the area of the surrounding rectangle. You then multiply this
area by the number of successful samples over the total number of samples, and this
will give you an approximation of the integral for the interval (a, b) (Pengelly, Feb
2002).
Figure 3.5: Acceptance-Rejection Monte Carlo method
3. Stratified Sampling:
The basic principle of this technique is to divide the interval (a, b) up into
subintervals. You then perform a crude Monte Carlo approximation on each
subinterval. You can find the variance by adding up the variances of each subinterval.
This method could be well suited for a function that is step-like or that has periods of
flat. This is because if you did an integration of a sub-interval that was very flat then
you are going to get a very small variance value. Thus the advantage of the Stratified
29
Sampling method is that you get to split the curve into parts that could have certain
advantageous properties when evaluating them on their own.
Figure 3.6: Stratified Sampling Monte Carlo method. Function interval (a, b) is divided into four
equal sized intervals – (I1, I2, I3, I4).
∫ ∫ ∫ ∫ ∫
Note that this equation is when the interval (a, b) has been broken into four sub-
intervals (a, c), (c, d), (d, e) and (e, b) (Pengelly, Feb 2002).
4. Importance Sampling:
In this method we define the integral equation as the following because they are
equal:
∫ ∫
where p(x) is the probability distribution factor.
Figure 3.7: Importance Sampling Monte Carlo method. This graph shows both f(x) and the
probability distribution function p(x).
The integral of p(x) over (a, b) is always equal to 1 and that for no value of x within
the interval (a, b) will p(x) evaluate to 0. So the question arises, what is the purpose
of introducing p(x) in the equation. Well, we can use it so that when we take samples
30
of the curve f(x) within the interval (a, b), we can make the choices taking into
account the probability of that particular sample getting selected.
For example, according to the example graph about half of the probability curve area
is in the last quarter of the interval (a, b). Therefore, when we choose samples we
should do it in a way so that half of the samples get taken from this area of the
interval (Pengelly, Feb 2002).
3.4 Las Vegas algorithm:
A Las Vegas algorithm is a randomized algorithm that always gives correct results. That is, it
always produces the correct result or it informs about the failure. In other words, a Las Vegas
algorithm does not gamble with the verity of the result; it gambles only with the resources used
for the computation. A simple example is randomized quick sort, where the pivot is chosen
randomly, but the result is always sorted. The usual definition of a Las Vegas algorithm includes
the restriction that the expected run time always will be finite, when the expectation is carried
out over the space of random information used in the algorithm.
Las Vegas algorithms were introduced by László Babai in 1979, in the context of the graph
isomorphism problem, as a stronger version of Monte Carlo algorithms. Las Vegas algorithms
can be used in situations where the number of possible solutions is relatively limited, and where
verifying the correctness of a candidate solution is relatively easy while actually calculating the
solution is complex (Wikipedia, 2011).
3.4.1 Relation to Monte Carlo algorithm:
Las Vegas algorithms can be contrasted with Monte Carlo algorithms, in which the resources
used are bounded but the answer is not guaranteed to be correct 100% of the time. By an
application of Markov's inequality, a Las Vegas algorithm can be converted into a Monte Carlo
algorithm via early termination (Wikipedia, 2011).
31
3.5 Rule-based Random Algorithm
They are a classification of Random Algorithms that uses a probability function which is limited
to boundary conditions or rules in order to restrict the sample set for the probability function to
certain domains. These algorithms use input data with a pre-defined set of rules or conditions to
influence the outcome of the probability function. We explain that the key idea is to associate a
likelihood, which we call probability, to sets of outcomes, not to individual outcomes. These sets
are events. The description of the events and of their probability constitutes a probability space
that characterizes completely a random experiment (Walrand, August 25, 2004).
3.5.1 Rules:
A predefined set of rules usually govern this algorithm which creates the sample space for the
probability function. They are carefully chosen so that we increase the chances of getting the
output more suitable to their inputs. The important questions to be asked while deciding the rules
are:
 Which input/s is/are to be considered?
 How will the chosen inputs affect the probability function?
 How many rules are required for one probability function?
 Do the chosen rules accurately limit the sample space for the probability function?
When random samples are chosen from the sample space, the meaning associated with the inputs
and the output is coherent as opposed to complete randomness. The likelihood of obtaining an
unwanted outcome is diminished but at the same time it remains unpredictable.
3.5.2 Probability Space:
A probability space is a triplet {Ω, F, P} where
1. Ω is a nonempty set, called the sample space;
2. F is a collection of subsets of Ω closed under countable set operations. The elements
of F are called events;
3. P is a countable additive function from F into [0, 1] such that P(Ω) = 1, called a
probability measure.
32
The main point is that one defines the probability of sets of outcomes (the events). The
probability should be countable additive (to be continuous). Accordingly (to be able to write
down this property), and also quite intuitively, the collection of events should be closed under
countable set operations (Walrand, August 25, 2004).
Some care is required when defining what we mean by a random choice. See Bertrand's paradox
in Appendix-A for an illustration of a possible confusion. Another example of the possible
confusion with statistics is Simpson's paradox in Appendix-B.
3.5.3 Practical application:
This type of algorithm can be applied to many fields of science that require controlled
uncertainty like neural networks, search engine data collection, mapping of stars in astronomy,
etc. However in video games, it has a lot of practical usage also. Some of them include Terrain
generation, random map and quest generation, dialogue and behaviour patterns and most
importantly item generation.
33
- Chapter 4 -
METHODOLOGY
4.1 Approach:
The purpose of the application is to create the mechanics of Item generation in role playing
games. After conducting research on different randomized algorithms and in understanding how
they work, I decided to follow the best suited approach for this project: Rule-based randomized
algorithm. In comparison, Markov chain process requires learning from previous iterations and
the mechanics of Item generation does not require past learning in order to affect the outcome of
the next iteration. Monte Carlo algorithms however focuses on using complete random samples
from the sample set and later to verify if the output lies with the function curve. This approach
could be used, but will be less optimal since there is a chance that the output will be rejected.
The only condition the chosen algorithm has is that the mechanic should follow certain rules to
stay within the guidelines of the game to have any meaning which correlates to game play value.
This is explained in the following section.
4.2 Rule Based Random Algorithm:
As mentioned earlier, this algorithm processes three sets of data to generate the output:
 Dynamic: Input values to the algorithm
 Static: Rules defined in the algorithm
 Static/Dynamic: the Probability function which varies depending on usage
Figure 4.1: Model of a Rule based random algorithm
34
The above model shows how various sets of inputs (Y1, Y2, Y3, .. Yk) are used by the defining
rules or limiting factors (r1, r2, r3, .. rk) to create a sample space of possibilities and finally a
probability function (p(x1)) is applied on this sample space to generate a final output.
4.2.1 Game Parameters:
The following table describes the parameters of the game that will be used in the design and for
the analysis:
Parameter Obtained Description
Player Level Input The player level can be chosen anywhere between 1 and 100
Player stats:
Strength,
Dexterity and
Energy
Calculated The player stats and calculated using the player level for
ease of testing.
Player Class Input The playable class chosen from: Amazon, Assassin,
Barbarian, Druid, Necromancer, Paladin and Sorceress
Player Magic
Find
Input Player Magic find chance could be anywhere between 0 and
100%
Quality of
Items
Predefined White- Normal Items, Blue- Magical Items and Gold- Rare
Items
Chests Predefined There are 10 chests available each with a different chance to
find magic Item:
Chest 1 2 3 4 5 6 7 8 9 10
MF% 2% 4% 8% 16% 32% 64% 128% 256% 512% 1024%
Item Types Predefined There are Armour, Weapon and Class specific item types
created.
Item Level Calculated The items‟ level is used to determine the effects, number of
effects, quality of item, etc. (1 – 100)
Effects Generated There are Armour, Weapon, Class-specific and General
effects predefined. Based on Item types they are generated.
Effect Values Generated The values of the effects are calculated also based on the
item level.
Table 4.1: Game Parameters Table
35
4.2.2 Defining Rules:
Prof. Whitehead from UC Santa Cruz states in his lecture notes that “Games have rules that act
as limitations, as well as rules that create affordances. Rules provide the player with meaningful
actions and give the game a structure. Rules can be designed to give players either enjoyable or
negative experiences.” (Prof. Whitehead, January 2007)
Different kinds of rules may be applied to Item Generation mechanics. The following rules have
been chosen and designed in this application:
Rules Rule Description Required Inputs
Rule 1 Item level must be within +/- 5 of the Player level  Player Level
Rule 2
If Item level is greater than Player level, then item
cannot be equipped. (Red Label)
 Item Level,
 Player Level
Rule 3
Total chance to find magic item is the sum of Player
and Chest chance to find magic item
 Player chance to
find magic item,
 Chest chance to find
Magic item
Rule 4
Number of Effects is calculated using total chance to
find magic item (0 to 5)
 Total chance to find
magic item
Rule 5
Quality of the item is decided based on its number of
effects: 0 – Normal Item (white),
1 to 3 Magical Item (blue),
4 or 5 Rare Item (golden)
 Number of effects
Rule 6
Effects are generated based on item types and Total
Magic find chance:
Armour items types get Armour effects,
Weapon item types get Weapon effects,
Class specific items get class specific effects,
Any item type gets General effects also.
 Item type,
 Total chance to find
magic item
 Player Class
Rule 7 Effect value is calculated from the item level  Item level
Rule 8
General Item properties is calculated from item level:
Weapons: min and max damage
 Item level
36
Armours: defence
Rule 9
Item Requirements are calculated using Item type
and Item level:
Melee weapons: Strength (maybe Dexterity)
Ranged weapons: Dexterity
Magical weapons: Energy
Class specific items: Class specific requirements
 Item type,
 Item level
 Player Class
Rule 10
If Item requirements are not met by the players‟ stats
(Strength, Dexterity, Energy and Class), then item
cannot be equipped. (Red label)
 Item requirements,
 Player Strength,
 Dexterity,
 Energy and
 Player Class.
Table 4.2: Rules Table
The above rules were implemented in the game application for the purpose of testing the cases
and analyzing the outcomes with various trials. The game was designed keeping these rules in
mind.
4.2.2.1 Application Design:
The game application was built using DirectX 9.0c framework with a few models and textures
imported from external sources. The player model was obtained from the sample project
provided by Microsoft DirectX 9.0c (Microsoft, 2010) and the textures were obtained from
TurboSquid.com (TurboSquid, 2011). Sound was implemented by using a utility created by
(Ditchburn, 2011). The framework of the application was originally created by Prof. Frank Luna
for a course project (Prof. Luna, 2011), but was later modified to a reusable and efficient project
framework by me.
The entire effort in building this application was concentrated around implementing two modes
of operation: a Rule based Random algorithm and a complete randomization algorithm, and
implementing them in an Item generation mechanic. Finally in order to improve accuracy of
testing and analysis, a functionality was developed to simulate any number of players testing the
application and generate an excel sheet with the outcomes. This would be used later for the
analysis.
37
4.2.3 Input Attributes:
The input attributes to the algorithm are classified in the table below:
Input Attribute Range/Values Used by Rule Affected Outcome
Player Class
Amazon, Assassin,
Barbarian, Druid,
Paladin, Necromancer,
Sorceress
Rule 6, Rule 9,
Rule 10
Class specific item drops,
Class specific effects
Player Level 1 – 100 Rule 1, Rule 2 Item Level
Player Magic Find
Chance
0 – (no cap) % Rule 3 Total chance to find magic
item
Player Stats
Strength, Dexterity or
Energy: 0 – (no cap)
Rule 10 Whether item is equip able
Item Level
1 – 100 Rule 2, Rule 7,
Rule 8, Rule 9
Number of item effects and
quality of item effects,
Requirements of the item,
Values of the effects
Item Type
Weapon, Armour,
Class Specific or
General Items
Rule 6, Rule 9 Effects generated
Item Requirements
Strength, Dexterity or
Energy: 0 – (no cap)
Rule 10 Whether item is equip able
Number of item
effects
0 – 5 Rule 5 Quality of Item (Normal,
Magical, Rare)
Total chance to find
magic item
Player Magic Find
Chance% + Chest
Magic Find Chance%
Rule 4, Rule 6 Number of item effects and
Quality of item effects
Chest Magic Find
Chance
2 – 1024 % Rule 3 Total chance to find magic
item
- Input from Player - Calculated from input
- Fixed inputs in the
application
Table 4.3: Input Attributes Table
38
The player class, level and magic find percentage are inputs to the game application. The
players‟ stats, item level, item type and number of item effects are calculated based on the
players‟ inputs. The chest magic find chances are pre determined for each chest.
4.2.4 User Interface and World Environment:
The user interface was designed to relay information to the player in real time and request inputs
from the player at start-up or when requested for. This includes the players‟ name, class, level,
stats, chance to find magic item, the number of items collected, the chest that has been opened,
the chance to find magic item of the chest and the number of items in the chest as well as the
mode in which the player is testing the game. These messages will be displayed on the top of the
screen depending on the actions of the player.
There are 10 chests placed in a closed room. Each of the chests represents an item drop source
which could easily be replaced by a monster, a friend or a non playing character. The idea of the
research was to test the item drop mechanics which works the same for any of these sources. The
chests are labelled from one to ten and have an increasing chance to find magic item based on its
level. When the player approaches a chest and tries to open it, the name of the chest and its
details are displayed in the UI. On opening a chest an item is generated and displayed on screen
in an item description box with an icon of the item as well. The player can repeatedly open the
chest to collect more items until it becomes empty.
4.2.5 Testing Scenario: (Arrow keys to move and Space bar to interact with
chests)
1. Start the application and select the option for non-automated execution.
2. Input the players‟ name, class and level.
3. Move the player over to each of the 10 chests and open each 3 times to collect a total of
30 items.
4. Change the mode to Mode 2 and repeat step 3.
5. Mark your feedback on the questionnaire. (Refer Appendix - G)
39
4.2.6 Application Screenshots:
4.2.6.1 Inputs:
Figures 4.2 and 4.3: Player entering the inputs
4.2.6.2 Initial Scene:
Figures 4.4 and 4.5: Player investigating a room with chests
4.2.6.3 Mode 1:
Figures 4.6 and 4.7: Opening chest 2 and chest 4 in Mode 1
40
4.2.6.4 Mode 2:
Figure 4.8 and 4.9: Opening chest 7 and chest 10 in Mode 2
4.2.7 Limitations:
This game has been limited to only implement and test the two modes of item generation used in
this research: Completely Random Algorithm, and Rule-Based Random Algorithm. The two
modes will be used to show the contrast in approaches. Due to insufficient time and resources, it
was not feasible to implement other RPG mechanics like fighting, spells or dialogues.
4.3 Completely Randomized Algorithm:
This algorithm is designed to work in the same manner as the previous one, except there are no
rules created to restrict the sample set. This means that any combination of item can be generated
using this mode. It still uses the same list of effects and their values and the item list, etc. But
there are no limitations to the item being generated. So it may be possible that a weapon type
item can get defensive effects or Paladin shield might get a boost to Necromancer skills.
This mode was designed and created to be an example of a possible existing Item generation
algorithm; even though it is well known that in most RPG games robust algorithms are already
being used. This mode will help to compare and contrast with my researched algorithm in terms
of usefulness and effectiveness. This will be analyzed in the Analysis and Results Chapter and
conclusions will be drawn in the final chapter.
41
- Chapter 5 -
EVALUATION AND RESULTS
5.1 Testing Approach:
Although initially planned to be tested with live participants and collect honest feedback from
them, it was later decided that another approach would be better suited for testing this
application, since it could be possible that participants would be biased to my approach. Another
reason being, since this research involves randomization, a thorough analysis must include
hundreds of test cases which may be impractical to collect from live participants. So I have
developed a utility within my game application that can simulate a specified number of players
and while generating the items for analysis, it will log them as a report in an excel sheet. For my
analysis I have tested both modes of my application by 200 simulated participants using my
testing utility and the results were generated in the report. I have conducted my analysis on this
sheet and written the necessary formulas to correlate meaningful information in order to generate
charts and tables. Earlier I had also conducted a blind survey using a few participants, but those
results are not heavily weighted in my results.
5.1.1 Testing Parameters:
The steps for testing by each player are listed below:
1. Start the game and provide the player inputs: Name, Class, and Level.
2. Select Mode 1 (Completely Random Algorithm).
3. Open each chest 3 times to get 3 items.
4. After completing all 10 chests, change to Mode 2 and repeat step 3.
Since this is a randomization algorithm, 3 items were decided to be obtained from each chest
giving us a more fair result, yet simple. After opening all chests in both modes, a total of 60
items would have been collected by the player and all items would be recorded in the report
sheet as well. In the automated mode, however the players‟ class, level and stats are randomly
42
generated while a unique name is given to each player and the same steps are followed for the
200 simulated players.
5.2 Results:
The results from this application is obtained in the excel sheet named “ExcelReport.xls”. Every
item collected by the player is logged in this report. Every item is recorded in a single line where
every attribute is separated by a pipe character (“|”). This makes it easier to separate the columns
in Microsoft Excel so that a proper table is constructed for analysis.
Table 5.1: Results from ExcelReport.xls after structuring into a Table
Table 5.2: Results from ExcelReport.xls contd.
43
The item effects and their values have been stored into various arrays based on their type. There
is an array for general item effects, weapon item effects, armour item effects and class-specific
item effects and their values increase for every 10 levels. See more results in APPENDIX-D.
Another document called “TestCases.txt” is also generated which shows the items with a better
structure meant for easy reading.
Figure 5.1: Results from TestCases.txt
Both of these reports contains the record of 12,000 items collected by 200 simulated players, 3
from each of the 10 chests, first using Mode 1 (Complete Randomized Algorithm) and then using
Mode 2 (Rule-Based Randomized Algorithm).
44
5.3 Analysis:
The excel sheet “ExcelReport.xls” was used as the input for the analysis. In order to have
statistical data, I had to create various formulas to map results with meaningful data.
5.3.1 Item Effect Chart:
Two formulas were created for the inputs of this chart.
5.3.1.1 Item Quality: (Rule 5)
Formula: =IF(N32="","Normal Item",IF(OR( O32="", P32="", Q32= ""),"Magical Item", "Rare Item"))
Table 5.3: Item Quality Formula
5.3.1.2 Number of Effects (Quantitative): (Rule 3 and Rule 4)
Formula: =COUNTA(O2,R2,U2,X2,AA2)
Table 5.4: Number of Effects (Quantitative) Formula
45
5.3.1.3 Item Effect Charts:
Figure 5.2: Chart 1 - Item Effect Chart for Chest 1 using Mode 1
This chart shows that using the complete randomized mode 1, the items that were dropped from
chest 1, had completely random number of effects. The number of effects determines the rarity
of the item (whether Normal, Magical or Rare). This means that it did not follow the
requirements of the item generation mechanic to generate items based on the level and magic
find chance of the player and the chest.
Figure 5.3: Chart 2 – Item Effect Chart for Chest 1 using Mode 2
This chart shows that using the rule-based randomized mode 2, the items that were dropped from
chest 1, had random yet limited number of effects. The number of effects ranged from 0 to 2,
which corresponds to Normal to lower Magical items. This means that this algorithm followed
the requirements of the item generation mechanic to generate items based on the level and magic
find chance of the player and the chest. See APPENDIX – E for all charts.
0
1
2
3
4
5
6
Player_0
Player_6
Player_12
Player_18
Player_24
Player_30
Player_36
Player_42
Player_48
Player_54
Player_60
Player_66
Player_72
Player_78
Player_84
Player_90
Player_96
Player_102
Player_108
Player_114
Player_120
Player_126
Player_132
Player_138
Player_144
Player_150
Player_156
Player_162
Player_168
Player_174
Player_180
Player_186
Player_192
Player_198
NumberofEffectsinanItem
Number of Test Cases by 200 simulated players
Mode 1: Chest 1: Item Effect Chart
0 effect is a Normal, 1-3 effects is a Magical and 4-5 effects is a Rare Item
0
1
2
3
4
5
6
Player_0
Player_6
Player_12
Player_18
Player_24
Player_30
Player_36
Player_42
Player_48
Player_54
Player_60
Player_66
Player_72
Player_78
Player_84
Player_90
Player_96
Player_102
Player_108
Player_114
Player_120
Player_126
Player_132
Player_138
Player_144
Player_150
Player_156
Player_162
Player_168
Player_174
Player_180
Player_186
Player_192
Player_198
NumberofEffectsinanItem
Number of Test Cases by 200 simulated players
Mode 2: Chest 1: Item Effect Chart
0 effect is a Normal, 1-3 effects is a Magical and 4-5 effects is a Rare Item
46
5.3.2 Error Chart:
This chart checks for correctness of the items that were generated based on clarity and
meaningful data. For example, if a sword was generated that has an effect like „+50% to Defense
rating‟, that would be incorrect because the item was a weapon type and the effect is meant for
defensive items. Another example is, if a sorceress only wand has an effect like „+2 to Paladin
skills‟, that would be incorrect, because a Paladin would never be able to equip it.
This chart checks this limitation of the items for correctness and plots it in a graph. These
limitations or boundary values form the sample set for a possible value, which is the defining
rule. There are 7 conditions being checked for correctness of items. They are described below.
5.3.2.1 Level Check: (Rule 1 and Rule 2)
Formula: =IF(OR(M2 > (C2+5), M2 < (C2-5)), FALSE, TRUE)
Table 5.5: Level Check Formula
This formula checks to see if the level of the item is within a range of +/- 5 of the players‟ level.
For this research, this is an acceptable range for an appropriate item level. The formula displays
True in green if it is within this range and False in Red if lies outside.
47
5.3.2.2 Requirement Check: (Rule 9 and 10)
Formula: =AND(IF(ISNUMBER(FIND("Strength",$N2,1)), IF(ISNUMBER(MATCH($J2,'Item Type
Classification'!$B$2:$B$22,0)), TRUE, FALSE), TRUE), IF(ISNUMBER(FIND("Dexterity",$N2,1)),
IF(ISNUMBER(MATCH($J2,'Item Type Classification'!$C$2:$C$7,0)), TRUE, FALSE), TRUE),
IF(ISNUMBER(FIND("Energy",$N2,1)), IF(ISNUMBER(MATCH($J2,'Item Type Classification'!$D$2:$D$7,0)),
TRUE, FALSE), TRUE), IF(ISNUMBER(FIND("Amazon Class Only",$N2,1)), IF($J2 = "Amazon's Spear/Bow",
TRUE, FALSE), TRUE), IF(ISNUMBER(FIND("Assassin Class Only",$N2,1)), IF($J2 = "Katar", TRUE, FALSE),
TRUE), IF(ISNUMBER(FIND("Barbarian Class Only",$N2,1)), IF($J2 = "Barbarian Helm", TRUE, FALSE),
TRUE), IF(ISNUMBER(FIND("Druid Class Only",$N2,1)), IF($J2 = "Druid Helm", TRUE, FALSE), TRUE),
IF(ISNUMBER(FIND("Necromancer Class Only",$N2,1)), IF($J2 = "Necromancer Head", TRUE, FALSE),
TRUE), IF(ISNUMBER(FIND("Paladin Class Only",$N2,1)), IF($J2 = "Paladin Shield", TRUE, FALSE), TRUE),
IF(ISNUMBER(FIND("Sorceress Class Only",$N2,1)), IF($J2 = "Sorceress Wand", TRUE, FALSE), TRUE))
Table 5.6: Requirement Check Formula
This formula check to see if the requirements generated for the item is correct or not. Strength
attribute is typically for melee weapons and armour, Dexterity attribute is for ranged items or
highly skilled melee weapons, and Energy attribute is for magic type items and finally there are
class specific items that should state class specific requirements. If there is a mismatch in these
requirements then this formula sets the value to False, else it is set to True.
5.3.2.3 Effects Check: (Rule 6, Rule 7 and Rule 8)
Formula: = IF($O2 = "", TRUE, IF(ISNUMBER(MATCH($O2,'Item Type Classification'!$J$2:$J$20,0)),
IF(ISNUMBER(MATCH($J2,'Item Type Classification'!$F$2:$F$17,0)), TRUE, FALSE),
IF(ISNUMBER(MATCH($O2,'Item Type Classification'!$K$2:$K$20,0)), IF(ISNUMBER(MATCH($J2,'Item
Type Classification'!$G$2:$G$12,0)), TRUE, FALSE), IF(ISNUMBER(MATCH($O2,'Item Type
Classification'!$L$2:$L$8,0)), IF(ISNUMBER(MATCH($J2,'Item Type Classification'!$H$2:$H$8,0)), TRUE,
FALSE), TRUE))))
48
Table 5.7: Effects Check Formula
This formula checks to see if the effect generated is meant for that item type and also if the
values match the item level. If it does it sets the value to True, else it is set to False. This formula
is applied for all the 5 effects generated.
5.3.2.4 Final Error Check:
Formula: =IF(OR($AH2 = FALSE, $AI2 = FALSE, $AJ2 = FALSE, $AK2 = FALSE, $AL2 = FALSE, $AM2 =
FALSE, $AN2 = FALSE), 1, 0)
Table 5.8: Final Error Check Formula
49
This is the final accumulated condition that checks to see if the 7 conditions: Level,
Requirement, Effect 1, Effect 2, Effect 3, Effect 4 and Effect 5 conditions have been satisfied. If
so, then it sets the value 0 which represents an acceptable item, else it sets the value 1 for an
unacceptable item. Also notice how the table row will display a completely green row for the 7
conditions if it is an acceptable item. These formulas are applied for all the 12,000 items and the
chart has been drawn to plot them statistically.
5.3.2.5 Error Charts:
Figure 5.4: Chart 3 – Error Chart for Chest 1 using Mode 1
Notice how all but 3 items have been plotted as invalid/incorrect items. This statistically means
that the chance of generating invalid items using my complete randomized algorithm is 11,997 in
12,000 or 99.975 %.
Figure 5.5: Chart 4 – Error Chart for Chest 1 using Mode 2
0
1
Player_0
Player_6
Player_12
Player_18
Player_24
Player_30
Player_36
Player_42
Player_48
Player_54
Player_60
Player_66
Player_72
Player_78
Player_84
Player_90
Player_96
Player_102
Player_108
Player_114
Player_120
Player_126
Player_132
Player_138
Player_144
Player_150
Player_156
Player_162
Player_168
Player_174
Player_180
Player_186
Player_192
Player_198
Mode 1: Chest 1: Error Chart
1 is an invalid Item and 0 is a valid Item
0
1
Player_0
Player_6
Player_12
Player_18
Player_24
Player_30
Player_36
Player_42
Player_48
Player_54
Player_60
Player_66
Player_72
Player_78
Player_84
Player_90
Player_96
Player_102
Player_108
Player_114
Player_120
Player_126
Player_132
Player_138
Player_144
Player_150
Player_156
Player_162
Player_168
Player_174
Player_180
Player_186
Player_192
Player_198
Mode 2: Chest 1: Error Chart
1 is an invalid Item and 0 is a valid Item
50
Notice how all the items have been plotted as valid/correct items. This statistically means that the
chance of generating invalid items using my rule –based randomized algorithm is 0 in 12,000 or
0%. Since the rules were defined the same way as the formulas, the result must be 0%.
5.3.3 Final Error Table:
Chest Number Chance of Error in Mode 1
(Complete Random)
Chance of Error in Mode 2
(Rule-based Random)
Chest 1 99.975 % 0 %
Chest 2 99.975 % 0 %
Chest 3 99.983 % 0 %
Chest 4 100 % 0 %
Chest 5 99.967 % 0 %
Chest 6 99.975 % 0 %
Chest 7 99.95 % 0 %
Chest 8 100 % 0 %
Chest 9 99.983 % 0 %
Chest 10 99.992 % 0 %
Table 5.9: Table of Errors between the two Modes
This final table shows the percentage of errors occurred using both types of algorithms. The
amount of errors in Mode 1 is extremely high because in the algorithm there is no control over
the sample set for the random algorithm so the chance of generating a valid item is extremely
small, so repeated sampling will be required using this approach to eventually get a valid item,
where as in Mode 2, the sample set is initially calculated by the rules so any possibility chosen
by the random algorithm will never have a chance of error always generating a valid item.
5.3.4 Complete Analysis:
Please find the rest of the Item Effect charts and Error charts for all 10 chests using both modes
in APPENDIX – E. The Item Type Classification which contains all the arrays in the excel report
used by the formulas is also displayed in APPENDIX – E.
51
- Chapter 6 -
CONCLUSION AND FUTURE WORK
6.1 Conclusion:
After analyzing all the results from this application a few things have become clear and can now
be verified. Firstly, rules or constraints are necessary in designing a random algorithm for item
generation mechanics. It would be possible to use an unconstrained random algorithm, but that
would result in obtaining a lot of unusable items and so the algorithm would have to be
repeatedly executed until a useful item is generated. This approach is less efficient and more time
consuming. The rule-based random algorithm, however, will always generate items that fall
within the function curve or within the accepted region, thus eliminating the need to repeat the
procedure.
Secondly, we can conclude that not only is the number of rules required to govern the selection
process important but also the rules themselves. The decision to select a rule must be made in
order to eventually increase the replay value of the game. So if that means that class specific
items with class specific effects will improve the item generation mechanic for improved and
increased play time, then it is a good rule to have. There are many role playing games today that
do not implement certain rules in item generation, for instance Dragon Age 1 and 2. There are
many chest and monsters that have predefined drops programmed into the game. This means that
the player will eventually get those items in every play through. Thus this mechanic remains at a
mediocre level as compared to Diablo or Fate‟s mechanic. Another example of a rule that should
be implemented is generating effects only meant for defensive, offensive, ranged or magical
items. This makes it more meaningful to the player and increases playability thus making item
farming more fun.
Thirdly, the increased playability of the game also increases the shelf life of the game and
improves the overall game rating thus improving popularity. There are many features that
contribute to a games rating but for role playing games, item generation is a key factor for the
52
purpose of customization of the playable character. This also increases the odds of players
wanting to buy more downloadable content and expansion packs for the game. A brilliant
example of this is the Warrior, Rogue and Mage DLC‟s packs for Dragon Age 2 (Bioware,
2011). Their only intent was to give the player better equipment to play the entire game again for
each class and they did it again with the second set of item packs for each class. The studio
makes more money because of introducing DLC‟s since the players want to play the game again
with better equipment.
Finally the consumers who play the game feel satisfied that their investment in the game was
worth it and that they can expect similar or improved mechanics in games from this developer,
thus increasing loyal fans to the company.
6.2 Unimplemented ideas:
The completion of this project doesn‟t mean that everything went according to plan from the
very beginning. There were a few planned ideas that were not implemented in the end, which is
described in this section.
There was a plan to implement other mechanics that use random algorithms in role playing
games like dialogue generation and quest generation. But after realizing the vastness of the
research and the amount of work involved in implementing them in the application during this
short period, it was cut from the project. The project was also planned to include a reusable data
structure like a tree or a linked list for maintaining the data (Items types, Effects and their values,
etc). Later for ease of use various arrays were used to store the information. The game was also
to have a name generation algorithm, which would be a combination of prefixes, item type and
suffixes to give the items some personality. But due to lack of time, this was not implemented.
Due to the lack of resources available, most of the graphics, effects and sounds were taken from
the game Diablo 2 which is trademark of Blizzard Entertainment (Blizzard, 2000). I have only
borrowed the images and sound for educational and research purposes. Only one model was
available for importing into the game which was obtained from DirectX 9.0 sample projects,
even though there are seven classes of players.
53
6.3 Future Work:
The primary reason for me to choose this topic for my research was because like many role
playing game fans out there, collecting items is an addiction for me. So I wanted to research
more about its algorithms so I could understand how the mechanic works and how to improve it.
But another important reason for choosing this topic was because after searching through many
portals and libraries, I couldn‟t find many useful research documents discussing item generation
algorithms in detail. This would probably be due to the fact that such algorithms are proprietary
to the developing company. So I decided that my research could be a good starting point for
others interested in doing similar research in this topic and how to go about implementing it.
Given time I could see myself working on enhancing my application by implementing the name
generation algorithm using prefixes and suffixes. It would also be beneficial to modify the data
structures to a more reusable and upgradeable one, like a linked list. This would also give an
easier opportunity to append to the list of effects. With more time to research, more creative and
useful rules could be defined to enhance the mechanic as well. This project could also be
enhanced by implementing a simple encounter with an enemy and the items could be dropped
from the enemy instead of the chest.
Looking at the horizon, we see a glimpse of newer and better item mechanics coming to fruition.
The all time classic Diablo is returning in the third instalment of the series and promises to be
more engrossing than ever. Blizzard plans to introduce a currency-based auction house where
players can go looking for exactly what they want and buy/sell it for real money. They have
already introduced it in their beta test (Blizzard, Dec, 2011). Besides that, they will introduce
artisans who are non-playing characters who can upgrade items for a price (Blizzard, Dec 2011).
This will enhance items farming to almost limitless possibilities. And the day will come when
even those mechanics will seem incomplete to core RPG fans.
54
REFERENCES AND BIBLIOGRAPHY
Arsenault, D., 2005. Abstract of Dynamic Range: When Game Design and Narratives Unite. s.l.:University
of Montreal.
Bioware, 2011. DA2 Add-Ons. [Online]
Available at: http://dragonage.bioware.com/da2/addon/
[Accessed 20 December 2011].
Blizzard, E., 1996. Blizzard Entertainment: Legacy Games. [Online]
Available at: http://us.blizzard.com/en-us/games/legacy/
[Accessed 28 November 2011].
Blizzard, E., 2000. Diablo 2. [Art] (Entertainment, Blizzard).
Blizzard, E., Dec 2011. Game Guide Updated: Artisans. [Online]
Available at: http://us.battle.net/d3/en/blog/4059594/Game_Guide_Updated_Artisans-
12_6_2011#blog
[Accessed 17 December 2011].
Blizzard, E., Dec, 2011. Currency-Based Auction House Beta Testing. [Online]
Available at: http://us.battle.net/d3/en/blog/4024156
[Accessed 17 December 2011].
Buzacott, J. A. & Shanthikumar, J. G., 1993. Stochastic Models of Manufacturing Systems. s.l.:Prentice
Hall.
Cleve, M., Feb 2008. Chapter 9: Random Numbers. In: s.l.:s.n., p. 1.
Ditchburn, K., 2011. SoundPlayer Utility. s.l.:s.n.
Flux, e. a., Dec, 2008. Item Generation Tutorial:. [Online]
Available at:
http://diablo2.diablowiki.net/Item_Generation_Tutorial#Short_Explanation_of_Drop_Process
[Accessed 27 Nov 2011].
hijo_del_escorpion, 2011. Dragon Age 2: Two Acts out of Three Ain’t Bad. [Online]
Available at: http://www.ign.com/blogs/hijo_del_escorpion/2011/03/14/dragon-age-2-two-acts-out-of-
three-ain%E2%80%99t-bad
[Accessed 3 December 2011].
Krakou, 2003. Full Diablo 2 Items Pack. [Online]
Available at: http://www.wc3c.net/showthread.php?t=16232
[Accessed 30 11 2011].
55
Kronika, 2009. Ciekawostki. [Online]
Available at: http://diablo1.ovh.org/?ciekawostki,78
[Accessed 28 November 2011].
Kushner, H. J., 1977. Probability methods for approximations in stochastic control and for Elliptic
Equations. V. 129 ed. s.l.:Academic Press, Inc.
Max Libbrecht, e. a., Sept 2011. Wikipedia. [Online]
Available at: http://en.wikipedia.org/wiki/Monte_Carlo_algorithm
[Accessed 12 Nov 2011].
Microsoft, 2010. Dwarf Model. [Art] (Microsoft).
Pengelly, J., Feb 2002. Monte Carlo Methods. s.l.:s.n.
Prof. Luna, F., 2011. d3dUtility. Dundee, Abertay: s.n.
Prof. Whitehead, J., January 2007. Definitions of Games and Play, Magic Circle, Rules as Limitations and
Affordances. Creative Commons Attribution 2.5 ed. Santa Cruz: University of California.
Samuel, R., 2011. Master's Project(CGT) - Rule-Based Probability for Random Content generation in
RPG's. [Online]
Available at: http://rejoshsamuel-mastersprojectcgt.blogspot.com/
[Accessed Jun-Dec 2011].
TurboSquid, 2011. Wall and Floor textures. [Art] (TurboSquid.com).
Virginia, U. o., Aug 2006. Chapter 11: Markov Chains. s.l.:s.n.
Walrand, J., August 25, 2004. Probability Space. In: Lecture Notes on Probability Theory and Random
Processes. Berkeley, CA: s.n., pp. 13-17.
Wikipedia, 2011. Las Vegas algorithm. [Online]
Available at: http://en.wikipedia.org/wiki/Las_Vegas_algorithm
[Accessed 19 11 2011].
Wikipedia, Nov 2011. Monte Carlo Method. [Online]
Available at: http://en.wikipedia.org/wiki/Monte_Carlo_method
[Accessed 15 Nov 2011].
56
APPENDIX – A
Bertrand's Paradox (Walrand, August 25, 2004)
The point of this note by Jean Walrand is that one has to be careful about the meaning of
“choosing at random."
Consider the following question: What is the probability that a chord selected at random in a
circle is larger than the side of an inscribed equilateral triangle? There are three plausible
answers to this question: 1=2, 1=3, and 1=4. Of course, the answer depends on how we choose
the chord.
Figure A.1: Three ways of choosing a chord.
Answer 1: 1=3
The first choice is shown in the left-most part of Figure A.1. To choose the chord, we fix a point
A on the circle; it will be one of the ends of the chord. We then choose another point X at
random on the circumference of the circle. If X happens to be between B and C (where ABC is
equilateral), then AX is longer than the sides of ABC. Thus, the requested probability is 1/3.
Answer 2: 1=4
The second choice is illustrated in the middle part of Figure A.1. We choose the chord by
choosing its midpoint (e.g., X) at random inside the circle. The chord is longer than the side of
the inscribed equilateral triangle if and only if X falls inside the circle with half the radius of the
original circle, which happens with probability 1/4.
Answer 3: 1=2
The third choice is illustrated in the right-most part of Figure A.1. We choose the chord by
choosing its midpoint (e.g., X) at random on a given radius OA of the circle. The chord is longer
than the side of the inscribed triangle if an only if the point is closer to the centre than half a
radius, which happens with probability 1/2.
57
APPENDIX - B
Simpson's Paradox (Walrand, August 25, 2004)
Jean Walrand states that proportions do not add up and points out that one has to be careful with
statistics.
Consider a university where 80% of the male applicants are accepted but only 51% of the female
applicants are accepted. You will be tempted to conclude that the university discriminates against
female applicants. However, a closer look at this university shows that it has only two colleges
with the admission records shown in the table.
Note that each college admits a larger fraction of female applicants than of male applicants, so
that the university cannot be accused of discrimination against the female students. It happens
that more female students apply to a more difficult college.
College F.Appl. F. Adm. %F. Adm. M. Appl. M. Adm. %M. Adm.
A 980 490 50% 200 80 40%
B 20 20 100% 800 720 90%
Total 1000 510 51% 1000 800 80%
Table B.1: Example for Simpson’s Paradox
58
APPENDIX - C
Short Explanation of Drop Process (Flux, Dec, 2008):
When you kill a monster or open a chest the game may generate items to reward you. The
properties of these items are generated at that moment, even though the item may be
unidentified. The game creates dropped items with algorithm of such kind:
1. At the beginning it finds treasure class (TC), that describes all drops of the monster
you killed, a chest you opened, a hidden stash you found, etc. All drop sources have
treasure classes.
2. The game then makes one or several iterations that are called "Picks", when it selects
one choice from several possibilities.
1. One of the possibilities is "NoDrop", which does what it sounds like. Many
monsters have multiple "picks," so even if one of them is NoDrop, the other picks
may overrule it. Most normal monsters have only one pick, though.
2. If nothing is selected from the first TC, the next one down the list will be consulted,
then the next, then the next, until an item or NoDrop is selected.
3. Once an item is selected, the item properties are determined. Since most items have
numerous possible types, game's algorithm of quality determination is highly
complicated. Items such as keys, runes, and potions are only found in normal quality,
but items like rings, short swords, helms, and bucklers have different qualities like
magic or unique. Note that Magic Find is checked during this step.
4. For every selected item an ilvl is calculated.
5. If the rarity check hits upon an item of unique or set quality, the game creates the list
of all valid item types (determined by their ilvl) and randomly selects one to drop. If
there is not a unique of that type, a rare item with triple durability will generate. If
there is no set item of the selected type, a magical item with double durability will
appear.
6. After the game selects item type and item quality, it generates item affixes if needed. It
also generates all other properties of an item, if there are such properties. Items like
Runes, mana potions, and identify scrolls doesn't have variable properties, but magic
rings, rare kite shields, cracked sashes needs property generation.
59
APPENDIX - D
Results Tables:
Table D.1: Completely Random Algorithm (Mode 1) Items
Table D.2: Rule-based Random Algorithm (Mode 2) Items
60
APPENDIX - E
Item Effect Charts: Completely Randomized Algorithm (Mode 1)
Figures E.1, E.2 and E.3: Item Effect Chart for chests 1, 2 and 3 using Mode 1
0
1
2
3
4
5
6
Player_0
Player_6
Player_12
Player_19
Player_25
Player_31
Player_38
Player_44
Player_50
Player_57
Player_63
Player_69
Player_76
Player_82
Player_88
Player_95
Player_101
Player_107
Player_114
Player_120
Player_126
Player_133
Player_139
Player_145
Player_152
Player_158
Player_164
Player_171
Player_177
Player_183
Player_190
Player_196
NumberofEffectsinanItem
Number of Test Cases by 200 simulated players
Mode 1: Chest 1: Item Effect Chart
0 effect is a Normal, 1-3 effects is a Magical and 4-5 effects is a Rare Item
0
1
2
3
4
5
6
Player_0
Player_6
Player_12
Player_19
Player_25
Player_31
Player_38
Player_44
Player_50
Player_57
Player_63
Player_69
Player_76
Player_82
Player_88
Player_95
Player_101
Player_107
Player_114
Player_120
Player_126
Player_133
Player_139
Player_145
Player_152
Player_158
Player_164
Player_171
Player_177
Player_183
Player_190
Player_196
NumberofEffectsinanItem
Number of Test Cases by 200 simulated players
Mode 1: Chest 2: Item Effect Chart
0 effect is a Normal, 1-3 effects is a Magical and 4-5 effects is a Rare Item
0
1
2
3
4
5
6
Player_0
Player_6
Player_12
Player_19
Player_25
Player_31
Player_38
Player_44
Player_50
Player_57
Player_63
Player_69
Player_76
Player_82
Player_88
Player_95
Player_101
Player_107
Player_114
Player_120
Player_126
Player_133
Player_139
Player_145
Player_152
Player_158
Player_164
Player_171
Player_177
Player_183
Player_190
Player_196
NumberofEffectsinanItem
Number of Test Cases by 200 simulated players
Mode 1: Chest 3: Item Effect Chart
0 effect is a Normal, 1-3 effects is a Magical and 4-5 effects is a Rare Item
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs
Item Generation in RPGs

More Related Content

Similar to Item Generation in RPGs

A realtime classic chess game [proposal]
A realtime classic chess game [proposal]A realtime classic chess game [proposal]
A realtime classic chess game [proposal]Nischal Lal Shrestha
 
"The Perspective Game: An Epistemic Game for Civic Engagement" by Sherry Jone...
"The Perspective Game: An Epistemic Game for Civic Engagement" by Sherry Jone..."The Perspective Game: An Epistemic Game for Civic Engagement" by Sherry Jone...
"The Perspective Game: An Epistemic Game for Civic Engagement" by Sherry Jone...Sherry Jones
 
Educational Game Design Thesis
Educational Game Design ThesisEducational Game Design Thesis
Educational Game Design ThesisCory Buckley
 
3D Content for Dream-like VR
3D Content for Dream-like VR3D Content for Dream-like VR
3D Content for Dream-like VRRoland Bruggmann
 
How tomakea gameinunity3d
How tomakea gameinunity3dHow tomakea gameinunity3d
How tomakea gameinunity3dDao Tung
 
Enhancing video game experience through a vibrotactile floor
Enhancing video game experience through a vibrotactile floorEnhancing video game experience through a vibrotactile floor
Enhancing video game experience through a vibrotactile floorNicola Gallo
 
Web Game Development
Web Game DevelopmentWeb Game Development
Web Game DevelopmentSabin Buraga
 
Building Upon Everyday Play
Building Upon Everyday PlayBuilding Upon Everyday Play
Building Upon Everyday Playhaiyan
 
Learning to Play Complex Games
Learning to Play Complex GamesLearning to Play Complex Games
Learning to Play Complex Gamesbutest
 
Surviving Applied Games (2018)
Surviving Applied Games (2018)Surviving Applied Games (2018)
Surviving Applied Games (2018)Pietro Polsinelli
 
AI.implant_Games_White_Paper
AI.implant_Games_White_PaperAI.implant_Games_White_Paper
AI.implant_Games_White_PaperKenneth Trueman
 
9.5 Theses on the Power and Efficacy of Gamification
9.5 Theses on the Power and Efficacy of Gamification9.5 Theses on the Power and Efficacy of Gamification
9.5 Theses on the Power and Efficacy of GamificationSebastian Deterding
 
Presentation
PresentationPresentation
PresentationAnu22ish
 
Game Design for Storytellers
Game Design for StorytellersGame Design for Storytellers
Game Design for StorytellersPietro Polsinelli
 
Eight Rules for Making Your First Great Game
Eight Rules for Making Your First Great GameEight Rules for Making Your First Great Game
Eight Rules for Making Your First Great GameNick Pruehs
 
Artificial Intelligence in Gaming
Artificial Intelligence in GamingArtificial Intelligence in Gaming
Artificial Intelligence in GamingAnmol Sawhney
 
Game engine terminology/glossary
Game engine terminology/glossaryGame engine terminology/glossary
Game engine terminology/glossarygordonpj96
 
Research Proposal
Research ProposalResearch Proposal
Research ProposalYashIyengar
 

Similar to Item Generation in RPGs (20)

A realtime classic chess game [proposal]
A realtime classic chess game [proposal]A realtime classic chess game [proposal]
A realtime classic chess game [proposal]
 
"The Perspective Game: An Epistemic Game for Civic Engagement" by Sherry Jone...
"The Perspective Game: An Epistemic Game for Civic Engagement" by Sherry Jone..."The Perspective Game: An Epistemic Game for Civic Engagement" by Sherry Jone...
"The Perspective Game: An Epistemic Game for Civic Engagement" by Sherry Jone...
 
Educational Game Design Thesis
Educational Game Design ThesisEducational Game Design Thesis
Educational Game Design Thesis
 
3D Content for Dream-like VR
3D Content for Dream-like VR3D Content for Dream-like VR
3D Content for Dream-like VR
 
How tomakea gameinunity3d
How tomakea gameinunity3dHow tomakea gameinunity3d
How tomakea gameinunity3d
 
Enhancing video game experience through a vibrotactile floor
Enhancing video game experience through a vibrotactile floorEnhancing video game experience through a vibrotactile floor
Enhancing video game experience through a vibrotactile floor
 
Web Game Development
Web Game DevelopmentWeb Game Development
Web Game Development
 
Building Upon Everyday Play
Building Upon Everyday PlayBuilding Upon Everyday Play
Building Upon Everyday Play
 
Learning to Play Complex Games
Learning to Play Complex GamesLearning to Play Complex Games
Learning to Play Complex Games
 
Surviving Applied Games (2018)
Surviving Applied Games (2018)Surviving Applied Games (2018)
Surviving Applied Games (2018)
 
Amazon_S3_191.doc
Amazon_S3_191.docAmazon_S3_191.doc
Amazon_S3_191.doc
 
AI.implant_Games_White_Paper
AI.implant_Games_White_PaperAI.implant_Games_White_Paper
AI.implant_Games_White_Paper
 
9.5 Theses on the Power and Efficacy of Gamification
9.5 Theses on the Power and Efficacy of Gamification9.5 Theses on the Power and Efficacy of Gamification
9.5 Theses on the Power and Efficacy of Gamification
 
Presentation
PresentationPresentation
Presentation
 
Action adventurer
Action adventurerAction adventurer
Action adventurer
 
Game Design for Storytellers
Game Design for StorytellersGame Design for Storytellers
Game Design for Storytellers
 
Eight Rules for Making Your First Great Game
Eight Rules for Making Your First Great GameEight Rules for Making Your First Great Game
Eight Rules for Making Your First Great Game
 
Artificial Intelligence in Gaming
Artificial Intelligence in GamingArtificial Intelligence in Gaming
Artificial Intelligence in Gaming
 
Game engine terminology/glossary
Game engine terminology/glossaryGame engine terminology/glossary
Game engine terminology/glossary
 
Research Proposal
Research ProposalResearch Proposal
Research Proposal
 

Recently uploaded

Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 

Recently uploaded (20)

Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 

Item Generation in RPGs

  • 1. Item Generation Using Rule-Based Randomization Algorithms in Role Playing Games Rejosh Varghese Samuel A dissertation submitted in partial fulfilment of the requirement for the award of the degree of MSc in Computer Games Technology University of Abertay Dundee Institute of Arts, Media and Computer Games December 2011
  • 2. 0 University of Abertay Dundee Permission to copy Author: Rejosh Varghese Samuel Title: Item Generation Using Rule-Based Randomization Algorithms in Role Playing Games Qualification sought: M.Sc. Year: 2011 (i) I certify that the above mentioned project is my original work (ii) I agree that this dissertation may be reproduced, stored or transmitted, in any form and by any means without the written consent of the undersigned. Signature ……………………......................... Date …………………………..
  • 3. 1 ABSTRACT Have you ever wondered about what makes a treasure chest to have unique and powerful items in your favourite Role Playing Game? Or have you ever had the urge to go “Item Farming” to make that perfect suit of armour or to have that complete arsenal of weapons at your disposal? The game mechanic for customizing your character to suit the players‟ needs initially introduced in Role Playing Games has been successful in appealing to players and has found its way to other genres of games as well. Whether it is a rare enchanted sword, power-up to boost the characters‟ skills or a currency system which allows the player to buy merchandise from in-game stores, collecting loot has become a critical way to play most games. Even though many players have asked the question “Why did it drop this item?” or “Why didn‟t I get a better one?” many of them don‟t understand how it works. If you‟re wondering about it, then it would seem interesting to know how the game decides to give you this random loot. This would require an understanding of how items are created and the algorithms involved in randomly generating a collectable item. This is called “Item drop mechanics”, referring to items being dropped from a chest or a monster once it has been slain. This falls under a category of Artificial Intelligence (AI), which require bounding to certain rules to create an appropriate item while playing the game. These rules help to define the limits of the possibility of creating any item. With a suitable randomization algorithm it would be possible to have unpredictable outcome with coherence. This research discusses the available randomization algorithms as compared to rule-based randomized algorithm and also discusses current and past games with such mechanics. Based on this research, an item generation mechanic was developed in a prototype game which was repeatedly tested to generate a 200 player simulated test cases. Based on the analysis of this output, a conclusion was drawn out as to how it can affect the game play and replay ability for player satisfaction and in turn prolong the shelf life of the game. This research also sheds light on the importance of the item generation mechanic and its usefulness in post production. Join me in taking the next step into darkness to see what light uncovers!
  • 4. 2 ACKNOWLEDGEMENT I would sincerely like to thank Dr. Suheyl Ozveren for his guidance and feedback which helped me in improving my approach to my research. I would also like to thank Dr. Euan Dempster for helping me to remain on track within my deadlines. I would also like to acknowledge that I have used a lot of content from the game Diablo 2, including item pictures, various effects and a few sounds files. This has been used only for educational purposes. This content is under the sole ownership of Blizzard Entertainment. And lastly I would like to thank my parents for supporting my goals and encouraging me to excel in my field.
  • 5. 3 CONTENTS Chapter 1: Introduction................................................................................................ 9 1.1 Background............................................................................................................. 9 1.2 Aim of the project................................................................................................. 10 1.2.1 Research question ........................................................................................................... 10 1.3 Project significance............................................................................................... 10 1.4 Objectives.............................................................................................................. 11 1.5 Structure of dissertation ...................................................................................... 12 Chapter 2: Games using Item Generation Mechanics .............................................. 13 2.1 Diablo..................................................................................................................... 13 2.1.1 The Drop Process............................................................................................................ 15 2.2 Diablo 2.................................................................................................................. 16 2.3 Fate......................................................................................................................... 17 2.4 Torchlight.............................................................................................................. 19 2.5 Dragon Age and Dragon Age 2............................................................................ 20 Chapter 3: Literature Review ..................................................................................... 22 3.1 Randomized Algorithm........................................................................................ 22 3.2 Markov Chain Processes...................................................................................... 23 3.2.1 Markov Chains................................................................................................................ 23 3.2.2 Markov Process .............................................................................................................. 24 3.3 Monte-Carlo Method............................................................................................ 26 3.3.1 Defining Characteristics ................................................................................................. 27 3.3.2 Types of Monte-Carlo Algorithms.................................................................................. 27 3.4 Las Vegas Algorithm............................................................................................ 30 3.4.1 Relation to Monte-Carlo Algorithm................................................................................ 30 3.5 Rule-Based Random Algorithm .......................................................................... 31 3.5.1 Rules ............................................................................................................................... 31 3.5.2 Probability Space............................................................................................................ 31 3.5.3 Practical Application....................................................................................................... 32 Chapter 4: Methodolgy ............................................................................................... 33 4.1 Approach............................................................................................................... 33 4.2 Rule-Based Random Algorithm .......................................................................... 33 4.2.1 Game Parameters............................................................................................................ 34 4.2.2 Defining Rules................................................................................................................ 35 4.2.2.1 Application Design.............................................................................36 4.2.3 Input Attributes............................................................................................................... 37 4.2.4 User Interface and World Environment .......................................................................... 38 4.2.5 Testing Scenario: (Arrow keys to move and Space bar to interact with chests)..............38 4.2.6 Application Screenshots ................................................................................................. 39 4.2.6.1 Inputs ..............................................................................................39 4.2.6.2 Initial Scene ......................................................................................39 4.2.6.3 Mode 1.............................................................................................39
  • 6. 4 4.2.6.4 Mode 2.............................................................................................40 4.2.7 Limitations...................................................................................................................... 40 4.3 Completely Randomized Algorithm ................................................................... 40 Chapter 5: Evaluation and Results ............................................................................ 41 5.1 Testing Approach ................................................................................................. 41 5.1.1 Testing Parameters.......................................................................................................... 41 5.2 Results.................................................................................................................... 42 5.3 Analysis.................................................................................................................. 44 5.3.1 Item Effects Chart........................................................................................................... 44 5.3.1.1 Item Quality (Rule 5) ..........................................................................44 5.3.1.2 Number of Effects (Quantitative) (Rule 3 and Rule 4) ...............................44 5.3.1.3 Item Effect Charts ..............................................................................45 5.3.2 Error Chart...................................................................................................................... 46 5.3.2.1 Level Check (Rule 1 and Rule 2)...........................................................46 5.3.2.2 Requirement Check (Rule 9 and Rule 10)................................................47 5.3.2.3 Effects Check (Rule 6, Rule 7 and Rule 8) ..............................................47 5.3.2.4 Final Error Check...............................................................................48 5.3.2.5 Error Charts ......................................................................................49 5.3.3 Final Error Table............................................................................................................. 50 5.3.4 Complete Analysis.......................................................................................................... 50 Chapter 6: Conclusion and Future Work.................................................................. 51 6.1 Conclusion............................................................................................................. 51 6.2 Unimplemented Ideas........................................................................................... 52 6.3 Future Work ......................................................................................................... 53 References and Bibliography...................................................................................... 54 Appendix A: Betrand’s Paradox................................................................................. 56 Appendix B: Simpson’s Paradox................................................................................ 57 Appendix C: Short Explainations of Drop Process................................................... 58 Appendix D: Results Tables........................................................................................ 59 Appendix E: Analysis Charts...................................................................................... 60 Appendix F: Code Segments....................................................................................... 75 Appendix G: Questiannaire........................................................................................ 80
  • 7. 5 List of Tables Table 4.1: Game Parameters Table....................................................................................... 34 Table 4.2: Rules Table.......................................................................................................... 36 Table 4.3: Input Attributes Table.......................................................................................... 37 Table 5.1: Results from ExcelReport.xls after structuring into a Table............................... 42 Table 5.2: Results from ExcelReport.xls contd. ................................................................... 42 Table 5.3: Item Quality Formula........................................................................................... 44 Table 5.4: Number of Effects (Quantitative) Formula.......................................................... 44 Table 5.5: Level Check Formula........................................................................................... 46 Table 5.6: Requirement Check Formula................................................................................47 Table 5.7: Effects Check Formula......................................................................................... 48 Table 5.8: Final Error Check Formula...................................................................................48 Table 5.9: Table of Errors between the two Modes...............................................................50 Table B.1: Example for Simpson‟s Paradox..........................................................................57 Table D.1: Completely Random Algorithm (Mode 1) Items................................................ 59 Table D.2: Rule-based Random Algorithm (Mode 2) Items................................................. 59 Table E.1: Item Type Classification...................................................................................... 74
  • 8. 6 List of Figures Figure 2.1: Diablo Final Boss Fight.......................................................................................13 Figure 2.2: Diablo, Beta, PR-Demo and Hellfire Items.........................................................14 Figure 2.3: Diablo, Beta, PR-Demo and Hellfire Items.........................................................14 Figure 2.4: Diablo 2 - Diablo Boss Fight...............................................................................16 Figure 2.5: Items in Diablo 2 and the gambling window from a Merchant...........................17 Figure 2.6: Items in Diablo 2 and the gambling window from a Merchant...........................17 Figure 2.7: Final Boss battle in Fate......................................................................................18 Figure 2.8: Items in Fate........................................................................................................18 Figure 2.9: Boss Fight in Torchlight......................................................................................19 Figure 2.10: Dragon Age 1 ................................................................................................... 20 Figure 2.11: Dragon Age 2 ................................................................................................... 20 Figure 2.12: Inventory and items in DA: Origins..................................................................21 Figure 2.13: Inventory and items in DA2............................................................................. 21 Figure 3.1: Monte-Carlo Method: n = 3,000......................................................................... 26 Figure 3.2: Monte-Carlo Method: n= 12,000........................................................................ 26 Figure 3.3: Monte-Carlo Method: n = 21,000....................................................................... 26 Figure 3.4: Monte-Carlo Method: n= 30,000........................................................................ 26 Figure 3.5: Acceptance-Rejection Monte Carlo method....................................................... 28 Figure 3.6: Stratified Sampling Monte Carlo method........................................................... 29 Figure 3.7: Importance Sampling Monte Carlo method........................................................ 29 Figure 4.1: Model of a Rule based random algorithm...........................................................33 Figure 4.2: Player entering the inputs...................................................................................39 Figure 4.3: Player entering the inputs....................................................................................39 Figure 4.4: Player investigating a room with chests..............................................................39 Figure 4.5: Player investigating a room with chests..............................................................39 Figure 4.6: Opening chest 2 in Mode 1................................................................................. 39 Figure 4.7: Opening chest 4 in Mode 1................................................................................. 39 Figure 4.8: Opening chest 7 in Mode 2................................................................................. 40 Figure 4.9: Opening chest 10 in Mode 2............................................................................... 40
  • 9. 7 Figure 5.1: Results from TestCases.txt..................................................................................43 Figure 5.2: Chart 1 - Item Effect Chart for Chest 1 using Mode 1........................................45 Figure 5.3: Chart 2 – Item Effect Chart for Chest 1 using Mode 2....................................... 45 Figure 5.4: Chart 3 – Error Chart for Chest 1 using Mode 1.................................................49 Figure 5.5: Chart 4 – Error Chart for Chest 1 using Mode 2.................................................49 Figure A.1: Three ways of choosing a chord.........................................................................56 Figure E.1: Item Effect Chart for chests 1 using Mode 1...................................................... 60 Figure E.2: Item Effect Chart for chests 2 using Mode 1...................................................... 60 Figure E.3: Item Effect Chart for chests 3 using Mode 1...................................................... 60 Figure E.4: Item Effect Chart for chests 4 using Mode 1...................................................... 61 Figure E.5: Item Effect Chart for chests 5 using Mode 1......................................................61 Figure E.6: Item Effect Chart for chests 6 using Mode 1...................................................... 61 Figure E.7: Item Effect Chart for chests 7 using Mode 1..................................................... 62 Figure E.8: Item Effect Chart for chests 8 using Mode 1...................................................... 62 Figure E.9: Item Effect Chart for chests 9 using Mode 1...................................................... 62 Figure E.10: Item Effect Chart for chest 10 using Mode 1....................................................63 Figure E.11: Item Effect Chart for chests 1 using Mode 2....................................................63 Figure E.12: Item Effect Chart for chests 2 using Mode 2....................................................63 Figure E.13: Item Effect Chart for chests 3 using Mode 2....................................................64 Figure E.14: Item Effect Chart for chests 4 using Mode 2....................................................64 Figure E.15: Item Effect Chart for chests 5 using Mode 2....................................................64 Figure E.16: Item Effect Chart for chests 6 using Mode 2....................................................65 Figure E.17: Item Effect Chart for chests 7 using Mode 2....................................................65 Figure E.18: Item Effect Chart for chests 8 using Mode 2....................................................65 Figure E.19: Item Effect Chart for chests 9 using Mode 2....................................................66 Figure E.20: Item Effect Chart for chests 10 using Mode 2..................................................66 Figure E.21: Error Chart for chests 1 using Mode 1............................................................. 67 Figure E.22: Error Chart for chests 2 using Mode 1............................................................. 67 Figure E.23: Error Chart for chests 3 using Mode 1............................................................. 67 Figure E.24: Error Chart for chests 4 using Mode 1............................................................. 68 Figure E.25: Error Chart for chests 5 using Mode 1............................................................. 68 Figure E.26: Error Chart for chests 6 using Mode 1............................................................. 68
  • 10. 8 Figure E.27: Error Chart for chests 7 using Mode 1..............................................................69 Figure E.28: Error Chart for chests 8 using Mode 1..............................................................69 Figure E.29: Error Chart for chests 9 using Mode 1..............................................................69 Figure E.30: Error Chart for chest 10 using Mode 1............................................................. 70 Figure E.31: Error Chart for chests 1 using Mode 2..............................................................70 Figure E.32: Error Chart for chests 2 using Mode 2..............................................................70 Figure E.33: Error Chart for chests 3 using Mode 2..............................................................71 Figure E.34: Error Chart for chests 4 using Mode 2..............................................................71 Figure E.35: Error Chart for chests 5 using Mode 2..............................................................71 Figure E.36: Error Chart for chests 6 using Mode 2..............................................................72 Figure E.37: Error Chart for chests 7 using Mode 2..............................................................72 Figure E.38: Error Chart for chests 8 using Mode 2..............................................................72 Figure E.39: Error Chart for chests 9 using Mode 2..............................................................73 Figure E.40: Error Chart for chests 10 using Mode 2............................................................73
  • 11. 9 - Chapter 1 - Introduction 1.1 Background Role-playing games (RPG) were invented as a pen-and-paper story based game. Their popularity with certain people skyrocketed due to the amount of detail in the layout, plot and story that lets them completely immerse in the game. A fantasy world where you could slay your enemies, become a knight or a wizard and rescue a princess sounds magical and unreal. That was the point of such games; experience the impossible. However it wasn‟t too long for them to catch up with technology and make video based role playing games, where you don‟t have to rely on your imagination so much anymore. The interactive game lets you see and hear the world around you on your computer. The game lets you collect loot and customize your character to your liking. You could learn spells and become a mage or learn to fight with a sword and become a warrior. This lets you relate with the character as you can choose from many available options to your liking. Out of the many game mechanics introduced in this genre, there was one mechanic that was an instant success; collecting loot for your character. Loot refers to weapons, armour, spells, books and other rare artefacts. They are usually dropped from a slain enemy or as a reward for completing a task. But to keep the excitement in the game, loot could be found in almost any kind of storage like chests scattered around the world. This gives the player an incentive to explore the map to find such rare chests. But since an important aspect of these games is the replay ability of the game, it seemed uninteresting to always find the same loot from the same sources every time you play the game. This led to the invention of randomized algorithms to generate the loot while playing the game also known as item generation mechanics. While exploring a few randomized algorithms, this project will describe them and help to decide which one would be suitable for an item generation mechanic.
  • 12. 10 1.2 Aim of the Project The aim of this project is to build and analyze the significance of a suitable item drop mechanic using a rule-based randomization algorithm for improving game play value in role playing games. 1.2.1 Research Question What is the need for rules or constraints in a randomized algorithm for any item generation mechanic in role playing games? 1.3 Project Significance This project will shed light to the approach behind the item generation mechanic used in role playing games and to analyze which rules or constraints are suitable to enforce to have a meaningful yet unpredictable randomized item generation mechanic. The qualitative and quantitative significance of this research when implemented in a game will include:  Increased game play value  Longer shelf life of the game due to increased play time  More value for money  Ease to implement an expansion pack to the game mechanic. The expected outcome of this project is to evaluate the importance of the randomized mechanic for item generation by testing the research application with some participants by conducting a blind test where they are expected to test two algorithms; a rule based randomized algorithm and a completely randomized algorithm without knowing which ones they are testing. Their honest feedback will be collected and analyzed. For the purpose of extensive testing of the mechanic, it will also have an automated testing tool to collect large amounts of data quickly.
  • 13. 11 1.4 Objectives 1. Conduct research on existing randomized algorithms and determine their effectiveness for item drop mechanics. 2. Game mechanics like item drops in RPG use a certain amount of randomness to create a feeling of uncertainness in the game. This project will research and experiment with the level of constraints/rules that need to be applied to the random factor in order to make the game play realistic and improve its replay value for these mechanics. 3. To develop a prototype application that will implement the following game mechanics: Item drops from chests using a rule based randomized algorithm and the following constraints will be tested in it experimentally: a. Level Based Constraints: Both the player and chest levels are factors for the level of the item being dropped and the individual item effects as well. b. Class Type Constraints: Specific item drops based on the player‟s class type. c. Magic Find Percentage: Chance of finding a better item also depends on the Magic find percentage of the player and the chest. d. Item Level Constraint: Based on the level of the item, specific effects can be applied and the values of the effects are affected. e. Item Requirements Constraints: Every item will have certain requirements needed to equip them. These requirements will be calculated from the items level. f. Item Type Constraints: Based on the type of the item, specific effects can be applied to the item. 4. The experimental analysis would be conducted after the application generates a report of 200 simulated players in an excel sheet. The output of the analysis will be graphical tables and charts. The application will also be tested by a few participants who will test the game mechanics with and without the constraints enabled. They would then have to complete a questionnaire which will ask them they‟re feedback and to rate each mechanic.
  • 14. 12 5. A conclusion will be drawn from the result of this analysis and will be presented. The possibility of future work on this topic will be discussed as well as the current trends to this mechanic. 1.5 Structure of dissertation The background review for this dissertation is broken up in to two chapters: Chapter 2: Games using Item Generation Mechanics and Chapter 3: Literature Review. Following chapters will be Methodology, Analyses and Result, and the final chapter will contain Conclusion and Future Work which will conclude the dissertation and list possible future work in the area. There will be Appendices at the end to elaborate on key points throughout the dissertation.
  • 15. 13 - Chapter 2 - GAMES USING ITEM GENERATION MECHANICS Ever since role playing video games were invented, players always had the ability to customize their characters to make them more interesting or powerful. Whether that involved equipping various kinds of armour, weapons or managing skills, depended on the game. Listed below are a few games that have over time proved that the item generation mechanic has become crucial to customizing a playable character. 2.1 Diablo: One of the most famous games ever made which uses the item generation mechanic is Diablo developed by Blizzard North in 1996 (Blizzard, 1996). Figure 2.1: Diablo Final Boss Fight This game introduced the concept of generating random levels each time you play the game as well as randomized loot from chests and monsters. Ever since then, game developers have been trying to recreate their success in role playing games by improving their randomization
  • 16. 14 algorithms for various game mechanics like items, monster and map generations. Diablo: Hellfire was an official expansion pack to this game made by Sierra On-Line with more items, characters and quests. Game designers have always wanted to introduce newer features that could use randomized algorithms to enhance the game play and so they have. The game Fate by WildTangent for instance allows the player to fish from a pond. There is a chance the player could find a special item inside the fish. Another game called Torchlight by Runic Games has an open ended system where certain non-playing characters can generate random quests based on the level of the player. Arsenault has described in his research abstract about its success. “Diablo provides a wonderful example of how successful a game can be, even without emergence. Do the three different character classes and 26 spells, along with the 31 armour pieces and 39 weapons – each one possibly enchanted with one or two of the 285 possible magical effects – provide an emergent game-play system? But in truth, there is very little difference between playing a Sorcerer attacking his enemies with a Venom Quarterstaff of the Bat, and playing a Warrior attacking his enemies with a Soldier‟s Long Sword of Thunder. Sorcerers can wear plate mails and wield heavy axes, Warriors can cast advanced spells, and Rogues can have their weapons repaired at the blacksmith” (Arsenault, 2005). Figure 2.2 and 2.3: Diablo, Beta, PR-Demo and Hellfire Items (Kronika, 2009)
  • 17. 15 So he asks “Why is Diablo successful? As the player goes deeper in the labyrinth, he faces increasingly challenging monsters, and gets to buy and find increasingly stronger equipment. The carefully-crafted balance makes the game addicting: the player is always fairly challenged, yet never over-powered. The success of Diablo is due to the fact that a progression-based game-play system matches the linear, pre-written story of an adventurer descending deeper in a dungeon to defeat the evil Lord of Terror” (Arsenault, 2005). Somewhere down the line, the player gets addicted to hoarding and perfecting his arsenal of weapons and armour. This single game play mechanic can cause the player to play the game for hours on end. The game also re-spawns slain monsters and bosses which allows the players to hunt them down again in order to get more items. In this context this is called „item farming‟. Playing on Battle.net allowed up to 4 players to play in a single game which increasing both the number of monsters to kill and their difficulty levels. This in turn also increases the chance to get better rewards from them too. 2.1.1 The Drop Process: So what actually happens when you kill a boss in Diablo? An algorithm or a sequence of operations is performed to create and drop one or more items. Flux from DiabloWiki.net has described the steps that are performed (Flux, Dec, 2008). The algorithm: 1. Calculates the number of items to drop 2. Selects the item types 3. Selects the item qualities 4. Based on chance selects certain unique items 5. Selects item properties based on prefixes and suffixes 6. Generates names for the items 7. Drops them as Unidentified items Please see Appendix-C for a detailed explanation of this process described by Flux.
  • 18. 16 2.2 Diablo 2: This sequel to Diablo has a further in-depth story line and a game play framework that has reused a lot of the mechanics from the first but also introduced many new ones. The random algorithms for generating maps, monsters and items were back, but now there were some distinct rules applied to the game which made it very distinguishable. For instance, five distinct classes were created with different abilities and spells. This meant that the player has to have a different strategy for each character class that he plays as since each class has its own strengths and weaknesses. They also designed class specific items and effects so that customisation of the player became more unique. This introduced a whole new dimension to item farming, where in class specific items would be better off traded to other players who might need them. Figure 2.4: Diablo 2 - Diablo Boss Fight In Diablo 2 Blizzard introduced a new classification of Item quality called Set Items, which are a collection of items when equipped with their matching set gives additional bonus effects to the player. The chance to find such items is the same as for unique items. This concept yet again affected the way a player would want to item farm because now they are collecting set item parts by storing them in the limited storage chest in town while trying to find their matching sets.
  • 19. 17 Figure 2.5 and 2.6: Items in Diablo 2 and the gambling window from a Merchant (Krakou, 2003) The drop process remains the same for Diablo 2; however the decision to drop a set item is calculated the same time when the algorithm is choosing a unique item. They even introduced a merchant NPC in every town that will “Gamble” with the player for the chance to buy a rareuniqueset item for a low price. Blizzard released the expansion for Diablo 2 called Lord of Destruction in June of 2001. Besides expanding the item database they also introduced 2.3 Fate: Here is another example of an RPG that specializes in randomized dungeon crawler and quest based mechanics. The Fate series by WildTangent includes Fate, Fate: Undiscovered Realms, Fate: The Traitor Soul and their latest instalment Fate: The Cursed King. They revolve around the player accepting a main quest to slay a random boss monster on a dungeon level somewhere below the ground. Along the way the player can pick up random quests from NPC and on successfully completing those missions they can claim their reward.
  • 20. 18 Figure 2.7: Final Boss battle in Fate Having been closely designed to Diablo 2, it uses a lot of the same mechanics including randomized map generation, item generation, melee and spell casting fighting mechanics. However randomized algorithms for quest and reward generation were newly introduced. The order or the number of quests undertaken is not important, but just the level of the player for that quest since it is based on the level that the quest is generated. Figure 2.8: Items in Fate
  • 21. 19 The items were generated the same way as in Diablo (refer Appendix- C). The chance to find magic item increases based on the characters level and by equipping items that enhance that property. The enemy or chests level is also a factor in the quality of the item being generated. The developers also created the gambling system similar to Diablo‟s merchant gamble for rare or unique items. They did however introduce a new concept for finding items by fishing. Even though the chances of finding a usable item are low this way, it does give you an alternate way to get items without killing monsters and the item obtained this way are pretty rare also. 2.4 Torchlight: Torchlight is an action role playing game made by Runic Games and released in 2009 which also follows in the footsteps of Diablo. The development of this game was led by Travis Baldree, designer of Fate and joined by Max Schaefer and Erich Schaefer Co-designers of Diablo and Diablo 2. Unlike Fate this game had direction and plots much like the original features of Diablo. However they did port over the Fate mechanic for randomized side quest and reward generation. Figure 2.9: Boss Fight in Torchlight
  • 22. 20 Besides having a smooth game play, Torchlight had amazing graphics and artwork to compliment its randomized dungeons and caverns. The game was built to be capable of running on almost any computer adjusting the effects if necessary. It had three character classes each having their own equipment types but not restricting any on the others. The game had random algorithms for map, quest, item, monster and reward generations etc. It had normal, magical, rare, unique and set items. Besides that every item had various grade levels based on the item level. 2.5 Dragon Age (DA) and Dragon Age 2 (DA2): Here is a game franchise that revolutionized role playing games. Dragon Age was designed to capture the sense of the player and make him feel he is in the fantasy world of Fereldan. Even though the random algorithms were only implemented to item and enemy generation mechanics, they did introduce complex rule based algorithms for dialog selection and decision making, which had consequences in the game itself. Figure 2.10 and 2.11: Dragon Age 1 and 2 This game introduced a complex structure of dialogues to affect the choices of the player and thereby affecting the outcome of the game. This creates another dimension of uncertainty to the game. So now the players must ask “How will my decision affect the outcome?” Rewards, Quests, Friendships and rivalries with characters or the storyline itself can be affected as a result of this.
  • 23. 21 This game differs from the examples mentioned above in terms of randomness. Most rare or unique items in the game are defined to drop from certain bosses or chest or even bought from certain merchants. This means that no matter how many times you play the game or in any scenario, the player will still receive those items. So even though this game doesn‟t have a completely random item generation algorithm, it still appears to be random. This is due to the rules by which the game is governed which have been carefully chosen. The official expansion pack to Dragon Age (DA) was DA: Origins, which took off with a new story line and mission, with new companions and a lot more loot to collect. Figure 2.12 and 2.13: Inventory and items in DA: Origins and DA2 A blog post by hijo_del_escorpion on IGN.com describes his take on the item and inventory system in DA 2. “The item and inventory system suffered some improvements. It is very similar to DA: O but a little friendlier. The developers even decided to help new RPG players by providing a star rating system for equip able items so as to make it easier to identify when some piece of armour or ring you acquired may upgrade what your characters already have equipped. My advice is to be careful with these star systems, because they can be very inaccurate especially with the jewellery items. In normal this is fine, but in higher difficulties these stat boosts can be the difference between victory and kicking the bucket. I found that the overall stats of a unique item rated with zero stars was more desirable than another item rated with five stars, although that ultimately depends on the characters strengths and weaknesses. But for newer players it might be a nice thing to have.” (hijo_del_escorpion, 2011)
  • 24. 22 - Chapter 3 - Literature Review Unpredictability has always been a curious phenomenon to humans, since there always exist an element of surprise with it. A procedural algorithm always has a predefined outcome because they are designed to perform a certain task a certain way. In order to create unpredictability a random element must be introduced to the algorithm. These algorithms are called randomized algorithms and a few relevant ones are described below. 3.1 Randomized Algorithm A randomized algorithm is a set of instructions that uses a random factor to compute and get an unpredictable output. Using the same randomized algorithm, if different computers keep getting the same output, is it truly random? Computers are in principle deterministic machines and should not exhibit random behaviour (Cleve, Feb 2008). So to mimic random behaviour, the algorithm must use a truly unpredictable input and process it to generate the random outcome. There have been many randomized algorithms created for the purpose of unpredictability or uncertainty. The multiplicative congruential algorithm which is the basis for many of the random number generations in use today was invented by Berkeley professor D. H. Lehmer a pioneer in computing and especially computational number theory. Lehmer's number generator algorithms involve three integer parameters, a, c, and m, and an initial value, x0, called the seed (Cleve, Feb 2008). The series can be calculated by using the formula: xk+1 = axk + c mod m: where k>0 and xk is the current number and xk+1 is the next number to be calculated Randomized algorithms have also been developed for creating Artificial Intelligence due to the nature of their unpredictable outcome. An example of this is Markov chain. In 1907, A. A. Markov began the study of an important new type of chance process. In this process, the
  • 25. 23 outcome of a given experiment can affect the outcome of the next experiment. This type of process is called a Markov chain (Virginia, Aug 2006). Another type of randomized algorithm is the Monte Carlo algorithm. These algorithms have a deterministic running time but whose output may be incorrect with a small amount of probability. The name refers to the grand casino in the Principality of Monaco at Monte Carlo, which is well-known around the world as an icon of gambling (Max Libbrecht, Sept 2011). A variant of the Monte Carlo algorithm is the Las Vegas Algorithm. It is also randomized, but in a different way. They take an amount of time that varies randomly, but always produce the correct answer. A Monte Carlo algorithm can be converted into a Las Vegas algorithm whenever there exists a procedure to verify that the output produced by the algorithm is indeed correct. If so, then the resulting Las Vegas algorithm is merely to repeatedly run the Monte Carlo algorithm until one of the runs produces an output that can be verified to be correct (Max Libbrecht, Sept 2011). 3.2 Markov Chain processes Important classes of stochastic processes are Markov chains and Markov processes. A Markov chain is a discrete-time process for which the future behaviour given the past and the present only depends on the present and not the past. A Markov process is the continuous-time version of a Markov chain. Markov chain and Markov processes focuses on these characteristics that are needed for the modelling and analysis of queuing problems (Buzacott & Shanthikumar, 1993). 3.2.1 Markov chains: A Markov chain is characterized by a set of states S and the transition probabilities pij between the states. Here, pij is the probability that the Markov chain is at the next time point in state j, given that it is at the present time point at state i. The matrix P with elements pij is called the transition probability matrix of the Markov chain. Note that the definition of the pij implies that the row sums of P are equal to 1. Under the conditions that
  • 26. 24  All states of the Markov chain communicate with each other (i.e., it is possible to go from each state, possibly in more than one step, to every other state),  The Markov chain is not periodic (a periodic Markov chain is a chain in which, e.g., you can only return to a state in an even number of steps),  The Markov chain does not drift away to infinity, the probability pi(n) that the system is in state i at time point n converges to a limit in as n tends to infinity. These limiting probabilities, or equilibrium probabilities, can be computed from a set of so-called balance equations. The balance equations balance the probability of leaving and entering a state in equilibrium. This leads to the equations ∑ ∑ Or ∑ where In vector-matrix notation this becomes, with π the row vector with elements πi, Together with the normalized equation ∑ The solution of the set of equations above is unique (Buzacott & Shanthikumar, 1993). 3.2.2 Markov processes: In a Markov process we also have a discrete set of state S. However, the transition behaviour is different from that in a Markov chain. In each state there are a number of possible events that can cause a transition. The event that causes a transition from state i to j, where j ≠ i, takes place after an exponential amount of time, say with parameter qij. As a result, in this model transitions take place at random points in time. According to the properties of exponential random variables we have:  In state i, a transition takes place after an exponential amount of time with parameter ∑j≠iqij.  The system makes a transition to state j with probability
  • 27. 25 ∑ Define ∑ The matrix Q with elements qij is called the generator of the Markov process. Note that the definition of the qii implies that the row sums of Q are 0. Under the conditions that:  All states of the Markov process communicate with each other,  The Markov process does not drift away to infinity, the probability pi(t) that the system is in state i at time t converges to a limit pi as t tends to infinity. Note that, different from the case of a discrete time Markov chain, we do not have to worry about periodicity. The randomness of the time the system spends in each state guarantees that the probability pi(t) converges to the limit pi. The limiting probabilities, or equilibrium probabilities, can again be computed from the balance equations. The balance equations now balance the flow out of a state and the flow into that state. The flow is the mean number of transitions per time unit. If the system is in state i, then events that cause the system to make a transition to state j occur with a frequency or rate qij . So the mean number of transitions per time unit from i to j is equal to piqij. This leads to the balance equations: ∑ ∑ Or ∑ In vector-matrix notation this becomes, with p the row vector with elements pi, Together with the normalization equation ∑ The solution of the set of equations above is unique (Buzacott & Shanthikumar, 1993).
  • 28. 26 3.3 Monte-Carlo method Monte-Carlo methods are a class of computational algorithms that rely on repeated random sampling to compute their results. They are often used in computer simulations of physical and mathematical systems. These methods are most suited to calculation by a computer and tend to be used when it is infeasible to compute an exact result with a deterministic algorithm. They are especially useful for simulated systems with many coupled degrees of freedom, such as fluids, disoriented materials, strongly coupled solids and cellular structures (Wikipedia, Nov 2011). Figure 3.1 and 3.2: Monte-Carlo Method: n = 3,000, n=12,000 Figure 3.3 and 3.4: Monte-Carlo Method: n=21,000 and n=30,000
  • 29. 27 The above example shows how random samples within the limits (1.0, 1.0) can be calculated with the function to determine if they lie within the function curve or outside. This can be interpreted as meaningful data. Terrain generation, fluid mechanics, particle effects and other similar mechanics can be implemented using this type of algorithm. As stated by Pengelly, Monte Carlo methods provide approximate solutions to a variety of mathematical problems by performing statistical sampling experiments. They can be loosely defined as statistical simulation methods, where statistical simulation is defined in quite general terms to be any method that utilizes sequences of random numbers to perform the simulation. Thus Monte Carlo methods are a collection of different methods that all basically perform the same process. This process involves performing many simulations using random numbers and probability to get an approximation of the answer to the problem (Pengelly, Feb 2002). 3.3.1 Defining Characteristics:  Use of random numbers in its simulations  It can provide an approximate answer quickly  It only provides an approximation of the answer.  The more simulations performed, the more accurate the approximation is. 3.3.2 Types of Monte Carlo Algorithms: 1. Crude Monte Carlo: For N random samples we take the summation of their function values and divide by N to get the mean value of the samples, then multiply it with the interval (b-a) to get the integral. ∑ Where (a, b) is the approximate limits of the sample x N is the number of random samples taken for one output. The next step is to calculate the accuracy of the approximate output (I) otherwise the answer will not be meaningful without a description of its uncertainty (Pengelly, Feb 2002).
  • 30. 28 2. Acceptance – Rejection Monte Carlo: This algorithm uses the same formula used in Crude Monte Carlo. In the (a, b) interval for any given value of x the function you must find the upper limit. You then enclose this interval with a rectangle that is high enough to be above the upper limit, so we can be sure that the entire function for this interval is within the rectangle. We now begin taking random points within the rectangle and evaluate this point to see if it is below the curve or not. If the random point is below the curve then it is treated as a successful sample. Thus, you take N random points and perform this check, remembering to keep count of the number of successful samples there have been. Now, once you have finished sampling, you can approximate the integral for the interval (a, b) by finding the area of the surrounding rectangle. You then multiply this area by the number of successful samples over the total number of samples, and this will give you an approximation of the integral for the interval (a, b) (Pengelly, Feb 2002). Figure 3.5: Acceptance-Rejection Monte Carlo method 3. Stratified Sampling: The basic principle of this technique is to divide the interval (a, b) up into subintervals. You then perform a crude Monte Carlo approximation on each subinterval. You can find the variance by adding up the variances of each subinterval. This method could be well suited for a function that is step-like or that has periods of flat. This is because if you did an integration of a sub-interval that was very flat then you are going to get a very small variance value. Thus the advantage of the Stratified
  • 31. 29 Sampling method is that you get to split the curve into parts that could have certain advantageous properties when evaluating them on their own. Figure 3.6: Stratified Sampling Monte Carlo method. Function interval (a, b) is divided into four equal sized intervals – (I1, I2, I3, I4). ∫ ∫ ∫ ∫ ∫ Note that this equation is when the interval (a, b) has been broken into four sub- intervals (a, c), (c, d), (d, e) and (e, b) (Pengelly, Feb 2002). 4. Importance Sampling: In this method we define the integral equation as the following because they are equal: ∫ ∫ where p(x) is the probability distribution factor. Figure 3.7: Importance Sampling Monte Carlo method. This graph shows both f(x) and the probability distribution function p(x). The integral of p(x) over (a, b) is always equal to 1 and that for no value of x within the interval (a, b) will p(x) evaluate to 0. So the question arises, what is the purpose of introducing p(x) in the equation. Well, we can use it so that when we take samples
  • 32. 30 of the curve f(x) within the interval (a, b), we can make the choices taking into account the probability of that particular sample getting selected. For example, according to the example graph about half of the probability curve area is in the last quarter of the interval (a, b). Therefore, when we choose samples we should do it in a way so that half of the samples get taken from this area of the interval (Pengelly, Feb 2002). 3.4 Las Vegas algorithm: A Las Vegas algorithm is a randomized algorithm that always gives correct results. That is, it always produces the correct result or it informs about the failure. In other words, a Las Vegas algorithm does not gamble with the verity of the result; it gambles only with the resources used for the computation. A simple example is randomized quick sort, where the pivot is chosen randomly, but the result is always sorted. The usual definition of a Las Vegas algorithm includes the restriction that the expected run time always will be finite, when the expectation is carried out over the space of random information used in the algorithm. Las Vegas algorithms were introduced by László Babai in 1979, in the context of the graph isomorphism problem, as a stronger version of Monte Carlo algorithms. Las Vegas algorithms can be used in situations where the number of possible solutions is relatively limited, and where verifying the correctness of a candidate solution is relatively easy while actually calculating the solution is complex (Wikipedia, 2011). 3.4.1 Relation to Monte Carlo algorithm: Las Vegas algorithms can be contrasted with Monte Carlo algorithms, in which the resources used are bounded but the answer is not guaranteed to be correct 100% of the time. By an application of Markov's inequality, a Las Vegas algorithm can be converted into a Monte Carlo algorithm via early termination (Wikipedia, 2011).
  • 33. 31 3.5 Rule-based Random Algorithm They are a classification of Random Algorithms that uses a probability function which is limited to boundary conditions or rules in order to restrict the sample set for the probability function to certain domains. These algorithms use input data with a pre-defined set of rules or conditions to influence the outcome of the probability function. We explain that the key idea is to associate a likelihood, which we call probability, to sets of outcomes, not to individual outcomes. These sets are events. The description of the events and of their probability constitutes a probability space that characterizes completely a random experiment (Walrand, August 25, 2004). 3.5.1 Rules: A predefined set of rules usually govern this algorithm which creates the sample space for the probability function. They are carefully chosen so that we increase the chances of getting the output more suitable to their inputs. The important questions to be asked while deciding the rules are:  Which input/s is/are to be considered?  How will the chosen inputs affect the probability function?  How many rules are required for one probability function?  Do the chosen rules accurately limit the sample space for the probability function? When random samples are chosen from the sample space, the meaning associated with the inputs and the output is coherent as opposed to complete randomness. The likelihood of obtaining an unwanted outcome is diminished but at the same time it remains unpredictable. 3.5.2 Probability Space: A probability space is a triplet {Ω, F, P} where 1. Ω is a nonempty set, called the sample space; 2. F is a collection of subsets of Ω closed under countable set operations. The elements of F are called events; 3. P is a countable additive function from F into [0, 1] such that P(Ω) = 1, called a probability measure.
  • 34. 32 The main point is that one defines the probability of sets of outcomes (the events). The probability should be countable additive (to be continuous). Accordingly (to be able to write down this property), and also quite intuitively, the collection of events should be closed under countable set operations (Walrand, August 25, 2004). Some care is required when defining what we mean by a random choice. See Bertrand's paradox in Appendix-A for an illustration of a possible confusion. Another example of the possible confusion with statistics is Simpson's paradox in Appendix-B. 3.5.3 Practical application: This type of algorithm can be applied to many fields of science that require controlled uncertainty like neural networks, search engine data collection, mapping of stars in astronomy, etc. However in video games, it has a lot of practical usage also. Some of them include Terrain generation, random map and quest generation, dialogue and behaviour patterns and most importantly item generation.
  • 35. 33 - Chapter 4 - METHODOLOGY 4.1 Approach: The purpose of the application is to create the mechanics of Item generation in role playing games. After conducting research on different randomized algorithms and in understanding how they work, I decided to follow the best suited approach for this project: Rule-based randomized algorithm. In comparison, Markov chain process requires learning from previous iterations and the mechanics of Item generation does not require past learning in order to affect the outcome of the next iteration. Monte Carlo algorithms however focuses on using complete random samples from the sample set and later to verify if the output lies with the function curve. This approach could be used, but will be less optimal since there is a chance that the output will be rejected. The only condition the chosen algorithm has is that the mechanic should follow certain rules to stay within the guidelines of the game to have any meaning which correlates to game play value. This is explained in the following section. 4.2 Rule Based Random Algorithm: As mentioned earlier, this algorithm processes three sets of data to generate the output:  Dynamic: Input values to the algorithm  Static: Rules defined in the algorithm  Static/Dynamic: the Probability function which varies depending on usage Figure 4.1: Model of a Rule based random algorithm
  • 36. 34 The above model shows how various sets of inputs (Y1, Y2, Y3, .. Yk) are used by the defining rules or limiting factors (r1, r2, r3, .. rk) to create a sample space of possibilities and finally a probability function (p(x1)) is applied on this sample space to generate a final output. 4.2.1 Game Parameters: The following table describes the parameters of the game that will be used in the design and for the analysis: Parameter Obtained Description Player Level Input The player level can be chosen anywhere between 1 and 100 Player stats: Strength, Dexterity and Energy Calculated The player stats and calculated using the player level for ease of testing. Player Class Input The playable class chosen from: Amazon, Assassin, Barbarian, Druid, Necromancer, Paladin and Sorceress Player Magic Find Input Player Magic find chance could be anywhere between 0 and 100% Quality of Items Predefined White- Normal Items, Blue- Magical Items and Gold- Rare Items Chests Predefined There are 10 chests available each with a different chance to find magic Item: Chest 1 2 3 4 5 6 7 8 9 10 MF% 2% 4% 8% 16% 32% 64% 128% 256% 512% 1024% Item Types Predefined There are Armour, Weapon and Class specific item types created. Item Level Calculated The items‟ level is used to determine the effects, number of effects, quality of item, etc. (1 – 100) Effects Generated There are Armour, Weapon, Class-specific and General effects predefined. Based on Item types they are generated. Effect Values Generated The values of the effects are calculated also based on the item level. Table 4.1: Game Parameters Table
  • 37. 35 4.2.2 Defining Rules: Prof. Whitehead from UC Santa Cruz states in his lecture notes that “Games have rules that act as limitations, as well as rules that create affordances. Rules provide the player with meaningful actions and give the game a structure. Rules can be designed to give players either enjoyable or negative experiences.” (Prof. Whitehead, January 2007) Different kinds of rules may be applied to Item Generation mechanics. The following rules have been chosen and designed in this application: Rules Rule Description Required Inputs Rule 1 Item level must be within +/- 5 of the Player level  Player Level Rule 2 If Item level is greater than Player level, then item cannot be equipped. (Red Label)  Item Level,  Player Level Rule 3 Total chance to find magic item is the sum of Player and Chest chance to find magic item  Player chance to find magic item,  Chest chance to find Magic item Rule 4 Number of Effects is calculated using total chance to find magic item (0 to 5)  Total chance to find magic item Rule 5 Quality of the item is decided based on its number of effects: 0 – Normal Item (white), 1 to 3 Magical Item (blue), 4 or 5 Rare Item (golden)  Number of effects Rule 6 Effects are generated based on item types and Total Magic find chance: Armour items types get Armour effects, Weapon item types get Weapon effects, Class specific items get class specific effects, Any item type gets General effects also.  Item type,  Total chance to find magic item  Player Class Rule 7 Effect value is calculated from the item level  Item level Rule 8 General Item properties is calculated from item level: Weapons: min and max damage  Item level
  • 38. 36 Armours: defence Rule 9 Item Requirements are calculated using Item type and Item level: Melee weapons: Strength (maybe Dexterity) Ranged weapons: Dexterity Magical weapons: Energy Class specific items: Class specific requirements  Item type,  Item level  Player Class Rule 10 If Item requirements are not met by the players‟ stats (Strength, Dexterity, Energy and Class), then item cannot be equipped. (Red label)  Item requirements,  Player Strength,  Dexterity,  Energy and  Player Class. Table 4.2: Rules Table The above rules were implemented in the game application for the purpose of testing the cases and analyzing the outcomes with various trials. The game was designed keeping these rules in mind. 4.2.2.1 Application Design: The game application was built using DirectX 9.0c framework with a few models and textures imported from external sources. The player model was obtained from the sample project provided by Microsoft DirectX 9.0c (Microsoft, 2010) and the textures were obtained from TurboSquid.com (TurboSquid, 2011). Sound was implemented by using a utility created by (Ditchburn, 2011). The framework of the application was originally created by Prof. Frank Luna for a course project (Prof. Luna, 2011), but was later modified to a reusable and efficient project framework by me. The entire effort in building this application was concentrated around implementing two modes of operation: a Rule based Random algorithm and a complete randomization algorithm, and implementing them in an Item generation mechanic. Finally in order to improve accuracy of testing and analysis, a functionality was developed to simulate any number of players testing the application and generate an excel sheet with the outcomes. This would be used later for the analysis.
  • 39. 37 4.2.3 Input Attributes: The input attributes to the algorithm are classified in the table below: Input Attribute Range/Values Used by Rule Affected Outcome Player Class Amazon, Assassin, Barbarian, Druid, Paladin, Necromancer, Sorceress Rule 6, Rule 9, Rule 10 Class specific item drops, Class specific effects Player Level 1 – 100 Rule 1, Rule 2 Item Level Player Magic Find Chance 0 – (no cap) % Rule 3 Total chance to find magic item Player Stats Strength, Dexterity or Energy: 0 – (no cap) Rule 10 Whether item is equip able Item Level 1 – 100 Rule 2, Rule 7, Rule 8, Rule 9 Number of item effects and quality of item effects, Requirements of the item, Values of the effects Item Type Weapon, Armour, Class Specific or General Items Rule 6, Rule 9 Effects generated Item Requirements Strength, Dexterity or Energy: 0 – (no cap) Rule 10 Whether item is equip able Number of item effects 0 – 5 Rule 5 Quality of Item (Normal, Magical, Rare) Total chance to find magic item Player Magic Find Chance% + Chest Magic Find Chance% Rule 4, Rule 6 Number of item effects and Quality of item effects Chest Magic Find Chance 2 – 1024 % Rule 3 Total chance to find magic item - Input from Player - Calculated from input - Fixed inputs in the application Table 4.3: Input Attributes Table
  • 40. 38 The player class, level and magic find percentage are inputs to the game application. The players‟ stats, item level, item type and number of item effects are calculated based on the players‟ inputs. The chest magic find chances are pre determined for each chest. 4.2.4 User Interface and World Environment: The user interface was designed to relay information to the player in real time and request inputs from the player at start-up or when requested for. This includes the players‟ name, class, level, stats, chance to find magic item, the number of items collected, the chest that has been opened, the chance to find magic item of the chest and the number of items in the chest as well as the mode in which the player is testing the game. These messages will be displayed on the top of the screen depending on the actions of the player. There are 10 chests placed in a closed room. Each of the chests represents an item drop source which could easily be replaced by a monster, a friend or a non playing character. The idea of the research was to test the item drop mechanics which works the same for any of these sources. The chests are labelled from one to ten and have an increasing chance to find magic item based on its level. When the player approaches a chest and tries to open it, the name of the chest and its details are displayed in the UI. On opening a chest an item is generated and displayed on screen in an item description box with an icon of the item as well. The player can repeatedly open the chest to collect more items until it becomes empty. 4.2.5 Testing Scenario: (Arrow keys to move and Space bar to interact with chests) 1. Start the application and select the option for non-automated execution. 2. Input the players‟ name, class and level. 3. Move the player over to each of the 10 chests and open each 3 times to collect a total of 30 items. 4. Change the mode to Mode 2 and repeat step 3. 5. Mark your feedback on the questionnaire. (Refer Appendix - G)
  • 41. 39 4.2.6 Application Screenshots: 4.2.6.1 Inputs: Figures 4.2 and 4.3: Player entering the inputs 4.2.6.2 Initial Scene: Figures 4.4 and 4.5: Player investigating a room with chests 4.2.6.3 Mode 1: Figures 4.6 and 4.7: Opening chest 2 and chest 4 in Mode 1
  • 42. 40 4.2.6.4 Mode 2: Figure 4.8 and 4.9: Opening chest 7 and chest 10 in Mode 2 4.2.7 Limitations: This game has been limited to only implement and test the two modes of item generation used in this research: Completely Random Algorithm, and Rule-Based Random Algorithm. The two modes will be used to show the contrast in approaches. Due to insufficient time and resources, it was not feasible to implement other RPG mechanics like fighting, spells or dialogues. 4.3 Completely Randomized Algorithm: This algorithm is designed to work in the same manner as the previous one, except there are no rules created to restrict the sample set. This means that any combination of item can be generated using this mode. It still uses the same list of effects and their values and the item list, etc. But there are no limitations to the item being generated. So it may be possible that a weapon type item can get defensive effects or Paladin shield might get a boost to Necromancer skills. This mode was designed and created to be an example of a possible existing Item generation algorithm; even though it is well known that in most RPG games robust algorithms are already being used. This mode will help to compare and contrast with my researched algorithm in terms of usefulness and effectiveness. This will be analyzed in the Analysis and Results Chapter and conclusions will be drawn in the final chapter.
  • 43. 41 - Chapter 5 - EVALUATION AND RESULTS 5.1 Testing Approach: Although initially planned to be tested with live participants and collect honest feedback from them, it was later decided that another approach would be better suited for testing this application, since it could be possible that participants would be biased to my approach. Another reason being, since this research involves randomization, a thorough analysis must include hundreds of test cases which may be impractical to collect from live participants. So I have developed a utility within my game application that can simulate a specified number of players and while generating the items for analysis, it will log them as a report in an excel sheet. For my analysis I have tested both modes of my application by 200 simulated participants using my testing utility and the results were generated in the report. I have conducted my analysis on this sheet and written the necessary formulas to correlate meaningful information in order to generate charts and tables. Earlier I had also conducted a blind survey using a few participants, but those results are not heavily weighted in my results. 5.1.1 Testing Parameters: The steps for testing by each player are listed below: 1. Start the game and provide the player inputs: Name, Class, and Level. 2. Select Mode 1 (Completely Random Algorithm). 3. Open each chest 3 times to get 3 items. 4. After completing all 10 chests, change to Mode 2 and repeat step 3. Since this is a randomization algorithm, 3 items were decided to be obtained from each chest giving us a more fair result, yet simple. After opening all chests in both modes, a total of 60 items would have been collected by the player and all items would be recorded in the report sheet as well. In the automated mode, however the players‟ class, level and stats are randomly
  • 44. 42 generated while a unique name is given to each player and the same steps are followed for the 200 simulated players. 5.2 Results: The results from this application is obtained in the excel sheet named “ExcelReport.xls”. Every item collected by the player is logged in this report. Every item is recorded in a single line where every attribute is separated by a pipe character (“|”). This makes it easier to separate the columns in Microsoft Excel so that a proper table is constructed for analysis. Table 5.1: Results from ExcelReport.xls after structuring into a Table Table 5.2: Results from ExcelReport.xls contd.
  • 45. 43 The item effects and their values have been stored into various arrays based on their type. There is an array for general item effects, weapon item effects, armour item effects and class-specific item effects and their values increase for every 10 levels. See more results in APPENDIX-D. Another document called “TestCases.txt” is also generated which shows the items with a better structure meant for easy reading. Figure 5.1: Results from TestCases.txt Both of these reports contains the record of 12,000 items collected by 200 simulated players, 3 from each of the 10 chests, first using Mode 1 (Complete Randomized Algorithm) and then using Mode 2 (Rule-Based Randomized Algorithm).
  • 46. 44 5.3 Analysis: The excel sheet “ExcelReport.xls” was used as the input for the analysis. In order to have statistical data, I had to create various formulas to map results with meaningful data. 5.3.1 Item Effect Chart: Two formulas were created for the inputs of this chart. 5.3.1.1 Item Quality: (Rule 5) Formula: =IF(N32="","Normal Item",IF(OR( O32="", P32="", Q32= ""),"Magical Item", "Rare Item")) Table 5.3: Item Quality Formula 5.3.1.2 Number of Effects (Quantitative): (Rule 3 and Rule 4) Formula: =COUNTA(O2,R2,U2,X2,AA2) Table 5.4: Number of Effects (Quantitative) Formula
  • 47. 45 5.3.1.3 Item Effect Charts: Figure 5.2: Chart 1 - Item Effect Chart for Chest 1 using Mode 1 This chart shows that using the complete randomized mode 1, the items that were dropped from chest 1, had completely random number of effects. The number of effects determines the rarity of the item (whether Normal, Magical or Rare). This means that it did not follow the requirements of the item generation mechanic to generate items based on the level and magic find chance of the player and the chest. Figure 5.3: Chart 2 – Item Effect Chart for Chest 1 using Mode 2 This chart shows that using the rule-based randomized mode 2, the items that were dropped from chest 1, had random yet limited number of effects. The number of effects ranged from 0 to 2, which corresponds to Normal to lower Magical items. This means that this algorithm followed the requirements of the item generation mechanic to generate items based on the level and magic find chance of the player and the chest. See APPENDIX – E for all charts. 0 1 2 3 4 5 6 Player_0 Player_6 Player_12 Player_18 Player_24 Player_30 Player_36 Player_42 Player_48 Player_54 Player_60 Player_66 Player_72 Player_78 Player_84 Player_90 Player_96 Player_102 Player_108 Player_114 Player_120 Player_126 Player_132 Player_138 Player_144 Player_150 Player_156 Player_162 Player_168 Player_174 Player_180 Player_186 Player_192 Player_198 NumberofEffectsinanItem Number of Test Cases by 200 simulated players Mode 1: Chest 1: Item Effect Chart 0 effect is a Normal, 1-3 effects is a Magical and 4-5 effects is a Rare Item 0 1 2 3 4 5 6 Player_0 Player_6 Player_12 Player_18 Player_24 Player_30 Player_36 Player_42 Player_48 Player_54 Player_60 Player_66 Player_72 Player_78 Player_84 Player_90 Player_96 Player_102 Player_108 Player_114 Player_120 Player_126 Player_132 Player_138 Player_144 Player_150 Player_156 Player_162 Player_168 Player_174 Player_180 Player_186 Player_192 Player_198 NumberofEffectsinanItem Number of Test Cases by 200 simulated players Mode 2: Chest 1: Item Effect Chart 0 effect is a Normal, 1-3 effects is a Magical and 4-5 effects is a Rare Item
  • 48. 46 5.3.2 Error Chart: This chart checks for correctness of the items that were generated based on clarity and meaningful data. For example, if a sword was generated that has an effect like „+50% to Defense rating‟, that would be incorrect because the item was a weapon type and the effect is meant for defensive items. Another example is, if a sorceress only wand has an effect like „+2 to Paladin skills‟, that would be incorrect, because a Paladin would never be able to equip it. This chart checks this limitation of the items for correctness and plots it in a graph. These limitations or boundary values form the sample set for a possible value, which is the defining rule. There are 7 conditions being checked for correctness of items. They are described below. 5.3.2.1 Level Check: (Rule 1 and Rule 2) Formula: =IF(OR(M2 > (C2+5), M2 < (C2-5)), FALSE, TRUE) Table 5.5: Level Check Formula This formula checks to see if the level of the item is within a range of +/- 5 of the players‟ level. For this research, this is an acceptable range for an appropriate item level. The formula displays True in green if it is within this range and False in Red if lies outside.
  • 49. 47 5.3.2.2 Requirement Check: (Rule 9 and 10) Formula: =AND(IF(ISNUMBER(FIND("Strength",$N2,1)), IF(ISNUMBER(MATCH($J2,'Item Type Classification'!$B$2:$B$22,0)), TRUE, FALSE), TRUE), IF(ISNUMBER(FIND("Dexterity",$N2,1)), IF(ISNUMBER(MATCH($J2,'Item Type Classification'!$C$2:$C$7,0)), TRUE, FALSE), TRUE), IF(ISNUMBER(FIND("Energy",$N2,1)), IF(ISNUMBER(MATCH($J2,'Item Type Classification'!$D$2:$D$7,0)), TRUE, FALSE), TRUE), IF(ISNUMBER(FIND("Amazon Class Only",$N2,1)), IF($J2 = "Amazon's Spear/Bow", TRUE, FALSE), TRUE), IF(ISNUMBER(FIND("Assassin Class Only",$N2,1)), IF($J2 = "Katar", TRUE, FALSE), TRUE), IF(ISNUMBER(FIND("Barbarian Class Only",$N2,1)), IF($J2 = "Barbarian Helm", TRUE, FALSE), TRUE), IF(ISNUMBER(FIND("Druid Class Only",$N2,1)), IF($J2 = "Druid Helm", TRUE, FALSE), TRUE), IF(ISNUMBER(FIND("Necromancer Class Only",$N2,1)), IF($J2 = "Necromancer Head", TRUE, FALSE), TRUE), IF(ISNUMBER(FIND("Paladin Class Only",$N2,1)), IF($J2 = "Paladin Shield", TRUE, FALSE), TRUE), IF(ISNUMBER(FIND("Sorceress Class Only",$N2,1)), IF($J2 = "Sorceress Wand", TRUE, FALSE), TRUE)) Table 5.6: Requirement Check Formula This formula check to see if the requirements generated for the item is correct or not. Strength attribute is typically for melee weapons and armour, Dexterity attribute is for ranged items or highly skilled melee weapons, and Energy attribute is for magic type items and finally there are class specific items that should state class specific requirements. If there is a mismatch in these requirements then this formula sets the value to False, else it is set to True. 5.3.2.3 Effects Check: (Rule 6, Rule 7 and Rule 8) Formula: = IF($O2 = "", TRUE, IF(ISNUMBER(MATCH($O2,'Item Type Classification'!$J$2:$J$20,0)), IF(ISNUMBER(MATCH($J2,'Item Type Classification'!$F$2:$F$17,0)), TRUE, FALSE), IF(ISNUMBER(MATCH($O2,'Item Type Classification'!$K$2:$K$20,0)), IF(ISNUMBER(MATCH($J2,'Item Type Classification'!$G$2:$G$12,0)), TRUE, FALSE), IF(ISNUMBER(MATCH($O2,'Item Type Classification'!$L$2:$L$8,0)), IF(ISNUMBER(MATCH($J2,'Item Type Classification'!$H$2:$H$8,0)), TRUE, FALSE), TRUE))))
  • 50. 48 Table 5.7: Effects Check Formula This formula checks to see if the effect generated is meant for that item type and also if the values match the item level. If it does it sets the value to True, else it is set to False. This formula is applied for all the 5 effects generated. 5.3.2.4 Final Error Check: Formula: =IF(OR($AH2 = FALSE, $AI2 = FALSE, $AJ2 = FALSE, $AK2 = FALSE, $AL2 = FALSE, $AM2 = FALSE, $AN2 = FALSE), 1, 0) Table 5.8: Final Error Check Formula
  • 51. 49 This is the final accumulated condition that checks to see if the 7 conditions: Level, Requirement, Effect 1, Effect 2, Effect 3, Effect 4 and Effect 5 conditions have been satisfied. If so, then it sets the value 0 which represents an acceptable item, else it sets the value 1 for an unacceptable item. Also notice how the table row will display a completely green row for the 7 conditions if it is an acceptable item. These formulas are applied for all the 12,000 items and the chart has been drawn to plot them statistically. 5.3.2.5 Error Charts: Figure 5.4: Chart 3 – Error Chart for Chest 1 using Mode 1 Notice how all but 3 items have been plotted as invalid/incorrect items. This statistically means that the chance of generating invalid items using my complete randomized algorithm is 11,997 in 12,000 or 99.975 %. Figure 5.5: Chart 4 – Error Chart for Chest 1 using Mode 2 0 1 Player_0 Player_6 Player_12 Player_18 Player_24 Player_30 Player_36 Player_42 Player_48 Player_54 Player_60 Player_66 Player_72 Player_78 Player_84 Player_90 Player_96 Player_102 Player_108 Player_114 Player_120 Player_126 Player_132 Player_138 Player_144 Player_150 Player_156 Player_162 Player_168 Player_174 Player_180 Player_186 Player_192 Player_198 Mode 1: Chest 1: Error Chart 1 is an invalid Item and 0 is a valid Item 0 1 Player_0 Player_6 Player_12 Player_18 Player_24 Player_30 Player_36 Player_42 Player_48 Player_54 Player_60 Player_66 Player_72 Player_78 Player_84 Player_90 Player_96 Player_102 Player_108 Player_114 Player_120 Player_126 Player_132 Player_138 Player_144 Player_150 Player_156 Player_162 Player_168 Player_174 Player_180 Player_186 Player_192 Player_198 Mode 2: Chest 1: Error Chart 1 is an invalid Item and 0 is a valid Item
  • 52. 50 Notice how all the items have been plotted as valid/correct items. This statistically means that the chance of generating invalid items using my rule –based randomized algorithm is 0 in 12,000 or 0%. Since the rules were defined the same way as the formulas, the result must be 0%. 5.3.3 Final Error Table: Chest Number Chance of Error in Mode 1 (Complete Random) Chance of Error in Mode 2 (Rule-based Random) Chest 1 99.975 % 0 % Chest 2 99.975 % 0 % Chest 3 99.983 % 0 % Chest 4 100 % 0 % Chest 5 99.967 % 0 % Chest 6 99.975 % 0 % Chest 7 99.95 % 0 % Chest 8 100 % 0 % Chest 9 99.983 % 0 % Chest 10 99.992 % 0 % Table 5.9: Table of Errors between the two Modes This final table shows the percentage of errors occurred using both types of algorithms. The amount of errors in Mode 1 is extremely high because in the algorithm there is no control over the sample set for the random algorithm so the chance of generating a valid item is extremely small, so repeated sampling will be required using this approach to eventually get a valid item, where as in Mode 2, the sample set is initially calculated by the rules so any possibility chosen by the random algorithm will never have a chance of error always generating a valid item. 5.3.4 Complete Analysis: Please find the rest of the Item Effect charts and Error charts for all 10 chests using both modes in APPENDIX – E. The Item Type Classification which contains all the arrays in the excel report used by the formulas is also displayed in APPENDIX – E.
  • 53. 51 - Chapter 6 - CONCLUSION AND FUTURE WORK 6.1 Conclusion: After analyzing all the results from this application a few things have become clear and can now be verified. Firstly, rules or constraints are necessary in designing a random algorithm for item generation mechanics. It would be possible to use an unconstrained random algorithm, but that would result in obtaining a lot of unusable items and so the algorithm would have to be repeatedly executed until a useful item is generated. This approach is less efficient and more time consuming. The rule-based random algorithm, however, will always generate items that fall within the function curve or within the accepted region, thus eliminating the need to repeat the procedure. Secondly, we can conclude that not only is the number of rules required to govern the selection process important but also the rules themselves. The decision to select a rule must be made in order to eventually increase the replay value of the game. So if that means that class specific items with class specific effects will improve the item generation mechanic for improved and increased play time, then it is a good rule to have. There are many role playing games today that do not implement certain rules in item generation, for instance Dragon Age 1 and 2. There are many chest and monsters that have predefined drops programmed into the game. This means that the player will eventually get those items in every play through. Thus this mechanic remains at a mediocre level as compared to Diablo or Fate‟s mechanic. Another example of a rule that should be implemented is generating effects only meant for defensive, offensive, ranged or magical items. This makes it more meaningful to the player and increases playability thus making item farming more fun. Thirdly, the increased playability of the game also increases the shelf life of the game and improves the overall game rating thus improving popularity. There are many features that contribute to a games rating but for role playing games, item generation is a key factor for the
  • 54. 52 purpose of customization of the playable character. This also increases the odds of players wanting to buy more downloadable content and expansion packs for the game. A brilliant example of this is the Warrior, Rogue and Mage DLC‟s packs for Dragon Age 2 (Bioware, 2011). Their only intent was to give the player better equipment to play the entire game again for each class and they did it again with the second set of item packs for each class. The studio makes more money because of introducing DLC‟s since the players want to play the game again with better equipment. Finally the consumers who play the game feel satisfied that their investment in the game was worth it and that they can expect similar or improved mechanics in games from this developer, thus increasing loyal fans to the company. 6.2 Unimplemented ideas: The completion of this project doesn‟t mean that everything went according to plan from the very beginning. There were a few planned ideas that were not implemented in the end, which is described in this section. There was a plan to implement other mechanics that use random algorithms in role playing games like dialogue generation and quest generation. But after realizing the vastness of the research and the amount of work involved in implementing them in the application during this short period, it was cut from the project. The project was also planned to include a reusable data structure like a tree or a linked list for maintaining the data (Items types, Effects and their values, etc). Later for ease of use various arrays were used to store the information. The game was also to have a name generation algorithm, which would be a combination of prefixes, item type and suffixes to give the items some personality. But due to lack of time, this was not implemented. Due to the lack of resources available, most of the graphics, effects and sounds were taken from the game Diablo 2 which is trademark of Blizzard Entertainment (Blizzard, 2000). I have only borrowed the images and sound for educational and research purposes. Only one model was available for importing into the game which was obtained from DirectX 9.0 sample projects, even though there are seven classes of players.
  • 55. 53 6.3 Future Work: The primary reason for me to choose this topic for my research was because like many role playing game fans out there, collecting items is an addiction for me. So I wanted to research more about its algorithms so I could understand how the mechanic works and how to improve it. But another important reason for choosing this topic was because after searching through many portals and libraries, I couldn‟t find many useful research documents discussing item generation algorithms in detail. This would probably be due to the fact that such algorithms are proprietary to the developing company. So I decided that my research could be a good starting point for others interested in doing similar research in this topic and how to go about implementing it. Given time I could see myself working on enhancing my application by implementing the name generation algorithm using prefixes and suffixes. It would also be beneficial to modify the data structures to a more reusable and upgradeable one, like a linked list. This would also give an easier opportunity to append to the list of effects. With more time to research, more creative and useful rules could be defined to enhance the mechanic as well. This project could also be enhanced by implementing a simple encounter with an enemy and the items could be dropped from the enemy instead of the chest. Looking at the horizon, we see a glimpse of newer and better item mechanics coming to fruition. The all time classic Diablo is returning in the third instalment of the series and promises to be more engrossing than ever. Blizzard plans to introduce a currency-based auction house where players can go looking for exactly what they want and buy/sell it for real money. They have already introduced it in their beta test (Blizzard, Dec, 2011). Besides that, they will introduce artisans who are non-playing characters who can upgrade items for a price (Blizzard, Dec 2011). This will enhance items farming to almost limitless possibilities. And the day will come when even those mechanics will seem incomplete to core RPG fans.
  • 56. 54 REFERENCES AND BIBLIOGRAPHY Arsenault, D., 2005. Abstract of Dynamic Range: When Game Design and Narratives Unite. s.l.:University of Montreal. Bioware, 2011. DA2 Add-Ons. [Online] Available at: http://dragonage.bioware.com/da2/addon/ [Accessed 20 December 2011]. Blizzard, E., 1996. Blizzard Entertainment: Legacy Games. [Online] Available at: http://us.blizzard.com/en-us/games/legacy/ [Accessed 28 November 2011]. Blizzard, E., 2000. Diablo 2. [Art] (Entertainment, Blizzard). Blizzard, E., Dec 2011. Game Guide Updated: Artisans. [Online] Available at: http://us.battle.net/d3/en/blog/4059594/Game_Guide_Updated_Artisans- 12_6_2011#blog [Accessed 17 December 2011]. Blizzard, E., Dec, 2011. Currency-Based Auction House Beta Testing. [Online] Available at: http://us.battle.net/d3/en/blog/4024156 [Accessed 17 December 2011]. Buzacott, J. A. & Shanthikumar, J. G., 1993. Stochastic Models of Manufacturing Systems. s.l.:Prentice Hall. Cleve, M., Feb 2008. Chapter 9: Random Numbers. In: s.l.:s.n., p. 1. Ditchburn, K., 2011. SoundPlayer Utility. s.l.:s.n. Flux, e. a., Dec, 2008. Item Generation Tutorial:. [Online] Available at: http://diablo2.diablowiki.net/Item_Generation_Tutorial#Short_Explanation_of_Drop_Process [Accessed 27 Nov 2011]. hijo_del_escorpion, 2011. Dragon Age 2: Two Acts out of Three Ain’t Bad. [Online] Available at: http://www.ign.com/blogs/hijo_del_escorpion/2011/03/14/dragon-age-2-two-acts-out-of- three-ain%E2%80%99t-bad [Accessed 3 December 2011]. Krakou, 2003. Full Diablo 2 Items Pack. [Online] Available at: http://www.wc3c.net/showthread.php?t=16232 [Accessed 30 11 2011].
  • 57. 55 Kronika, 2009. Ciekawostki. [Online] Available at: http://diablo1.ovh.org/?ciekawostki,78 [Accessed 28 November 2011]. Kushner, H. J., 1977. Probability methods for approximations in stochastic control and for Elliptic Equations. V. 129 ed. s.l.:Academic Press, Inc. Max Libbrecht, e. a., Sept 2011. Wikipedia. [Online] Available at: http://en.wikipedia.org/wiki/Monte_Carlo_algorithm [Accessed 12 Nov 2011]. Microsoft, 2010. Dwarf Model. [Art] (Microsoft). Pengelly, J., Feb 2002. Monte Carlo Methods. s.l.:s.n. Prof. Luna, F., 2011. d3dUtility. Dundee, Abertay: s.n. Prof. Whitehead, J., January 2007. Definitions of Games and Play, Magic Circle, Rules as Limitations and Affordances. Creative Commons Attribution 2.5 ed. Santa Cruz: University of California. Samuel, R., 2011. Master's Project(CGT) - Rule-Based Probability for Random Content generation in RPG's. [Online] Available at: http://rejoshsamuel-mastersprojectcgt.blogspot.com/ [Accessed Jun-Dec 2011]. TurboSquid, 2011. Wall and Floor textures. [Art] (TurboSquid.com). Virginia, U. o., Aug 2006. Chapter 11: Markov Chains. s.l.:s.n. Walrand, J., August 25, 2004. Probability Space. In: Lecture Notes on Probability Theory and Random Processes. Berkeley, CA: s.n., pp. 13-17. Wikipedia, 2011. Las Vegas algorithm. [Online] Available at: http://en.wikipedia.org/wiki/Las_Vegas_algorithm [Accessed 19 11 2011]. Wikipedia, Nov 2011. Monte Carlo Method. [Online] Available at: http://en.wikipedia.org/wiki/Monte_Carlo_method [Accessed 15 Nov 2011].
  • 58. 56 APPENDIX – A Bertrand's Paradox (Walrand, August 25, 2004) The point of this note by Jean Walrand is that one has to be careful about the meaning of “choosing at random." Consider the following question: What is the probability that a chord selected at random in a circle is larger than the side of an inscribed equilateral triangle? There are three plausible answers to this question: 1=2, 1=3, and 1=4. Of course, the answer depends on how we choose the chord. Figure A.1: Three ways of choosing a chord. Answer 1: 1=3 The first choice is shown in the left-most part of Figure A.1. To choose the chord, we fix a point A on the circle; it will be one of the ends of the chord. We then choose another point X at random on the circumference of the circle. If X happens to be between B and C (where ABC is equilateral), then AX is longer than the sides of ABC. Thus, the requested probability is 1/3. Answer 2: 1=4 The second choice is illustrated in the middle part of Figure A.1. We choose the chord by choosing its midpoint (e.g., X) at random inside the circle. The chord is longer than the side of the inscribed equilateral triangle if and only if X falls inside the circle with half the radius of the original circle, which happens with probability 1/4. Answer 3: 1=2 The third choice is illustrated in the right-most part of Figure A.1. We choose the chord by choosing its midpoint (e.g., X) at random on a given radius OA of the circle. The chord is longer than the side of the inscribed triangle if an only if the point is closer to the centre than half a radius, which happens with probability 1/2.
  • 59. 57 APPENDIX - B Simpson's Paradox (Walrand, August 25, 2004) Jean Walrand states that proportions do not add up and points out that one has to be careful with statistics. Consider a university where 80% of the male applicants are accepted but only 51% of the female applicants are accepted. You will be tempted to conclude that the university discriminates against female applicants. However, a closer look at this university shows that it has only two colleges with the admission records shown in the table. Note that each college admits a larger fraction of female applicants than of male applicants, so that the university cannot be accused of discrimination against the female students. It happens that more female students apply to a more difficult college. College F.Appl. F. Adm. %F. Adm. M. Appl. M. Adm. %M. Adm. A 980 490 50% 200 80 40% B 20 20 100% 800 720 90% Total 1000 510 51% 1000 800 80% Table B.1: Example for Simpson’s Paradox
  • 60. 58 APPENDIX - C Short Explanation of Drop Process (Flux, Dec, 2008): When you kill a monster or open a chest the game may generate items to reward you. The properties of these items are generated at that moment, even though the item may be unidentified. The game creates dropped items with algorithm of such kind: 1. At the beginning it finds treasure class (TC), that describes all drops of the monster you killed, a chest you opened, a hidden stash you found, etc. All drop sources have treasure classes. 2. The game then makes one or several iterations that are called "Picks", when it selects one choice from several possibilities. 1. One of the possibilities is "NoDrop", which does what it sounds like. Many monsters have multiple "picks," so even if one of them is NoDrop, the other picks may overrule it. Most normal monsters have only one pick, though. 2. If nothing is selected from the first TC, the next one down the list will be consulted, then the next, then the next, until an item or NoDrop is selected. 3. Once an item is selected, the item properties are determined. Since most items have numerous possible types, game's algorithm of quality determination is highly complicated. Items such as keys, runes, and potions are only found in normal quality, but items like rings, short swords, helms, and bucklers have different qualities like magic or unique. Note that Magic Find is checked during this step. 4. For every selected item an ilvl is calculated. 5. If the rarity check hits upon an item of unique or set quality, the game creates the list of all valid item types (determined by their ilvl) and randomly selects one to drop. If there is not a unique of that type, a rare item with triple durability will generate. If there is no set item of the selected type, a magical item with double durability will appear. 6. After the game selects item type and item quality, it generates item affixes if needed. It also generates all other properties of an item, if there are such properties. Items like Runes, mana potions, and identify scrolls doesn't have variable properties, but magic rings, rare kite shields, cracked sashes needs property generation.
  • 61. 59 APPENDIX - D Results Tables: Table D.1: Completely Random Algorithm (Mode 1) Items Table D.2: Rule-based Random Algorithm (Mode 2) Items
  • 62. 60 APPENDIX - E Item Effect Charts: Completely Randomized Algorithm (Mode 1) Figures E.1, E.2 and E.3: Item Effect Chart for chests 1, 2 and 3 using Mode 1 0 1 2 3 4 5 6 Player_0 Player_6 Player_12 Player_19 Player_25 Player_31 Player_38 Player_44 Player_50 Player_57 Player_63 Player_69 Player_76 Player_82 Player_88 Player_95 Player_101 Player_107 Player_114 Player_120 Player_126 Player_133 Player_139 Player_145 Player_152 Player_158 Player_164 Player_171 Player_177 Player_183 Player_190 Player_196 NumberofEffectsinanItem Number of Test Cases by 200 simulated players Mode 1: Chest 1: Item Effect Chart 0 effect is a Normal, 1-3 effects is a Magical and 4-5 effects is a Rare Item 0 1 2 3 4 5 6 Player_0 Player_6 Player_12 Player_19 Player_25 Player_31 Player_38 Player_44 Player_50 Player_57 Player_63 Player_69 Player_76 Player_82 Player_88 Player_95 Player_101 Player_107 Player_114 Player_120 Player_126 Player_133 Player_139 Player_145 Player_152 Player_158 Player_164 Player_171 Player_177 Player_183 Player_190 Player_196 NumberofEffectsinanItem Number of Test Cases by 200 simulated players Mode 1: Chest 2: Item Effect Chart 0 effect is a Normal, 1-3 effects is a Magical and 4-5 effects is a Rare Item 0 1 2 3 4 5 6 Player_0 Player_6 Player_12 Player_19 Player_25 Player_31 Player_38 Player_44 Player_50 Player_57 Player_63 Player_69 Player_76 Player_82 Player_88 Player_95 Player_101 Player_107 Player_114 Player_120 Player_126 Player_133 Player_139 Player_145 Player_152 Player_158 Player_164 Player_171 Player_177 Player_183 Player_190 Player_196 NumberofEffectsinanItem Number of Test Cases by 200 simulated players Mode 1: Chest 3: Item Effect Chart 0 effect is a Normal, 1-3 effects is a Magical and 4-5 effects is a Rare Item