Jump to content
Science Forums

How do I make an algorithm?


Recommended Posts

You're going to need to clarify that quite a bit more:

 

What do you mean by "the probability of information?"

 

What does the program do?

 

Why do you care about that probability?

 

For a list of all the ways technology has failed to improve the quality of life, please press three, :)

Buffy

Link to comment
Share on other sites

I want to make a program where I input information, it processes the probability of the most likely outcome based on variables, then spit out the most likely answer.

 

 

If I input what is the probability of these three characters winning in a duel.

 

A

HP: 20

MP: 15

Spec: 11

ATK: 09

 

B

HP: 20

MP: 14

Spec: 11

ATK: 19

 

C

HP: 19

MP: 20

Spec: 15

ATK: 10

 

The program that I make would be able to take this data and figure out which one has the most likely chance of beating the other, A, B, or C, and then which one has the best chance of winning altogether. :)

 

Why? Because I choose too? :xmas_rudolph: The purpose of this program as a whole is strictly on a need to know basis, I just am asking for help in this piece of the puzzle.

Link to comment
Share on other sites

Unfortunately, the answer really is "it's complicated."

 

I've had just enough experience playing those silly shoot-em-up games to understand what you mean by those codes...but I think that obfuscates things to the point where I won't be clear so let me elaborate using a bit simpler analogy...

 

Let's say a Quarterback has a completion percentage of 30% and yards per play of 10 yards (for those of you who live outside the US, a Forward has a scoring percentage of 30% (3 goals per 10 shots on goal) and 5 shots on goal per game or some such) [and don't anyone complain that these numbers are crazy in the real world because it's just an *example*! I'm a 49ers and Arsenal fan, but I don't claim to actually know anything about either kind of football!]. In order to have an idea of whether or not this guy has a chance of winning a game (match) depends on an enormous amount of historical data that would provide a mechanism for correlating having these ratings with winning.

 

Now that's just working in the "real world" when in the "fake world" of video games, in fact these data points are applied to formulas to figure out who between two opponents are going to win a particular face off. In simpler games there's a completely deterministic formula for determining the outcome. In any program that is more sophisticated, a (usually) Poisson distributed random number is applied to various parts of the function to generate "random" but "somewhat predictable" outcomes. In such cases, while you can use historical data in the same way that you would a "real world" situation, if you actually have access to the algorithms, you can manipulate them to determine the effect of the application of the random numbers to develop a probability function based on the two sets of input parameters. That in itself will be an interesting algebraic (or more probably, a calculus) problem.

 

In any case, there is no "general solution" given what you've presented, its entirely based on either the empirical relationships between the four parameters, or a knowledge about the functions that the program uses to determine outcomes.

 

Events in the past may be roughly divided into those which probably never happened and those which do not matter, :)

Buffy

Link to comment
Share on other sites

yes, i'm with buffy, it can be extremely complicated, infact let me expand that, it can be as easy or as complicated as you want it to be.

 

It depends on not only what information you are considering, but also how you are computing it. Until you describe the process you want to use to calculate the probability, all the variables, values, methods etc, we cant, beyond being very very vague, describe how you'd go about it.

 

the data you give is vague, we wanna know how you want to compute the probability (math side of it), is it only based on these values, how do you want to restrict the calculation, how you want to approximate, etc, etc, give us a verbal equation, we can tell you how to go about such algorithm. BTW if you dont understand the math and logic behind probability calculations, you shouldn't be starting on this project until you understand, notice distinction, not just be able to figure out probability in 2 scenarios, understand how probability works and be able to create your own functions based on the data you have.

Link to comment
Share on other sites

I want to make a program where I input information, it processes the probability of the most likely outcome based on variables, then spit out the most likely answer.

 

 

If I input what is the probability of these three characters winning in a duel.

 

A

HP: 20

MP: 15

Spec: 11

ATK: 09

 

B

HP: 20

MP: 14

Spec: 11

ATK: 19

 

C

HP: 19

MP: 20

Spec: 15

ATK: 10

 

The program that I make would be able to take this data and figure out which one has the most likely chance of beating the other, A, B, or C, and then which one has the best chance of winning altogether. :shrug:

 

Why? Because I choose too? :) The purpose of this program as a whole is strictly on a need to know basis, I just am asking for help in this piece of the puzzle.

I think I vaguely remember such values. Let's see ...

 

I assume HP means Hit Points, ATK means Attack (%) Percentage and Spec just means some special ability. Not sure what MP means...

 

As Buffy was saying "assuming" you "knew" what deterministic "process" you do with these values. You could calculate the resultant Probability. That process would be your algorithm.

 

So do you know that process.

 

