Giving options more or less weight

This is a discussion on Giving options more or less weight within the Game Programming forums, part of the General Programming Boards category; I am working on a program that will decide which meals will be prepared & served for the week. At ...

  1. #1
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528

    Giving options more or less weight

    I am working on a program that will decide which meals will be prepared & served for the week. At first I thought it would be really easy - have a list of things I like to eat, and let the computer randomly pick a certain number of them - Voila! Instant menu plan. But then I was reminded that some meals are OK, but not every week - perhaps every third week or so. So then, it seems to me that my program has to give more weight to some options rather than others. My problem is that I have no idea of how to implement this, and worse yet, I don't even know the terminology to do a decent search for what I am after. it seems to me that the answer might lie with those who are well versed in game programming, hence why I am posting here. If anyone would care to set me on the right track, I would appreciate it.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    You might want to look at weighted average calculations. For instance a Runge-Kutta integrator for a physics system takes a weighted average of 4 distinct points to arrive at the final answer. I'm sure mathworld has a lot of information on computing weighted averages.

    Runge-kutta computes k1,k2,k3 and k4. Then it does: final = 1/6 * ((k1 + (2 * k2) + (2* k3) + k4))


    One thing is for certain is you will have to assign coefficients to each meal or meal ingredient in order to calculate the end result. You will need some type of formula to come up with a good coefficient that might take into account the number of calories, various cholesterol types, sugars, etc.

    A first glance nieve approach is to find out how much a human needs of each one of the key categories you are using and produce ingredient coefficients based on that. You can then either average the coeffs. or do a weighted average on them to arrive at the final coefficient for the ingredient or meal. Then it's a simple matter of having the computer do some math to make sure the final coefficient for the meal is near some number.

    I recommend you use normalized data to make the math simple.

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    use a neural network to decide, and train it based on how much you liked its choice, and a history of the meals it has served you over perhaps the last year, so it learns to serve holiday appropriate meals during holidays, but not necessarily at other times of the year.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  4. #4
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Quote Originally Posted by Bubba View Post
    You might want to look at weighted average calculations. For instance a Runge-Kutta integrator for a physics system takes a weighted average of 4 distinct points to arrive at the final answer. I'm sure mathworld has a lot of information on computing weighted averages.

    Runge-kutta computes k1,k2,k3 and k4. Then it does: final = 1/6 * ((k1 + (2 * k2) + (2* k3) + k4))


    One thing is for certain is you will have to assign coefficients to each meal or meal ingredient in order to calculate the end result. You will need some type of formula to come up with a good coefficient that might take into account the number of calories, various cholesterol types, sugars, etc.

    A first glance nieve approach is to find out how much a human needs of each one of the key categories you are using and produce ingredient coefficients based on that. You can then either average the coeffs. or do a weighted average on them to arrive at the final coefficient for the ingredient or meal. Then it's a simple matter of having the computer do some math to make sure the final coefficient for the meal is near some number.

    I recommend you use normalized data to make the math simple.
    Thanks for the info. Now I have an idea of where to begin.

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,657
    I hope your algorithm takes into account the proper balance of flavors.

  6. #6
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by Sebastiani View Post
    I hope your algorithm takes into account the proper balance of flavors.
    And balances nutritional requirements.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weight Balanced Tree - Implementation
    By paulovitorbal in forum C Programming
    Replies: 1
    Last Post: 10-31-2007, 02:28 PM
  2. What's the best way to handle many program options?
    By stickmangumby in forum C Programming
    Replies: 19
    Last Post: 06-06-2007, 04:06 PM
  3. Double to Int conversion warning
    By wiznant in forum C Programming
    Replies: 15
    Last Post: 09-19-2005, 09:25 PM
  4. Replies: 1
    Last Post: 10-18-2003, 09:15 AM
  5. Opening files - Giving options?
    By wwwGazUKcom in forum C++ Programming
    Replies: 3
    Last Post: 09-18-2001, 07:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21