Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- namespace HearthStats
- {
- class Program
- {
- //Create enum "State", so we can
- public enum State
- {
- ROBBINGBANK, HAVINGGOODTIME, LAYINGLOW, FLEEING,
- }
- private static Random rnd = new Random();
- private static State currentState = State.ROBBINGBANK;
- private static int wealth = 0, distanceToCop = 1, strength = 10;
- static void Main(string[] args)
- {
- Console.WriteLine("Wealth: " + wealth.ToString() + " Distance: " + distanceToCop.ToString() + " Strength: " + strength.ToString());
- while (true)
- {
- switch(currentState)
- {
- case State.ROBBINGBANK: {
- wealth++;
- strength--;
- if (rnd.Next(0, 10) < 3) distanceToCop = 0;
- if (distanceToCop == 0)
- {
- currentState = State.FLEEING;
- Console.WriteLine("There's a cop, better start running!!"); break;
- }
- if (wealth >= 5 && strength >= 5)
- {
- Console.WriteLine("I got enough money and feel strong enough to have a good time!");
- currentState = State.HAVINGGOODTIME; break;
- }
- if (strength == 0)
- {
- Console.WriteLine("I'm out of energy, i need rest!");
- currentState = State.LAYINGLOW;
- }
- Console.WriteLine("Status: Robbing the bank");
- Console.WriteLine("Wealth: " + wealth.ToString() + " Distance: " + distanceToCop.ToString() + " Strength: " + strength.ToString());
- break;
- }
- case State.HAVINGGOODTIME: {
- wealth--;
- strength--;
- if(rnd.Next(0, 10) < 3) distanceToCop = 0;
- if (distanceToCop == 0)
- {
- Console.WriteLine("There's a cop, better start running!!");
- currentState = State.FLEEING; break;
- }
- if (strength == 0)
- {
- Console.WriteLine("I 'm feeling weak, i should rest.");
- currentState = State.LAYINGLOW; break;
- }
- if(wealth == 0)
- {
- Console.WriteLine("I'm out of money, i should try to get some more.");
- currentState = State.ROBBINGBANK; break;
- }
- Console.WriteLine("Status: Having a good time");
- Console.WriteLine("Wealth: " + wealth.ToString() + " Distance: " + distanceToCop.ToString() + " Strength: " + strength.ToString());
- break;
- }
- case State.LAYINGLOW: {
- strength++;
- if(strength >= 5 && wealth >= 5)
- {
- Console.WriteLine("Time to have a good time again!");
- currentState = State.HAVINGGOODTIME;
- }
- if (strength >= 5)
- {
- Console.WriteLine("I feel refreshed, let's go rob a bank again!");
- currentState = State.ROBBINGBANK; break;
- }
- Console.WriteLine("Status: Laying low");
- Console.WriteLine("Wealth: " + wealth.ToString() + " Distance: " + distanceToCop.ToString() + " Strength: " + strength.ToString());
- break;
- }
- case State.FLEEING: {
- strength--;
- distanceToCop++;
- if(distanceToCop > 2) {
- Console.WriteLine("I lost the cop, lets go rest");
- currentState = State.LAYINGLOW; break;
- }
- if (wealth >= 5 && strength >= 5)
- {
- Console.WriteLine("I lost the cop, i feel safe, time to have a good time!!");
- currentState = State.HAVINGGOODTIME; break;
- }
- if (strength > 0 && wealth < 5)
- {
- Console.WriteLine("I feel safe, let's go rob a bank again!");
- currentState = State.ROBBINGBANK; break;
- }
- if(strength == 0)
- {
- currentState = State.LAYINGLOW;
- }
- Console.WriteLine("Status: Fleeing!!");
- Console.WriteLine("Wealth: " + wealth.ToString() + " Distance: " + distanceToCop.ToString() + " Strength: " + strength.ToString());
- break;
- }
- }
- Thread.Sleep(1000);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement