Zleef’s Blog

I wish i was swimming here –but instead, i’ll happily work on my computer science homework…

Archive for March, 2009

HW 6

So I was really busy doing a serious update of the game, and wasn’t able to implement both the visitor pattern and state pattern. You can see the “planning documents below (sorry it formats it so weird on here, i’ll attach a pdf document for easier viewing) to see where i’m going with this. I really just needed more foundation for the game play. 

The visitor pattern is used for printing out a specially formated list of the ingredients in a specific soup. 

The state pattern will get added soon. What my initial plan for it is to use as a “game state” for displaying different menus depending on if we’re in the start scree, settings, or gameplay, etc…

I’m having a bit of trouble in the Preference class. Basically what i want to happen is when a customer is created they’ll get an instance of Preferences. When the preferences object is created i want it to go and look at all the ingredients that are used in the store (i.e. for a polymorphic approach i’d like it to – in the future, be able to have a number of soups created each with various ingredients. (side note on a side note: i’d like each ingredient to implement a set of “tastes” or something so that you could create additional ingredients and then from the interface there’d be a couple of things that you’d rate the ingredient on for example it might be like salty, sweet, savory, filling, healthy, tasty or something like that and then each ingredient would really only be an object that contained different values for each one of those). When the soup was added to the store, there would be a scan of the soup to see if there are any ingredients used in this soup that haven’t been used before, and if so add them to our list of supplies (store.Supplies) ). and then create a random number between 0 and 100 to use as its preference for this ingredient (i.e. how much it likes that ingredient) later in the game i’ll determine if the customer likes the soup by testing if the amount of the ingredient in the soup is within range of  their preference. The way i’m setting this up is by using ai.Preferences.setPreferences() which will take in a list of all the supplies (ingredients used in the store) and then put them as the key in a hashmap along with a random int between 1 and 100 (which will be there actual preference). Where the actual problem is happening is when i go to get a preference (ai.Preferences.getPreference() ) it’s throwing errros about how it can’t be cast into an int. 

I know this is kind of a belligerent explanation of the problem, but if you can make sense of it and offer any suggestions that’d be great. Thanks!

Additional Planning Documents (pseudo re-factoring)

The formating is horrible on the post so i attached a pdf of the actual document:

<< game-planning-document.pdf >>

======================

Setup

Player Options

  • Set Amounts of each Ingredients 
  • Set Cost of Soup

 

System Options (Constants)

  • GAME_LENGTH       //length in min. of the game. 
  • NEXT_WAVE_IN       //length in min. of how often a new wave of customers comes
  • IMPULSE_CHANCE_RANGE    //what the random number range will be
  • IMPULSE_CHANCE  //which number out of impulse range gives them a impulse buy
  • IMPULSE_AMOUNT       //$$$ how much more the customer is going to spend with an impulse
  • PRICE_DEVIATION  //determines the deviation of what a customer is willing to pay
  • PREFERENCE_DEVIATION //deviation of what cust. will like according to their set preference

======================

Start Simulation

  • Runs for two minutes
  • <<No pause or menu options available>>
  • Create a new store and add a soup to it.
  • Create a new customer driver.

======================

Create Customers

  • Every ten seconds a new wave of customers is created. 
    • Every customer is given a set of preferences, a possible impulse purchase, an “intuition,” and also a “life”. 
      • The preferences will be a random int for each ingredient and the amount of money they’re willing to spend.
      • The impulse purchase will be selected at random at customer initialization. 
      • Their intuition is a timer that determines when they’ll go up and order. If it’s set after their life has expired they’ll never order (i.e. they’ll just become a loiterer). We should run a test before the intuition timer is initialized to determine if they’re going to be a loiterer and if so don’t start the timer so we don’t wast resources.
      • The life is basically a timer that describes how long they stay in the restaurant. Once the timer runs out, they gracefully leave the restaurant by unsetting the intuition timer (if applicable), (exiting GUI [animation]), and removing themselves from the list of customers.
  • The number of new customers is based on a Random number between 1 & 10 and is weighted by popularity. So initially (at popularity 0), at max only 10 customers would show up. 
    • Popularity starts at 1 and then goes up indefinitely, it can’t be set at less than 0 so that it’s not impossible to recover from no one liking you (i.e. if you got negative -10 popularity then you would have zero customers coming in and have no one to increase your popularity).
      • This will be set very primitively: every customer that likes their meal will add 1pt to popularity, and customers that don’t enjoy it will decrement it by 1. If by some chance everyone of the ingredients matches the customers preference we’ll add 10.

 

 

 

 

======================

Interaction

  • Interaction will be what the customer does in the restaurant.
    •  
      • + interact()
        • this will control the process of interaction. it’ll first call wantsToOrder(), then order(), then finally consume().

 

  •  
    •  
      • - wantsToOrder()
        • This will decide it the customer wants to place an order. 
        • It will consult the price. If the price is within their  deviation it will decide its a good idea to buy it. 
      • - order()
        • Create a new instance of the soup which will increase the total number of soups purchased and the revenue.
      • - consume()
        • Determine if the ingredient amount is within the  deviation of customers preference for each ingredient (iterate through the list of ingredients and check each one.) If the majority of ingredients fall within the preference range then add 1 to the popularity, else subtract 1. 

 

 

======================

Score

  • Total sales
  • Total Revenues
  • Customers vs Customers who Purchased
  • Customer Satisfaction
    • “x” Customers liked your soup
    • “y” Customers disliked your soup
    • Your approval rating was (approved_customers/total_customers) * 100

 

======================

Follow

Get every new post delivered to your Inbox.