// // //================================The Geek Game Character Quiz================================= /* By Joshua Tanenbaum December, 2006 Simon Fraser University School Of Interactive Arts and Technology for IAT 800 - Foundations of Computational Art and Design As with many RPGs, characters in the Geek Game are comprised of various statistics. Physical and mental capabilites of thw character are represented by 8 attributes. Each attribute has seven skills associated with it. Each class is characterized by a Primary Attribute, a Secondary Attribute, several special abilities, and 25 class skills. Concentration of skills is useful for determining weighting of attributes in a heirarchial scale. This is a prototype of the Class selection quiz fot the Geek Game. It contains 28 questions. Each question pairs up two of the 56 skills in the game, from two different attributes. To determine which class is the best match, I apply an algorithm that loosely ranks the attribute choices of the player in order to determine primary and secondary attributes, and overall skill concentration. With 28 questions, this test is harly a rigorous model of user preference, however it is a satisfactory proof-of-concept. Because each positive answer is also a negative response to it's component choice, the specific wording of any given question becomes a confounding factor when it comes to modeling user intent. Two to three times this number of questions might mitigate that substantially however this level of detail is outside the scope of this project. Future versions of this quiz will include a section of class specific questions, which ought to help provide a more precise model for the system to work with, and a clearer sense of class distinctions in the case of test taker. */ // // //=========Initialize library and assign variables================ import SpringGUI.*; SpringGUI gui; String result; PFont font; boolean submit; int i = 0; //iterator variable int Qtype; //==============data storage variables (attributes)============= int strength = 0; int agility = 0; int finemotor = 0; int metabolism = 0; int intellect = 0; int worldliness = 0; int creativity = 0; int charisma = 0; //============image names and class types==================== PImage outcome, academic, codemunkey, comicbook, culturewhore, fairefighter, gamer, netgeek, scientist, techie, theatergeek, goat; //==================Setup GUI elements and create an array of question class objects=============== void setup() { font = loadFont("ArialMT-48.vlw"); size(800,600); framerate(30); gui = new SpringGUI(this); Question[] questions = new Question[28]; for (int i = 0; i<28; i++){ //iterates through the question ID's, so that each question object displays a single set of Q&A's questions[i] = new Question(i); } Qtype = new Question(i).myQuestion(); submit(); ui(); } //==================In the draw loop, the program watches the value of the "submit" boolean variable, and resets it to false after each click of the "subButton"============== void draw () { askQuestions(submit); submit = false; } //===============The UI method instantiates the two radio buttons. void ui(){ gui.addRadiobutton("myRadiobutton1", "A -- ", "myGroup", 10, 207, 45, 20); gui.addRadiobutton("myRadiobutton2", "B --", "myGroup", 10, 257, 45, 20); gui.setState("myRadiobutton1", true); gui.setAllBackgrounds(25,25,100); gui.setAllForegrounds(255,255,255); } //=============The Submit method instantiates the pushbutton for submiing responses void submit(){ gui.addButton("subButton","Submit!", 700, 310, 75, 30); } //==================This is the standard event handler for the SPRINGui library. Each event is stored in an array of strings. //In this method I am using the selection of the "subButton" to both toggle the submit value to true, thus incrementing through the askQuestion method, //and calling the submission method to increment my data storage variables. void handleEvent(String[] parameters) { if (parameters[1].equals("subButton") && parameters[2].equals("mouseClicked")){ submit = true; submission(); } } //====================The Ask Questions Method iterates through the question objects in the array, calling them in sequence. //When it reaches the end of the array, it calculates and displays the result based upon the values of the "attribute" integers. void askQuestions(boolean S) { if (S == true){ i= i +1; } if (S==true && i<=27){ Qtype = new Question(i).myQuestion(); } else if(i>=28){ fill(0); rect(0,0, width,height); gui.remove("myRadiobutton1"); gui.remove("myRadiobutton2"); gui.remove("subButton"); /* If the primary attribute is above the cutoff, and the sum of the Primary and secondary attributes is greater then the sum of the tertiary and quaternary, and the sum of the top four is greater then the sum of the bottom four, then the class is considered a match. Additionally, I check the sum of the primary and secondary attributes of each class against each of the others, which makes an effective tie breaker, should two or more possible matches arise*/ int cutoff=5; //determines how forgiving the algorithm is...higher numbers make class assignation more accurate, but less likely. String imagename = ""; //variable for holding the filename of the result image int toptwo = 0; //variable for the prmary and secondary attributes if ((intellect >= cutoff) && ((intellect + finemotor) >(metabolism + creativity)) && ((intellect + finemotor + metabolism + creativity) > (charisma + strength + agility + worldliness))) { imagename = "codemunkey.jpg"; toptwo = (intellect + finemotor); } if ((worldliness >= cutoff) && ((worldliness + intellect) >(finemotor + metabolism)) && ((worldliness + intellect + finemotor + metabolism) > (charisma + strength + creativity + agility))){ if(toptwo < (worldliness + intellect)){ imagename = "netgeek.jpg"; toptwo = worldliness + intellect; } } if ((metabolism >= cutoff) && ((metabolism + charisma) >(strength + agility)) && ((charisma + metabolism + strength + agility) > (creativity + intellect + worldliness + finemotor))){ if(toptwo < (metabolism + charisma)){ imagename = "theatergeek.jpg"; toptwo = metabolism + charisma; } } if ((metabolism >= cutoff) && ((metabolism + charisma) > (creativity + agility )) && ((metabolism + charisma + creativity + agility) > (strength + finemotor + worldliness + intellect))){ if(toptwo < (metabolism + charisma)){ imagename = "gamer.jpg"; toptwo= metabolism + charisma; } } if ((agility >= cutoff) && ((strength + agility) > (metabolism + worldliness)) && ((agility + strength + worldliness + metabolism) > (creativity + intellect + charisma + finemotor))){ if(toptwo < (strength + agility)){ imagename = "comicbook.jpg"; toptwo = strength + agility; } } if ((strength >= cutoff) && ((strength + agility) > (metabolism + charisma)) && ((strength + agility + metabolism + charisma) > (worldliness + finemotor + intellect + creativity))){ if(toptwo < (strength + agility)){ imagename = "fairefighter.jpg"; toptwo = strength + agility; } } if ((finemotor >= cutoff) && ((finemotor + creativity) > (worldliness + intellect)) && ((finemotor + creativity + intellect + worldliness) > (metabolism + charisma + strength + agility))){ if(toptwo < (finemotor+creativity)){ imagename = "scientist.jpg"; toptwo = finemotor + creativity; } } if ((creativity >= cutoff) && ((creativity + agility) > (finemotor + metabolism)) && ((creativity + agility + finemotor + metabolism) > (intellect + worldliness + strength + charisma))){ if (toptwo < (creativity + agility)){ imagename = "techie.jpg"; toptwo = creativity + agility; } } if ((intellect >= cutoff) && ((intellect + metabolism) > (worldliness + charisma)) && ((intellect + metabolism + worldliness + charisma) > (creativity + agility + finemotor + strength))){ if (toptwo < (intellect + metabolism)){ imagename = "academic.jpg"; toptwo = intellect + metabolism; } } if ((charisma >= cutoff) && ((charisma + worldliness) > (intellect + creativity)) && ((charisma + worldliness + intellect + creativity) > (metabolism + finemotor + agility + strength))){ if (toptwo < (charisma + worldliness )){ imagename = "culturewhore.jpg"; toptwo = charisma+worldliness; } } if (imagename == "") { imagename = "goat.jpg"; ///should none of the classes be considered a match, load the Geek of All Trades image. } outcome = loadImage(imagename); image(outcome,0,0); //Debugging block, for checking if the attributes have been properly incremented. println("strength = "+ strength); println("agility = "+ agility); println("finemotor = "+ finemotor); println("metabolism = "+ metabolism); println("intellect = "+ intellect); println("worldliness = "+ worldliness); println("creativity = "+ creativity); println("charisma = "+ charisma); } }