Let's say A attacks B (frontal attack)

Damage (DMG) done on B by A would be some factor of ATK value mitigated by some Defense factor of B. without this process it is all guesswork.

 

Hope this helps.

 

maddog

Link to comment
Share on other sites

I want to make a program where I input information, it processes the probability of the most likely outcome based on variables, then spit out the most likely answer.

If I input what is the probability of these three characters winning in a duel.

A

HP: 20

MP: 15

Spec: 11

ATK: 09

...

Julian,

in theory, any of us can show you how to make an algorithm for this purpose. But I feel your level of "secrecy" is a bit high--and unnecessary. None of us are gonna steal your idea and make our own game.

 

So, let me tell you how to make an algorithm -- in the broadest general terms.

 

First, decide EXACTLY what "HP", "MP", "Spec", "ATK" (and others) mean in your game. Is "HP" the number of health points for the duelist? [When they go to zero, the duelist dies.] Or is "HP" the number of hit points subtracted from the other guy's health points. Write your definitions out until you're sure they are clear and unambiguous.

 

Second, decide what kind of number each parameter is. Is it a QUANTITY of something? Like health, or luck, or wisdom, or godliness or cleanliness? Or is it a PROBABILITY that something will (or will not) happen? For example, "MP" could be the probability that each duelist in turn will successfully land an attack on the other. How are each of these parameters to AID the duelist? How do you want health to work? How will wisdom work? Perhaps wisdom will aid the duelist to block attacks? Or increase the possibility of landing an attack with double hit points?

 

Third, decide what the output of the algorithm will be. Is it to output the winner of the duel? Is it to output just the probability that each duelist will win if pitted against each other? Or is the algorithm supposed to actually play out the duel (using probabilities where appropriate), and also adjust their parameters to reflect the battle. For example, reducing the winner's health points.

 

Fourth -- and this is the important part -- pick a pair of duelists and talk yourself through a battle. What happens first? Does the duelist who "starts" the battle always have the opportunity to attack first? Which parameters are most important and are used first? How is "death" or "losing" calculated? If the target survives the first attack, what other calculations do you want before having the target counter-attack? Like, where does "luck" or "godliness" come into this battle?

 

Fifth, once you have talked yourself through a battle and you know just the way it should turn out, then write down the algorithm. You know what the inputs are: the parameter tables of your two duelists. Your internal logic will likely be a big loop where the first duelist attacks, then the target counter-attacks. If both are still alive, then go back to the top of the loop and repeat--until one dies (or runs). The outputs of the algorithm might be just the updated parameter tables of the two duelists, and an outcome number which states whether the loser died or ran away.

 

The fifth step will only be as good as the "story" you create in step four.

 

Does that help? :) :shrug: :)

Link to comment
Share on other sites

The program is designed to take in a tournament program designed to interpret data from the last 10 matches of each of the contestents, imputted by the user [when the time comes another program.

 

A maximum of 12, and a minimum of 8. [it's supposed to be an expansion of a program someone else had made buuuuuuuuut I'm doing it my way. Cause if I figure out how to do it at 12 to 8, I can do it myself and work it all the way down to 1 and just replace the older program with my new one. It'll win me guild points and it'll give the senior programmer 'artist points' allowing him to retire one of his programs and being respected for having it run so long. He is ecstatic about my attempts to do this, because he is my mentor :P but enough of the history lesson :P... where was I?... *thinks...* :doh: I hurt my head, got to invent a way that makes thinking nonhazardous to my health.... okay. so the progam currently runs 1 to 8 tournament contestants. The data is imputted by the judges. The judges use the last 10 or so matches, they have a system that I have requested to get a copy of for this algorithm that they use to sometimes void matches altogether. Such as ties and stuff like that do not count as a valid history, but some of the information leading up to the tie does. Sooo the new program here inputs a minimum of 8, to a max of 12 contestant's past 10 game scores.

 

The scores are then compared and the probability of each is weighed against all of the others. Then the program predicts based on the calculations it does, in a precise order, who would win and in what order they will win based on the last 10 game scores/histories of the players.

 

The factors at this time that are used in the calculation are being requested along with the way the judges score the histories of the past game scores so I will not know till I get them, although they are due in the mail any day now.

 

It's for a Fight Club. We are seeing if we can predict the possibilities of who will win based on personal data provided by each member, and measuring it up to their last 10 fights. Some things such as if they get blind sided by a light, go into a category for lack of concentration [how many times this has happened in the last 10 fights, I do know if it has happened a certain number of times the Judges discount it altogether. My attempt is to actually improve on this by just having this as a handicap in the program's deterministic processing.

 

Human behaviour is often unpredictable, but it is a tradition in our fight club to predict the outcome of the fights based on numbers and facts. It's how most of us keep sharp in our jobs. Calculating how many times in the last few fights the other guy decides to throw a right hook, as opposed to his left. Using psychology to analyze if it is his style to use the right hook or if it is what he is doing to win the fight. Style outweighs, 'being in the moment' by 4 to 1. However if the player becomes aware of the style in the fight circle, then that can be a surprise leading to new mark ups and new game scores, and a new history. But a history is usually the last 10 to 20 fights.

 

I personally want the program to once the information is put on a fighter, as long as they are an active member and haven't "jacked out" [meaning quit the fight club] then I want all their information stored in there for eventual upgrades to the program where it can go back and deduce their entire history and probable outcome against another fighter who has less of a history. I just have to figure out how that kind of equation would work, and then translate it to the algorithm for the upgrade. :hihi: Admittedly I'm new to the fight club, but all of the guys in there are the nerds and the geeks, we have a chef, restaurant owner, we have 2 millionaires, and we have valets, all of them as a right of passage have contributed to the fight club in some way. My mentor is like me, he didn't know much about something and he tackled it and it became a tradition of the fight club to use his program in what we call tournaments.

 

The idea of fight club goes against tournaments, but honestly a tournament is for the more humble members. The ones who don't have as much as the rest, the guy who begs on the corner for a buck - these are the guys who qualify for the Tournament. Everyone pitches in something for the winners. It's usually a group of 8, but we are expanding it to 8 to possibly 12. Then everyone who is chosen to fight in the tournament will get something based on how they rank. This program actually would help us before hand have all of the arrangements ready for the most likely candidates and in what order their 'prizes' will be given.

 

Enough of the history type thing I talk too much :D I just am attempting to convey that this is an important thing I am doing here by asking for help in making this, and telling you what it is and what it is used for.

 

Everyone knows that I've already broken the infamous, "Don't talk about fight club" rule... now you know how badly I want to get this done. I hope that my story touches you all enough that you could help make this dream of mine, to contribute to something I feel is very important to not only me but my brothers who participate in our club.

 

 

So plz tell me step by step what I need to do if you can. Give me a general idea. A couple of people already have sort of done that. I'll post more when I know how they score the game scores and histories.

 

Sorry for making everyone think it was a game. I just figured it'd be best to keep it under wraps, but I figure if you all knew you'd be more willing to help. If nothing for the simple fact you could say you helped a fight club.

Link to comment
Share on other sites

Ok, here are some problems you need to solve:

 

first of all, read through a couple of things on probability to understand what you will need to accomplish in the end, in basic terms.

 

Probability tutorial

 

that gives you a good overlook of what probability is, but the problem is, its not the only thing you have to do, if you want to figure out to a greater degree of success what the outcome will be based on previous accounts, you need to base your probability on statistics as well

 

AP Statistics Tutorial: Variables

 

to gather statistical data, look at some of these:

 

Statistical Data Mining Tutorials

 

and you will need to analyze the data, have a read through this:

 

Inferring From Data

 

you also want to familiarize yourself with various probability theories, example would be bayesian probabiliy:

 

BAYESIAN PROBABILITY THEORY

Bayesian Tutorial

 

but have a look at this wiki page on frequency (aka statistical) probability:

Frequency probability - Wikipedia, the free encyclopedia

 

oh another excellent resource i found, and this is on putting probability and statistical analysis together:

 

Introduction to Probability and Statistics

 

So here is an algorithm on how you use the knowledge you gain above to create the algorithm for figuring out who wins the fight:

 

1) find a link above

2) follow the link

3) read the article

4) follow links to other articles that that article may link you to if there are any

5) once done reading the topic make sure you understand it from both the thinking perspective and the mathematics of it

6) come back here and look for the next link, if it is present go to step 2

7) get a sample of all of the data that you are going to process for every fight

8) using the data mining methods determine what, use every bit of data might give you

9) using statistical analysis, analize all of the statistics you have determined, determines the outcome of the match

10) put that process into functions that give valid mathematical data back

11) figure out the base equation you could use to predict the outcome of a match, not based on any of the statistical data. This will give you something to work from

12) run your base function to predict the probability of outcomes of the matches data for which you already have

13) look at how your statistical data effected the results

14) based on that, modify your probability function to create a much more accurate results

 

once you have the functions for statistical mining and probability, you culd create the algorithm to calculate the probability. Infact if you post all of that research here, we, or well at least myself, i could help you with the exact algorithm for getting the results, and perhaps even help you with some problems you might face in code...

 

hope this helps

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...