scieee AI-readable full text Open interactive document viewer

ScripTale: generation of procedural narrative

Ripoll Galan, Laura

Abstract

The subject of research is the procedural narrative. Procedural narrative is the way of generating narrative automatically along with the progress of the game. More specifically, the subject of the study will be about exploring the way procedural narrative could be implemented in a project and through with a tool external to the code of the game itself.

Full text

  ScripTale  : Generation of Procedural Narrative  Bachelor’s thesis Design and Development of Video Games    Author: Ripoll Galan, Laura Director: Torelló Oliver, Josep CITM (UPC) - Terrassa Course: 2017 - 2018 Scheme: 2014   Generation of Procedural Narrative Ripoll Galan, Laura Abstract The subject of research is the procedural narrative. Procedural narrative is the way of generating narrative automatically along with the progress of the game. More specifically, the subject of the study will be about exploring the way procedural narrative could be implemented in a project and through with a tool external to the code of the game itself. Key words and notation AI: Artificial Intelligence PN: Procedural Narrative PCG: Procedural Content Generation LL: Linear Logic GOAP: Goal Oriented Action Planning States: Resultant variables of each character after an action Conditions: Rules to be ascertained to develop an action Actions: Performance of an available option of the character Messages: Content of the dialogue said by a character towards another      1  Generation of Procedural Narrative Ripoll Galan, Laura  Index  Abstract 1 Key words and notation 1 Index 2 Index of figures and images 5 Index of tables 6 1. Introduction 7 1.1. Project justification 7 1.1.1. Motivation 7 1.1.2. The problem 7 1.2. Aim of the project 8 1.2.1. General goals of the project 8 1.2.2. Specific goals of the project 8 1.3. Project scope 9 2. State of the art 10 2.1. NPCs. Learning the player’s way of play 11 2.2. Voice recognition and realistic graphics 12 2.3. Procedural Content Generation 14 2.4. ANGELINA 15 2.5. Procedural Narrative 15 2.6. The tool: ScripTale 17 3. Planning 19 3.1. Gantt chart 19 3.1.1. Tasks description 19 2  Generation of Procedural Narrative Ripoll Galan, Laura 3.1.2. Chart 22 3.2. SWOT 24 3.2.1. Analysis 24 3.2.2. Contingency plan 26 3.3. Costs analysis 27 3.3.1 Costs overview 27 3.3.2. Costs breakdown 30 3.4. Management tools 33 4. Methodology 33 4.1. Tracking of the project 34 4.2. Validation tools 34 5. Development 36 5.1. Design of the tool 36 5.2. ScripTale Initial implementation 40 5.2.1. Curve Editor 40 5.2.2. States Editor 42 5.2.3. Relationships Editor 45 5.2.4. Dialogue System 46 5.2.5. Characters 47 5.2.6. Messages and actions 48 5.2.7. Emotions 49 5.3. Initial workflow of ScripTale 52 5.4. Last state of ScripTale 53 5.4.1. Curve editor 53 5.4.2. States Editor 54 5.4.3. Relationships Editor 55 5.4.4. Dialogue System 56 5.4.4. Characters 56 3  Generation of Procedural Narrative Ripoll Galan, Laura 5.4.5. Messages and Actions 60 5.4.6. Emotions 60 5.5. Final workflow of ScripTale 61 6. Conclusions 62 Bibliography 65 Annexes 68            4  Generation of Procedural Narrative Ripoll Galan, Laura Index of figures and images  Monte Carlo Tree Search Algorithm schema Fig. 2.1. Characters’ decision taking schema in The hare and the turtle Fig. 2.5. Gantt diagram Fig. 3.1.2. Design schema of the base classes of ScripTale Fig. 5.1.1. Design shema of the editors of ScripTale Fig. 5.1.2. Curve editor of ScripTale Fig. 5.2.1.a. Curve functions of ScripTale  necessary for the programmers Fig. 5.2.1.b. Schema of the States functionality Fig. 5.2.2. Schema of the Relationships functionality Fig. 5.2.3. Workflow of ScripTale Fig. 5.3. Relationships Editor of ScripTale Fig. 5.4.3. Current workflow of ScripTale Fig. 5.5. Simple example of use of TeLLer  provided by its creators Fig. 6.  5  Generation of Procedural Narrative Ripoll Galan, Laura Index of tables  Work Packages Table 3.3.1. a Partners  Table 3.3.1. b Budget Table 3.3.1. c  Human resources  Table 3.3.2 a  Software  Table 3.3.2 b  Hardware Table 3.3.2 c  Indirect costs Table 3.3.2 d         6  Generation of Procedural Narrative Ripoll Galan, Laura 1. Introduction 1.1. Project justification 1.1.1. Motivation The strongest justification of this project is my intrinsic motivation to link two of my               favourite fields in video games: Artificial Intelligence and narrative. Not only because            of my own interest in these two areas but also due to the high rate of difficulty                 involved and the amazing result that could be achieved by defeating the challenge             to unify both opposed behaviours, as narrative tends to be structured and AI             emergent. 1.1.2. The problem Nowadays, procedural methodologies in video games are spreading, from         animations to terrain creation and so, narrative. However, there is not any global             tool in Unity’s Asset Store to allow procedural narrative generation in games            developed with this popular engine. More investigation in this field is needed and a high demand of procedural narrative              exists in the industry. Some AAA games try to make such an approach but, these               implementations are not public and other developers could find it difficult to include             such a valuable feature on commercial engines like Unity. Some theoretical research has been carried out, however, there is no practical tool             to apply procedural narrative to real projects.   7  Generation of Procedural Narrative Ripoll Galan, Laura 1.2. Aim of the project The goal of the project is to program a tool in Unity that could be implemented in                 any game to generate procedural narrative through a dialogue system with the            existing characters. The tool will be submitted in a Unity package format to make it easier to put it in the                   Asset Store afterwards. If the tool has proved an interest in the community, a Demo               will be delivered as a Unity project so the code will be accessible to anyone and                also in a compiled game version. However, it is not an aim of this project but a                 further possible work beginning with the tool. To develop the entire project, be it the package of the tool, the engine to be used                 will be Unity. On the other hand, for scripts edition and code, Visual Studio will be                the IDE to work with. 1.2.1. General goals of the project -Generate a narrative with different results at each game: Make it possible            to generate different narrative with a same base system dialogue but with            unexpected results at each game. -Approach the tool to independent developers: Make a available tool to           improve narrative systems on independent games in the market. -Get the tool published in Asset Store: Accomplish all the requirements to            publish the result of this research, the tool, to the Asset Store in unity. 1.2.2. Specific goals of the project -Control an AI with unpredictable results: Being capable of controlling most           of the internal paths or processes of the AI without losing the surprise of              getting an emergent narrative situation. 8  Generation of Procedural Narrative Ripoll Galan, Laura 2.4. ANGELINA It can be relatively easily conceived that some areas such as art or sound can be                modulated and created alongside procedural generation but, Design seems         something untouchable that can only be done by human. Thinking up an entire             game from scratch is a task that is usually carried out by a designer. Withal,               ANGELINA is the practical validation of the potential of PCG, being able to             substitute this last task. Michael Cook is the 30-year-old senior research fellow at University of Falmouth            behind ANGELINA. The tool’s name stands for “A Novel Game-Evolving Labrat I’ve            Named Angelina.” He developed ANGELINA in 2011 and since then, Michael has            kept updating the tool. Meanwhile, ANGELINA has developed by itself hundreds of            experimental video games. The senior researcher is now working on Creative Code            Generation for Interactive Media. PCG is normally employed in video game development as a tool to aid in a specific                feature within a large creative vision that comes from a person. What Michael tries              to achieve with ANGELINA is to have a system that procedurally generates the             majority or even all the aspects of a game’s design by itself. 2.5. Procedural Narrative Procedural Narrative is the automatic process that generates narrative over time.           However, narrative is a structured story by definition so, balancing the emergency of             PCG and the structure of the narrative is the main conflict in procedural narrative.              Other procedural contents, have no need of a rule or structure to exist but the ones                imposed by the designer, whereas narrative does. A story needs to have a             beginning and an ending, with its relevant stages and conflict points. To build an emergent story, characters and AI will take more control of the actions               and the main weight of the narrative will be the interaction between characters and              15  Generation of Procedural Narrative Ripoll Galan, Laura their decision taking aspect. In this way, by letting the player some freedom, the              machine and the player will take turns to redrive the story to some desired states               established by the Designer (or not). To illustrate what has been brought up in Practices for Procedural Narrative            Generation  (Martens Chris, 2017), coming up with an schema could make it more            clear. So, a good example of story with a main plot determined by the characters’              decisions is the classical tale: The Hare and the turtle  . As can be seen in the                following schema, all the decisions brings the story to an end. Characters can plot              their own story:       For the implementation of AI there is not a correct set algorithm to follow, each               solution finds its own way: Deep Learning, Machine Learning, Finite State Machines,            Behaviour Trees, States, MCSTA… Theoretical studies from various universities,         such as the Development of an Emergent Narrative Generation Architecture for           Videogames (Schudlo, Nicholas A., 2014) point out one shared method for           procedural narrative: Linear Logic, a type of substructural logic. Substructural logic is the study of correct methods of reasoning characterized by            following three rules: 16  Generation of Procedural Narrative Ripoll Galan, Laura -The contraction rule: It states that any premise used for a valid            deduction, can remains valid only once. -The weakening rule: While a hypothesis of a valid deduction (not a            premise) remains valid, more premises can be added to it. -The exchange rule: Also called the permutation rule, it defines that           the order of premises is irrelevant to the validation of a deduction. Linear Logic is one exception in substructural logic due to its omission of the              contraction rule and the weakening rule.  Linear Logic emphasizes on the role of formulas as resources. To avoid focusing on              the truth or the proof from classic logic, it does not allow the application of the                contraction rule or the weakening rule to all the formulas but only to those marked               with certain modals. This way it has an involutive negation while keeping strong the              interpretation. Provided this focus on resources, Linear Logic is applied in           programming such as, in this case in procedural narrative which, as already seen is              based on rules and algorithms to control it.  2.6. The tool: ScripTale ScripTale  , name of the tool which is object of the current study, will begin from the                point of the theoretical investigations done in Procedural Narrative. That means it            will use the information asserted in these studies to progress. It will go further implementing in Unity what these studies have shown in papers.              Despite some AAA games such as The Witcher 3: Wild Hunt  (CD Projekt RED, 2015)               could have presented similar features or innovative narrative components, none of           them makes the code available and/or scalable, being closed and specific for the             game. The distinctive feature of ScripTale is the freedom, not only for offering the              17  Generation of Procedural Narrative Ripoll Galan, Laura tool to a wider range of studios but also for being able to adapt to any game made                  with Unity. This AI tool’s limitations yet would be positively reviewed for its specific purpose.             ScripTale depends on human input to work, the designer or the screenwriter. The             responsible of the narrative task would have to provide the tool with a minimum              amount of dialogue classified on the type of character that would say that sentence              and in which case. To let the tool work with the provided dialogue system, the               designer has to set the path of the story, the picks of intensity or the curve.                ScripTale will then, adapt the story and decision making to follow the established             rhythm. All this means that this tool can work with a dialogue to generate narrative               whilst the others in the market cannot.          18  Generation of Procedural Narrative Ripoll Galan, Laura 3. Planning 3.1. Gantt chart 3.1.1. Tasks description The description of the tasks chronologically ordered can be found below. All of             them are tagged showing the area they belong to.  Rubric 1 preparation: Prepare the contents of Rubric 1 and write them down on the document. Research of assets: Looking for assets of the project. Research of AI methods: Deep knowledge about the different methods that could be applied to the project. Schema of the tool: Design the functionality of the tool, scratch an UML and make a general schema of               how it will look like and how it will work. Initial tool: Programming the base of the tool by creating a minimum AI for the characters and               the basic interface for the tool.    19  Generation of Procedural Narrative Ripoll Galan, Laura Dialogue system: Create a basic dialogue system. Simple sentences but working with the logic            needed in the project (example of the logic: combine sentences to create new ones              from the features of the characters, for instance, adding tags). Programming of the dialogue system: Improve the base tool by adding the methods chosen. (Possibly, programming of            the methods without including dialogue system yet. That is contemplated in the            following step of fixing the tool). Test and fix the tool: Detect errors, make the code cleaner, and polish the dialogue and narrative. Rubric 2 preparation: Prepare the contents of Rubric 1 and write them down on the document. Improve dialogue: Add more sentences and expand the existing dialogue. Improve the GUI of the tool: Improve the tool’s interface, make the interface usable and the graphics appealing. Improve AI system: Improvement of the AI methods, fix the program’s errors. Project writing: End up with writing the document itself. Further stages of the project will be added               during the project revision part, at the end of it. Separate the tool from the game: Separate the game (in .dll format) from the tool (a unity package). The game should               have the tool applied in it. 20  Generation of Procedural Narrative Ripoll Galan, Laura Decorate the tool: Decide the name of the tool, create an icon, add extra features (such as sending the                script of the final story to the users). Narrative improvements: Last final minor improvements on the dialogue system or narrative. AI improvements: Last final minor improvements on the AI system of the tool. Overall project revision: No more programming or design to add new features will be done during these last               days, only bug fixing. If a task is not finished on time, then, it will be decided where                  and how to cut. Include everything new on the project document and ensure the              quality of the final tool. 21  Generation of Procedural Narrative Ripoll Galan, Laura 3.1.2. Chart     22  Generation of Procedural Narrative Ripoll Galan, Laura    23  Generation of Procedural Narrative Ripoll Galan, Laura 3.2. SWOT 3.2.1. Analysis Strengths: -Attractive offer: The offer itself is appealing. Not only does it provide a             dialogue system to reduce time and increase efficiency but also a narrative            complexity higher than the one that could be achieved without the tool. -Innovation: Innovation attracts the target to try something unknown if it has            been proved that to work. -Accessible: The target knows the place to get it and normally enters the             store. If the tool is attractive enough, they can easily manage to download it              and include it into a project. Target is used to it and that makes the tool                accessible. -User friendly: Easy to understand. There is no need of previous knowledge           to use it. The tool is intuitive and most of the functionality can be applied               through the UI, not through code. Weaknesses: -Unrecognised brand: There is no market behind waiting for the tool because          it is a new unknown brand. That makes it complicated to get popularity. -Innovation: Innovation can be both, a strength and a weakness at the same             time. Being considered innovative in a field where a lot of research has been              done, and is still being, is dangerous because it could mean that the idea              leads to failure. -Oriented to very specific games: Gameplay on games that will use the tool             may offer on an open-world scenario to allow the players to interact. Cannot             be applied in most of the mobile games developed by indies.  24  Generation of Procedural Narrative Ripoll Galan, Laura Software Software Price per unit Units Total cost Unity Plus license  360 €/unit 1 unit 360 € Microsoft Office  149 €/unit 1 unit 149 € Unity assets (Characters & Environments)  12 €/unit 2 units 24 € TOTAL  - - 533 €  -Assumptions:  The developers acquire a license for 1 year and 1 account.           Unity assets bought shall be low price assets but not some of the free ones.               Microsoft Office offers a license for 3 years, so it may be used in further               projects of the studio. Hardware  Hardware Price per unit Unit Lifetime Total cost Amortisation PCs  900 €/h 1 unit 5 years 900 € 60 € TOTAL  - - - 900 € 60 €  31  Generation of Procedural Narrative Ripoll Galan, Laura Indirect costs Type Price per month Amount of months Total cost Office rental  1200 €/unit 4 4800 € Light, water & other supplies  150 €/unit 4 600 € Self-employed quota  264.44/month and person 4 2115.52 € TOTAL  - - 7515.52 €  -Assumptions:  As the proper size of a small office is less than 100 m2, it is               assumed the property will sit on a 90 m2 surface, located in Barcelona.             Self-employed quota must be paid twice, having the developer and the           screenwriter as the main share-holders.     32  Generation of Procedural Narrative Ripoll Galan, Laura 3.4. Management tools Hacknplan and Trello will both be used to keep the track of the development.              Hacknplan tables may change for each milestone or in a short settled period. Trello,              meanwhile, is thought to be used to store a more general picture of the project, in                other words, all the project tasks will be specified in Trello as generic capsules that               could embrace multiple specific assignments. 4. Methodology In the videogames industry, it is common to use a pre-production, production and             post-production model-based methodology. However, this study does not consist         on a videogame itself but on a tool, therefore, this methodology will not work              efficiently on a project of this kind. An agile interactive method would be the most suitable to develop the project. The              different stages could change dynamically as it consists of a research that has to be               iterated, tested, and change continuously. Scrum is one of these methodologies           that would perfectly fit the project’s typology, so that is the one to be used. Scrum, being based on sprints, can be easily managed with such a management             tool like Hacknplan. Weekly stages: -Beginning of the week: A backlog update will be done and the tasks to be               developed over a week will be noted down. -During the week: Daily sprint review of the tasks done, balancing remaining           time/tasks and estimations established to get to know one own’s error rate. -End of the week: Try to close all the tasks. If that is not possible, draw to a                  close by deciding which features are to be cut given that the time is limited.  33  Generation of Procedural Narrative Ripoll Galan, Laura 4.1. Tracking of the project Hacknplan, as used for the management, will be accessible at any time of the              project and it will also show its progress, current, and past. As happens with Hacknplan, GitHub can also provide a good tool for monitoring the              project. Through all the commits, if described properly, it is possible to see the              advance. However GitBash will be used to commit all the project’s changes instead of             GitHub, tool which also allows this action, through GitHub will be used to check the               progress. Github provides an intuitive User Interface for this monitoring feature. 4.2. Validation tools To check the authenticity of the theoric information collected through internet,           consulting to a professional in this field will be done. E-mailing the Doctor in              Artificial Intelligence Chris Martens could be considered by itself a validation tool for             the investigation part. Before testing, because of using Unity as an engine, a suitable debug needs to be               done. Linking Unity to the IDE Visual Studio makes it possible not only to             implement the code but also to check it at the same instant, to debug it. Visual studio will also be used to test, but not as an exclusive tool, because testing                needs to be done by using the program and as such Unity Editor will meet this               needs. After having fixed the bugs found through this tool, another testing round will be              done by building the application. A testing scene will be creating during the testing              session to evaluate its effectivity in runtime, not only within the editors, but also the               AI scripts executing in game. 34  Generation of Procedural Narrative Ripoll Galan, Laura Validation is also required for the narrative aspect of the project so, in this case,               online tools will be used, for instance: correctors,synonym dictionaries and        dictionaries.                35  Generation of Procedural Narrative Ripoll Galan, Laura 5. Development The development process starts by conceiving the structure of the tool, deciding            which parameters to obtain by the input of a designer or which ones should be left                up to the tool thus the planning of further tasks gets easier. However, this led to structural problems on how many variables should be handled             by the designer and once decided and how an usable UI could be displayed leading               to the ease in managing and editing a vast number of parameters. For these reason, parameters to be handled have been divided into three different             fields: the relationships’ editor, the curve editor, the states’ editor. These editors,            however, need other structures to get to work, such as the characters with its              emotions and behaviours or the messages classified from the dialogue. Before the implementation, all of these had to be clearly designed to avoid             inconsistencies or negligible work. 5.1. Design of the tool After seeing other concepts of Procedural Narrative that can be found in the State              of Art section, letting the characters plot the story by their actions was the way to                start with the tool. However, with the new idea of including a dialogue to fit the                narrative, the Linear Logic method used in these other projects was not effective             enough and this other methods to be combined with were required in the             ScripTale  ’s implementation. To behave in a way or another, the characters will be driven by emotions and each                consequent state after an action should affect some characters in some way. So,             the emotional component is added now to the linear logic relatives states. At this point, the necessity of including a grade of importance was needed on how               the characters would be affected. Consequently, the tool should include weights. All            the interactions with the characters would affect them in some way so, all the inputs               36  Generation of Procedural Narrative Ripoll Galan, Laura are designed to control emotions, and emotions will drive the story. States (results             of the actions performed) and messages (what players say) have emotional           implication. This emotional implication is translated into a natural behaviour of the characters in             taking actions. To sum up, in this tool, actions are still plotting the story but, being                affected by the emotions resultant of the original characters’ behaviour and other            characters’ actions, so as to get a fitting dialogue in all this procedural generation of               narrative. The artificial intelligence of the tool works with linear logic and weights. - AI concepts: Working with weights means implementing a Goal Oriented Action Planning          (GOAP). It is a system that allows the agents (characters) to plan a sequence of               actions to satisfy an aim. This sequence of actions depends not only to the goal but                also on the current state of the agent. Each possible action has multiple weights of necessities it will satisfy. However, the             actions available can present a condition. That is the point where the current project              combines Linear Logic (LL) with GOAP. LL will ensure that an action cannot be done until another one has ended, an item                has been consumed or, on the other hand, some actions can happen            simultaneously. Linear Logic states the conditions and the end point of each action. ScripTale  implements LL to decide the available spectrum of actions from the           current states, the possible ones and the demand of the intensity curve. GOAP is              used after to get the most likely action or message to occur given the character               current state and the available actions filtered by the Linear Logic step.    37  Generation of Procedural Narrative Ripoll Galan, Laura - Initial design schemas to start implementing: All the elements in the schemas were added and modified by the schemas’ own              nature if they had two follow the two rules of: emotional implication for the decision               making and actions to plot the story. Base Classes     38  Generation of Procedural Narrative Ripoll Galan, Laura Editors       39  Generation of Procedural Narrative Ripoll Galan, Laura 5.2. ScripTale  Initial implementation 5.2.1. Curve Editor The curve editor provided to the designer is meant to be driving the story through               an intensity path desired. It would allow the designer to control the time the climax               will happen or the more relaxing parts of the story.     - Problems: The curve editor actually did not suppose any striking problem. The only trouble             that was generated had been when ScripTale was applied to a game consisting of              narrative parts (interactive parts where developing the plot of the story) and            gameplay parts, the curvature was still advancing in time. The problem was easily             solved by adding an option to pause the curve by calling a function, if the narrative                needs to be stopped, and resume it when required. However, despite the tool is thought to be used by designers, this lead to the               simplest as well as major inconvenient of ScripTale  . It is the programmer, not the              designer who has to take the already mentioned problem into account. The solution             40  Generation of Procedural Narrative Ripoll Galan, Laura To break the limitations of this kind of software, the Dialogue System was changed              to work, as it currently does, through Google Drive. The Asset Store of Unity and even other platforms on the Internet, provide Plugins              to integrate the use of spreadsheet Excel in a project. However, ScripTale works             with document files, not Excel, and, as it was complicated to find a Plugin with this                functionality, this one was implemented in the code of the tool itself through the              Google Drive API without any other Plugin. The research of Plugins and the final              decision of coding the desired functionality were the two main problems that            appeared after solving the precedent conflict relative to software licenses. 5.2.5. Characters Characters are entities with an id different one to each other to be quickly identified.               They will also own a stack of events, each event consisting on a structure with a                pointer to another character and an array of emotions. The stack pretends to simulate a memory, it keeps track of what has happened to               the character and what could break or modify a relationship. Finally and the most important, the character is constituted by two sets of emotions.              The original ones that define it and determine its way of acting and behaviour. If a                character tends to be aggressive by nature (high level of rage emotion by default),              for instance, a message transmitting rage will increase the rage current state of the              character. - Problems: Characters must have a memory to keep track of what has happened. However, the              knowledge of the events is not taken in consideration. These caused two problems: - Messages did not have any effect on them at any moment if they are not               applied to the character. 47  Generation of Procedural Narrative Ripoll Galan, Laura - The character is affected even if it doesn’t know the source of its emotions              because has not received directly the message or the action. A temporary solution is not to apply an effect of a message that has not been                 received directly by the character and apply the effect if it gets to know it. It is                 complicated, though, to track if it discovers a message that is already in its memory               stack. 5.2.6. Messages and actions Messages and actions are actually the same thing. Both of them consist on             structures containing the id of the character emitter, the one of the receiver and a               dictionary with the ids of the characters affected as keys and the array of emotions               that the message or the actions produced. The difference between messages and actions is the output. Messages are meant            to pick a type of dialogue depending on the emotions of the emitter character and               to create an effect on the receiver. This is, then, the output of the message.               However, an action derives to an state. It is also chosen by the emotional state of                the character, however, in this case, it takes into account the conditions of the              story. To quickly pick up a message from all the loaded ones, these are the helper               functions called by ScripTale  when building the dialogue.    public static List<Message> GetMessagesByEmotion(EmotionType emotion) { return messages.FindAll(m => m.effect.emmotion == emotion); } 48  Generation of Procedural Narrative Ripoll Galan, Laura public static List<Message> GetMessagesByEmotionAndLevel(EmotionType emotion, float level, float threshold) { return messages.FindAll(m => m.effect.emmotion == emotion && (m.effect.level <= (level + threshold) && m.effect.level >= (level - threshold))); }   - Problems: Although actions are messages are conceptually the same type of structures,           messages are not supposed to be able to get to a state and so, it could be difficult                  to reach to a state. Some possible solutions were or choosing an action right after a                dialogue happens, which would still feel antinatural to cut a conversation and start             an action immediately; another one could be to start an action depending on the              resultant states after a conversation. This last one is the approach taken in this tool,               despite there are probably better implementations to solve it. 5.2.7. Emotions As it has been stated multiple times in the current document, characters, messages,             actions and states are based on emotions. In a more technical aspect emotions             consist on structures which simply contain the enum type of emotion and a float              value corresponding to the level.      49  Generation of Procedural Narrative Ripoll Galan, Laura  The basic emotions to define a character are:   public enum EmotionType { Grief, Loathing, Rage, Vigilance, Ecstasy, Admiration, Terror, Amazing, None }  All of them have been chosen to achieve a human-like realistic behaviour and             different archetypes of characters by mixing various levels of emotions. On the            basis of that postulate, the feelings that have been applied in the current project              actually follow the ones that are thought to constitute the human being. Plutchik R.              (1927 - 2006) had developed a wheel of emotions to describe the people with              feelings. This has been the inspiration for the EmotionType choice of options. - Problems: Before realizing some research on psychological papers was needed to develop a            variate and spectrum of emotions to define a character, these basic feelings where             needed. However it was complicated to pick up the right choice of emotions that              50  Generation of Procedural Narrative Ripoll Galan, Laura could be combined to get different behaviours without any psychological          knowledge. The real matter about the inclusion of emotions in the project was the unexpectancy              of the task itself. It was not taken into consideration at the time of the planning.                However, due to the nature of research of this project, these emergent situations             were thought to occur so, some generic tasks include in themselves investigation            and implementation. The Gannt chart can, then, remain the same, as “Emotions”            can be considered a task inside the “Dialogue system  ” one.                51  Generation of Procedural Narrative Ripoll Galan, Laura 5.3. Initial workflow of ScripTale The big picture of ScripTale  would look like this schema.                  52  Generation of Procedural Narrative Ripoll Galan, Laura 5.4. Last state of ScripTale 5.4.1. Curve editor The tool has definitely removed the Curve editor because of design incongruities.            First of all, usage of the tool gets more complicated as more elements are being               added. Moreover, sTaleCharacters have currently been totally programmed and         have a huge impact on design, so more items to control were being developed.              What is more, story had very little influence in the story and its perks were fewer                than the problems it caused. It was only taken into account to get the next possible                state, depending on the intensity on time. The corresponding function in which the curve was involved was the following.            Were the tool just got the intensity directrices from it and combined it with the               intensity requirements of each of the states. Then it took the most suitable state for               the established curve.  private static void GetNextState() { float intensity = sTaleCurve.GetCurveState(); float[] level = new float[current_state.children.Count]; for (int i = 0; i < current_state.children.Count; ++i) { float average = 0; int count = 0; for (int e = 0; e < current_state.children[i].content.returnEffect.Count; ++e) { for (int c = 0; c < current_state.children[i].content.returnEffect[e].conditions.Count; ++c) { average += current_state.children[i].content.returnEffect[e].conditions[c].level; count++; } } 53  Generation of Procedural Narrative Ripoll Galan, Laura average = average / count; level[i] = Mathf.Clamp(current_state.children[i].content.conditionsSet * average, 0.0f, 100.0f); } int following_index = 0; for(int lev = 0; lev < level.Length; ++lev) { if(Mathf.Abs(intensity - level[lev]) < Mathf.Abs(intensity - level[following_index])) { following_index = lev; } } following_state = current_state.children[following_index]; }  The states Editor is a way itself to control the intensity depending on the conditions               set by the designer and no further editors should be needed to accomplish this aim. 5.4.2. States Editor The States Editor functionality remained almost the same as what was initially            designed and implemented. As the decision of removing the intensity curve was            removed, the next state to follow in the tree had to be decided in a self-contained                way. Without the input of the designer to plot the path, the tool had to do it by itself,                   so GOAP takes more relevance in this process. Various goals were planned for each state. From the current state, the story has              different aims. To decide which one to take, the tool checks the conditions in each               of these states and calculates the distance between the current emotional level of             the character and the level set in the condition. The one to be choose is the most                 likely to happen. In technical terms, the cheapest option, the one that would take              less iterations. 54  Generation of Procedural Narrative Ripoll Galan, Laura 5.4.3. Relationships Editor This editor remains the same as was planned. When the editor is first opened, all               the characters appearing in the story have to be already put in the scene. All of                them will appear as a node and when they are connected to each other, their               relationship has to be set. The relationships can be saved in an own extension file               and this file or other files derived from the editor can be assigned to the ScripTale                prefab to be used over the course of the game.         55  Generation of Procedural Narrative Ripoll Galan, Laura 5.4.4. Dialogue System Few changes have been applied to the Dialogue System. The main workflow            through Google Drive has been kept: The document must be uploaded in Google             Drive and it will be downloaded directly throughout Unity, without any need to             download it in the computer and passing it to Unity afterwards. The principal and only improvement is that it is the user who chooses when to               download the dialogue file by checking the toggle provided in the Dialogue Importer             prefab of ScripTale  . The document is not refreshed automatically but only when the             designer wants to and selects the option to download it again. All the instructions of use are specified in the Readme.md  . 5.4.4. Characters Characters’ narrative behaviour is all found in the script sTaleCharacter, that has to             be attached to the Character prefab in the scene. It is one of the most complex                script in ScripTale because it consists in an agent that interacts with the editors to               act or talk depending on the current state and also on the messages and actions               that the character itself owns.   These are all the variables that the character needs or controls:  [SerializeField] public int identifier; [SerializeField] public Effect[] baseBehaviour; [SerializeField] public Message[] characterMessages; public Effect[] currentState; List<Effect> memory; 56  Generation of Procedural Narrative Ripoll Galan, Laura            TeLLer had stopped at this point because their solution was about generating a             syntax for exploring procedurality in narrative with a cleaner and shorter manner            than with the already existing behavior trees. The current project could have ended             up with this anti-innovative solution to solve the same trouble raised by another             study in a more complex way. However, ScripTale  , wanted to justify the use of trees               in the States Editor with a meaningful output in the development of the story. Narrative would be linked with dialogue in my implementation. How to make some             structured field such as the dialogue up to an artificial intelligence was the obstacle              that has been the hardest part of the current study until the last implementation of               63  Generation of Procedural Narrative Ripoll Galan, Laura ScripTale  , and still is despite having found a solution. Classifying all the messages             into different types of emotions could allow the tool to decide which message to              pick up without any knowledge of the content but the emotion the message could              cause to a character. To endow this feature with realism, not all the characters              would be affected equally by a message, the effect had to be modified depending              on the relationship between characters. Realism is the key that is still found a limit for the tool. To achieve emotional realistic                 narrative behavior, the logic of the conversation was not contemplated. So           characters must still have default sentences as variate as the designer wants to set              them. However, they must be generic as conversations may not happen to make             sense. This could be a further point of research for the current project. It was not                implemented because a supposed to be simple tool would have become so            complicated that AI would have less control over the decision taking process of the              messages sent by the characters. To conclude with this project, an observation has to be done. In an uncertain field               such as Artificial Intelligence, the accomplishment of goals becomes dubious. They           were technically achieved, however, better implementations can be done and          studies still have a long way to improve in Procedural Narrative to get better results               and really impressive conversational behavior totally up to the characters or agents            of the AI.        64  Generation of Procedural Narrative Ripoll Galan, Laura  Bibliography - State of the art AI meaning gameplay benefits  [Online]. (2017, 15th September). Article, URL <https://www.forbes.com/sites/quora/2017/09/15/how-will-artificial-intelligence-cha nge-video-games/#6107d8dd2bb5> [Consult 14th February 2018]. NPCs algorithms  [Online]. (2017, 28th August). Blog, URL<http://sitn.hms.harvard.edu/flash/2017/ai-video-games-toward-intelligent-gam e/> [Consult 14th February 2018]. AI’s effect on video games  [Online]. (2018, 10th January). Blog, URL<http://www.techradar.com/news/game-on-how-ai-is-transforming-video-gam es-forever> [Consult 14th February 2018]. Future of AI in the video games field  [Online]. (2017, 27th July). Blog, URL<https://www.theatlantic.com/technology/archive/2017/07/musk-vs-zuck/5350 77> [Consult 15th February 2018]. Visual improvements  [Online]. (2018, 10th January). Blog, URL<https://www.techradar.com/news/tim-sweeney-refreshing-consoles-every-sev eral-years-keeps-everyone-happy/2#article-body> [Consult 17th February 2018]. Voice recognition video game  [Online]. (2017, 2nd February). Article, URL<https://www.bbc.co.uk/taster/pilots/inspection-chamber> [Consult 17th February 2018]. Destiny 2 Alexa  [Online]. (2017, 30th November). Article, URL<https://www.polygon.com/2017/11/30/16719532/destiny-2-amazon-alexa-voi ce-commands-ghost-shell> [Consult 17th February 2018]. -Procedural content generation  : 65  Generation of Procedural Narrative Ripoll Galan, Laura Green Dale. (2016). Procedural Content Generation for C++ Game Development  . UK: Packt Publishing. Community Experience Distilled. Watkins Ryan. (2016). Procedural Content Generation for Unity Game Development  . UK: Packt Publishing. Community Experience Distilled. Areas in which PCG can be applied  [Online]. (2017, 14th July). Video, URL <https://www.youtube.com/watch?time_continue=2&v=0vST4IvG5CE> [Consult 8th February 2018]. PCG implementation  [Online]. (GDC Europe 2014). Conference content, URL <https://www.gdcvault.com/play/1020868/Games-with-Freedom-Programming-Pro cedural> [Consult 8th February 2018]. Angelina  [Online]. (2017, 29th November). Blog, URL <https://www.technologyreview.com/s/609482/ai-is-dreaming-up-new-kinds-of-vid eo-games/> [Consult 9th February 2018]. Games made by Angelina  [Online]. (2018, 15th January). Web page, URL <http://www.gamesbyangelina.org/> [Consult 9th February 2018]. - Procedural narrative information: Narrative Structure  [Online]. (2017, 6th September). Blog, URL <http://www.gamasutra.com/blogs/AndrzejMarczewski/20170609/299705/Narrative _Atoms_and_the_Soap_Heros_Journey.php> [Consult 8th February 2018]. Practices for Procedural Narrative Generation  [Online]. (2017, 12th May). Video, URL <https://www.youtube.com/watch?v=k2rgzZ2WXKo> [Consult 7th February 2018]. Practices for Procedural Narrative Generation  [Online]. (2016, 10th January). Video, URL <https://www.youtube.com/watch?v=p40p0AVUH70> [Consult 7th February 2018].   66  Generation of Procedural Narrative Ripoll Galan, Laura - Development Schudlo, Nicholas A.. (2014). Development of an Emergent Narrative Generation Architecture for Videogames. Bosser A., Ferreira J. F., and Cavazza M., and Martens C.. Linear Logic Programming for Narrative Generation  [Online]. Research, URL <https://www.cs.cmu.edu/~cmartens/lpnmr13.pdf  > [Consult 21st March 2018]. Goal Oriented Action Planning for a Smarter AI  [Online]. (2014, 23rd April). Tutorial, URL <https://gamedevelopment.tutsplus.com/tutorials/goal-oriented-action-planning-for -a-smarter-ai--cms-20793> [Consult 20tht April 2018].               67  Generation of Procedural Narrative Ripoll Galan, Laura Annexes - Annex 1: ScripTale.unitypackage Annex 1, named ScripTale.unitypackage can be found in the same folder as the             current memory. It consists on the tool itself, the resultant package to be imported              to unity so as to make use of the tool. - Annex 2: Readme.md Annex 2, named Readme.md can be found in the same folder as the current              memory. It consists on the README of the tool, the instructions of use.   68