Today's Tasks
Well, its been a couple hours.... I decided to grab dinner, then humiliated a few Call of Duty: Black Ops rounds. So, I didn't get anything productive done, but the night is young and I have a pack of caffeine pills so who knows, I might do a little scripting, but chances are getting lost in algorithms and writing C# code, inevitably taring out my hair in the process, but puzzles keep my mind fresh. It shall be an entertaining and knowledgeable night, sounds fun!
I'm starting with a webpage, written in html of course, for my buddy.... You see the other day, my buddy spun out with another car on the highway, and totaled his car in an accident, so he had confided in me to "search Craigslist for a slightly used one for sale......" Well, that's no fun.... I could write a small script to send the data through google, referencing http://minneapolis.craigslist.org/, but that's a few simple lines plus seems like a waste of time taking the long way of a basic task. I've decided, a fancy little html page with links to low mileage cars that I've found, and saved the URL's to a document.
Webpage complete, took longer than expected but I ran to the store to grab Red Bull and a Sobe LifeWater, with coconut water of course, so delicious. Now, to move on to the main course of the night :) Going to throw, a few code snippets into the Hangman console application, but shall not hold my full attention, no... I have a craving for something different, something not involving string manipulation..... hmmm...... well, I guess i could have an "app" to scan files for size( in bytes ), as well as, tell you number of lines and characters. But I already have an object similar to that, just needs to be tweaked, or "Hacked", a little bit. Although, I can change it to send hex code to a file created, or if already exists, opened with read/write permissions addressing location of in hex~
Decided to rewrite an old Rock Paper Scissors game from when I first learned C#, for some reason it refuses to output your "Win Rate".... It may the lack of sleep, but I can't find the bug in the code.... Whatever......
Source Code:
I'm starting with a webpage, written in html of course, for my buddy.... You see the other day, my buddy spun out with another car on the highway, and totaled his car in an accident, so he had confided in me to "search Craigslist for a slightly used one for sale......" Well, that's no fun.... I could write a small script to send the data through google, referencing http://minneapolis.craigslist.org/, but that's a few simple lines plus seems like a waste of time taking the long way of a basic task. I've decided, a fancy little html page with links to low mileage cars that I've found, and saved the URL's to a document.
Webpage complete, took longer than expected but I ran to the store to grab Red Bull and a Sobe LifeWater, with coconut water of course, so delicious. Now, to move on to the main course of the night :) Going to throw, a few code snippets into the Hangman console application, but shall not hold my full attention, no... I have a craving for something different, something not involving string manipulation..... hmmm...... well, I guess i could have an "app" to scan files for size( in bytes ), as well as, tell you number of lines and characters. But I already have an object similar to that, just needs to be tweaked, or "Hacked", a little bit. Although, I can change it to send hex code to a file created, or if already exists, opened with read/write permissions addressing location of in hex~
Decided to rewrite an old Rock Paper Scissors game from when I first learned C#, for some reason it refuses to output your "Win Rate".... It may the lack of sleep, but I can't find the bug in the code.... Whatever......
Source Code:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace RockPaperScissors
- {
- public class RpsClass
- {
- int count = 0;
- static void Main(string[] args)
- {
- string userInput;
- bool gameOver = false;
- RpsClass Wins = new RpsClass();
- RpsClass Loses = new RpsClass();
- RpsClass Ties = new RpsClass();
- RpsClass Rounds = new RpsClass();
- int rate;
- TitleScreen();
- Console.WriteLine("\n(R)ock, (P)aper, (S)cissors, (Q)uit\n\n\n");
- while (!gameOver)
- {
- Console.WriteLine("Wins:\t{0}", Wins.count);
- Console.WriteLine("Loses:\t{0}", Loses.count);
- Console.WriteLine("Ties:\t{0}", Ties.count);
- Console.WriteLine("Win Rate:\n{0}%\n\n", rate = GetPercentage(Wins, Rounds));
- Console.Write("Choose your Weapon.");
- userInput = Console.ReadLine().ToLower();
- if (userInput == "q")
- {
- gameOver = true;
- }
- else
- {
- Result DidI = CheckWinOrLose(userInput);
- if (DidI.Equals(Result.Win))
- {
- Wins.count++;
- }
- else if (DidI.Equals(Result.Lose))
- {
- Loses.count++;
- }
- else if (DidI.Equals(Result.Tie))
- {
- Ties.count++;
- }
- }
- Rounds.count++;
- Console.Clear();
- }
- }
- private static int GetPercentage(RpsClass Wins, RpsClass Rounds)
- {
- if (Rounds.count != 0 && Wins.count != 0)
- {
- int rate = (Wins.count * 100) /Rounds.count;
- // int rate = Wins.count / Rounds.count * 100;
- return rate;
- }
- return 0;
- }
- private static Result CheckWinOrLose(string userInput)
- {
- RpsClass Wins = new RpsClass();
- RpsClass Loses = new RpsClass();
- RpsClass Ties = new RpsClass();
- Random compChoice = new Random();
- int compWeapon = compChoice.Next(0, 3);
- if (compWeapon == 0)
- {
- if (userInput == "r")
- {
- Console.WriteLine("You Tied!");
- return Result.Tie;
- }
- else if (userInput == "p")
- {
- Console.WriteLine("You Win!!");
- return Result.Win;
- }
- else if (userInput == "s")
- {
- Console.WriteLine("You Lose....");
- return Result.Lose;
- }
- else
- {
- Console.WriteLine("Invalid choice.Try Again!");
- return Result.Invalid;
- }
- }
- else if (compWeapon == 1)
- {
- if (userInput == "r")
- {
- Console.WriteLine("You Lose....");
- return Result.Lose;
- }
- else if (userInput == "p")
- {
- Console.WriteLine("You Tied!");
- return Result.Tie;
- }
- else if (userInput == "s")
- {
- Console.WriteLine("You Win!!");
- return Result.Lose;
- }
- else
- {
- Console.WriteLine("Invalid choice.Try Again!");
- return Result.Invalid;
- }
- }
- else if (compWeapon == 2)
- {
- if (userInput == "r")
- {
- Console.WriteLine("You Win!!");
- return Result.Win;
- }
- else if (userInput == "p")
- {
- Console.WriteLine("You Lose....");
- return Result.Lose;
- }
- else if (userInput == "s")
- {
- Console.WriteLine("You Tied!");
- return Result.Tie;
- }
- else
- {
- Console.WriteLine("Invalid choice.Try Again!");
- return Result.Invalid;
- }
- }
- return Result.Invalid;
- }
- private static void TitleScreen()
- {
- Console.WriteLine("\t*********************************************************");
- Console.WriteLine("\t*********************************************************");
- Console.WriteLine("\t***\t\t\t ***");
- Console.WriteLine("\t***\t\t\t ***");
- Console.WriteLine("\t***\t\t\t ***");
- Console.WriteLine("\t***\t\t R0ckP4p3rSc1ss0r5 v 1.0 ***");
- Console.WriteLine("\t***\t Written By: N0kturn4LC0d3M0nk33 ***");
- Console.WriteLine("\t***\t\t\t ***");
- Console.WriteLine("\t***\t\t\t ***");
- Console.WriteLine("\t***\t\t\t ***");
- Console.WriteLine("\t*********************************************************");
- Console.WriteLine("\t*********************************************************");
- }
- public enum Result
- {
- Win,
- Lose,
- Tie,
- Invalid,
- }
- }
- }
After further investigation I discovered the issue, the algoritm to calculate "Win Rate" was wrong, I'm updating the source code right now. Enjoy!
Comments
Post a Comment