Post: Make Me A Simple Calculator (vBux)
08-12-2011, 02:45 AM #1
Adam West
git muny
(adsbygoogle = window.adsbygoogle || []).push({}); I'll 50k vBux to whoever can make me an odds calculator when the odds are 50/50
What i want it to do: calculate my odds of winning and showing it in % after a series of wins and losses.
The Math (probably explained terribly) :
If the odds are 50/50 the one that gets picked (Win or Loose) gets divided in 2 and Half stays and the other Half goes to the other side. If you don't get it look at the example below


Example:The beginning Odds are 50%Win/50%Loss
1rst Game: If I win the odds will be 25%Win/75%Loss
2nd Game: if I win again the odds will be 12.5%Win/87.5%Loss
3rd Game: If I loose the odds will be 56.25%Win/43.75%Loss

250k vBux and +10 rep to the first person that makes this for me
(adsbygoogle = window.adsbygoogle || []).push({});
08-13-2011, 08:54 AM #29
Adam West
git muny
Originally posted by AsianInvasion View Post
Oh yeah. LOL.
That's my bad. Its because in order to get the 78.90... number I multiply by 100. Forgot to do that to the loss number. Here ya go:

You must login or register to view this content.

Better?

Yeah... I'm sorry, that was just a stupid mistake (partially resulting from my tiredness). Just added the multiply by 100, so it'll come out looking like a percentage.

looks nice can you give me a dl link so i can try it out?
08-13-2011, 09:01 AM #30
Epic?
Awe-Inspiring
Originally posted by Adam
looks nice can you give me a dl link so i can try it out?



Here's a download link for the executable. I quickly slapped together assembly info and an icon for it, but other than that its completely the same as to what you saw in the screen shot (or at least it should function the same): You must login or register to view this content.

I'll make you a nicer one (possibly with a GUI), that is a bit faster, tomorrow. For now, I'm going to go to sleep.

If you did like this, I don't need vBux, rep, or anything, but I'd appreciate you checking out the forum in my sig! =D (but don't get me wrong, I do appreciate vBux and rep xD)

The following 2 users say thank you to Epic? for this useful post:

Adam West, O.P
08-13-2011, 09:08 AM #31
Adam West
git muny
Originally posted by AsianInvasion View Post
Here's a download link for the executable. I quickly slapped together assembly info and an icon for it, but other than that its completely the same as to what you saw in the screen shot (or at least it should function the same): You must login or register to view this content.

I'll make you a nicer one (possibly with a GUI), that is a bit faster, tomorrow. For now, I'm going to go to sleep.

If you did like this, I don't need vBux, rep, or anything, but I'd appreciate you checking out the forum in my sig! =D (but don't get me wrong, I do appreciate vBux and rep xD)

alright, one thing i dont like is that it does not run continuously and i'd have to keep my own log of wins and losses and re-enter them each time, i'd also have to restart the program each time but thank you Happy
08-13-2011, 05:40 PM #32
Pichu
RIP PICHU.
Originally posted by AsianInvasion View Post
That's tough, because in theory, each round is a completely unrelated event. Let's say you're flipping a coin. The first time you flip it, the odds of you getting heads is 50%, and the odds of getting tails is the same. The second time you flip the coin, the odds have not changed, there is still an equal chance of the coin going either way, because the two flips are individual results.

What you're assuming is that after each event, an object is removed. For example, a bag of 4 marbles, two blue, two red. If you draw a blue marble, the odds of getting a red marble are increased the next event - but only if you don't reinsert the blue marble to the draw.

So, is the removal of an object what you are looking for? Or do you want a program that prints 50% a bunch?


Same thing I was thinking, if you break this then your guess would be incorrect but also incorrect if you leave it because of the other possible decision.

Now wait, if he is able to input the correct guess then it is possible. It is like doing this.

50/50

A = 50
B = 50

If A loses then A / 2
A = 25

If A Wins then
A = A + A / 2

If B Loses then B / 2
B = 25

If B wins then
B = B + B / 2

This is all just on the top of my mind, not 100% if this is right but this is a general idea of what would occur. May make it.
08-13-2011, 07:07 PM #33
Epic?
Awe-Inspiring
Originally posted by Sublimity View Post
Same thing I was thinking, if you break this then your guess would be incorrect but also incorrect if you leave it because of the other possible decision.

Now wait, if he is able to input the correct guess then it is possible. It is like doing this.

50/50

A = 50
B = 50

If A loses then A / 2
A = 25

If A Wins then
A = A + A / 2

If B Loses then B / 2
B = 25

If B wins then
B = B + B / 2

This is all just on the top of my mind, not 100% if this is right but this is a general idea of what would occur. May make it.


Yeah, that's effectively what I did...

In C# I just took in the individual chars into a List<char>. I started with a base of 0.5:
    
double WinChance = 0.5f;
double LossChance = 0.5f;


Then, all I had to do was loop through them:
    
foreach (char x in track)
{
if (x == 'w'Winky Winky
{
WinChance /= 2.0;
LossChance = 1.0 - WinChance;
Console.WriteLine(WinChance);
}
else if (x == 'l'Winky Winky
{
LossChance /= 2.0;
WinChance = 1.0 - LossChance;
Console.WriteLine(WinChance);
}
}
Console.WriteLine("Therefore, the odds of you winning are exactly " + WinChance * 100 + "% and your chances of loosing are exactly " + LossChance * 100 + "%.");


It seems to work fine...

Its not too complex, it just took me a bit to understand what he wanted.
08-13-2011, 07:24 PM #34
Pichu
RIP PICHU.
Originally posted by AsianInvasion View Post
Yeah, that's effectively what I did...

In C# I just took in the individual chars into a List<char>. I started with a base of 0.5:
    
double WinChance = 0.5f;
double LossChance = 0.5f;


Then, all I had to do was loop through them:
    
foreach (char x in track)
{
if (x == 'w'Winky Winky
{
WinChance /= 2.0;
LossChance = 1.0 - WinChance;
Console.WriteLine(WinChance);
}
else if (x == 'l'Winky Winky
{
LossChance /= 2.0;
WinChance = 1.0 - LossChance;
Console.WriteLine(WinChance);
}
}
Console.WriteLine("Therefore, the odds of you winning are exactly " + WinChance * 100 + "% and your chances of loosing are exactly " + LossChance * 100 + "%.");


It seems to work fine...

Its not too complex, it just took me a bit to understand what he wanted.


Nice, mind if I have a copy of the source and program. I'm still trying to learn the language of C#. Smile
08-13-2011, 07:52 PM #35
Epic?
Awe-Inspiring
Originally posted by Sublimity View Post
Nice, mind if I have a copy of the source and program. I'm still trying to learn the language of C#. Smile


No problem. Its a console app, so you won't need any designer files. I didn't have any comments in it prior to you asking, so I've done my best to add in my comments post-programming:
    
using System;
using System.Collections.Generic;
using System.Text;

namespace Hiscalc
{
class Program
{
static void Main(string[] args)
{
// take in user input
Console.WriteLine("Enter the sequence of your win/loss record, using a lowercase 'w' to mark wins, and a lowercase 'l' to mark losses:\n");
string userInput = Console.ReadLine();

// create a list of characters (similar to an array) to store the user input in a useful form
List<char> track = new List<char>();

// loop through each character in the userInput string, adding each character to the list
foreach (char x in userInput)
{
track.Add(x);
}

// call the calculate function
Calculate(track);
}

// calculate function is private and static, returns no values - takes a character list as a parameter
private static void Calculate(List<char> track)
{
// create two doubles to hold the initial value (50% or .5)
// they'll also be used later to hold new values
double WinChance = 0.5f;
double LossChance = 0.5f;

// loop through each character in the char list (called track)
foreach (char x in track)
{
// determine if its a w for win, or l for loss
if (x == 'w'Winky Winky
{
// perform calculations in event of win
WinChance /= 2.0;
LossChance = 1.0 - WinChance;
// print the odds of winning
Console.WriteLine(WinChance);
}
else if (x == 'l'Winky Winky
{
// perform calculations in event of loss
LossChance /= 2.0;
WinChance = 1.0 - LossChance;
// print the odds of winning
Console.WriteLine(WinChance);
}
}
// Finally, print the odds of winning and the odds of losing
// Write them as percentages (hence the * 100).
Console.WriteLine("Therefore, the odds of you winning are exactly " + WinChance * 100 + "% and your chances of loosing are exactly " + LossChance * 100 + "%.");
Console.ReadKey(); // ReadKey to allow user time to read the information
}
}
}


I removed the using directive for Linq, because I decided to set the target framework to .NET 2.0 (as opposed to 4.0, the latest version), that would allow for maximum compatibility.


Enjoy!

Feel free to improve upon it, add a GUI, whatever, and give it to him.
08-14-2011, 03:52 AM #36
Pichu
RIP PICHU.
Originally posted by AsianInvasion View Post
No problem. Its a console app, so you won't need any designer files. I didn't have any comments in it prior to you asking, so I've done my best to add in my comments post-programming:
    
using System;
using System.Collections.Generic;
using System.Text;

namespace Hiscalc
{
class Program
{
static void Main(string[] args)
{
// take in user input
Console.WriteLine("Enter the sequence of your win/loss record, using a lowercase 'w' to mark wins, and a lowercase 'l' to mark losses:\n");
string userInput = Console.ReadLine();

// create a list of characters (similar to an array) to store the user input in a useful form
List<char> track = new List<char>();

// loop through each character in the userInput string, adding each character to the list
foreach (char x in userInput)
{
track.Add(x);
}

// call the calculate function
Calculate(track);
}

// calculate function is private and static, returns no values - takes a character list as a parameter
private static void Calculate(List<char> track)
{
// create two doubles to hold the initial value (50% or .5)
// they'll also be used later to hold new values
double WinChance = 0.5f;
double LossChance = 0.5f;

// loop through each character in the char list (called track)
foreach (char x in track)
{
// determine if its a w for win, or l for loss
if (x == 'w'Winky Winky
{
// perform calculations in event of win
WinChance /= 2.0;
LossChance = 1.0 - WinChance;
// print the odds of winning
Console.WriteLine(WinChance);
}
else if (x == 'l'Winky Winky
{
// perform calculations in event of loss
LossChance /= 2.0;
WinChance = 1.0 - LossChance;
// print the odds of winning
Console.WriteLine(WinChance);
}
}
// Finally, print the odds of winning and the odds of losing
// Write them as percentages (hence the * 100).
Console.WriteLine("Therefore, the odds of you winning are exactly " + WinChance * 100 + "% and your chances of loosing are exactly " + LossChance * 100 + "%.");
Console.ReadKey(); // ReadKey to allow user time to read the information
}
}
}


I removed the using directive for Linq, because I decided to set the target framework to .NET 2.0 (as opposed to 4.0, the latest version), that would allow for maximum compatibility.


Enjoy!

Feel free to improve upon it, add a GUI, whatever, and give it to him.


Thank you. Smile

I think for my first main project in C# will to add a GUI to this. When I do, I'll be sure to give credit to you as well. Happy

The following user thanked Pichu for this useful post:

Epic?

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo