Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Text;
- using System.Collections.Generic;
- namespace MonsterTest
- {
- class MainClass
- {
- public static void Main (string[] args)
- {
- // Open a file for the results.
- Monster.Rng = new Random();
- const int numDudes = 100;
- using(FileStream resStream = File.Open("outdata.csv", FileMode.OpenOrCreate))
- {
- AppendValue(resStream, "Strength, Mojo, Soak, Willpower, Reflex, Intelligence\r\n");
- // Create some monsters
- List<Monster> monsters = new List<Monster>();
- for (int m = 0; m < numDudes; m++)
- {
- monsters.Add(new Monster());
- }
- // Round robin the monsters
- List<int> wins = new List<int>();
- for (int i = 0; i < numDudes; i++)
- {
- wins.Add(0);
- for (int j = 0; j < numDudes; j++)
- {
- // Don't fight ourselves
- if (i == j)
- continue;
- wins[i] += monsters[i].Fight(monsters[j]) ? 1 : 0;
- }
- }
- List<KeyValuePair<int, int>> kvp = new List<KeyValuePair<int, int>>();
- for (int i = 0; i < wins.Count; i++)
- kvp.Add(new KeyValuePair<int, int>(i, wins[i]));
- // Sort
- kvp.Sort(delegate(KeyValuePair<int, int> x, KeyValuePair<int, int> y) { return x.Value.CompareTo(y.Value); });
- for (int w = wins.Count - 1; w > wins.Count - 6; w--)
- AppendMonster(resStream, monsters[kvp[w].Key]);
- }
- Console.WriteLine ("Hello World!");
- }
- private static void AppendValue(FileStream fs, string value)
- {
- byte[] info = new UTF8Encoding(true).GetBytes(value);
- fs.Write(info, 0, info.Length);
- }
- private static void AppendMonster(FileStream fs, Monster value)
- {
- string monsterString =
- value.Strength.ToString() + ", " +
- value.Mojo.ToString() + ", " +
- value.Soak.ToString() + ", " +
- value.Willpower.ToString() + ", " +
- value.Reflex.ToString() + ", " +
- value.Intelligence.ToString() + "\r\n";
- AppendValue(fs, monsterString);
- }
- }
- }
Add Comment
Please, Sign In to add comment