Ejemplo n.º 1
0
        public void initialize_world()
        {
            //C:\\Users\\kris\\Google Drive\\pcvo\\c#\\visualstudio2015\\projects\\Game_of_life\\Game_of_life\\
            var           fileloc = @"C:\Users\%username%\Google Drive\pcvo\c#\visualstudio2015\projects\Game_of_life\Game_of_life\amoebe.csv";
            string        file    = Environment.ExpandEnvironmentVariables(fileloc);
            List <string> lines   = new List <string>();
            List <string> aname   = new List <string>();
            List <string> agender = new List <string>();
            List <string> aposx   = new List <string>();
            List <string> aposy   = new List <string>();
            List <string> aage    = new List <string>();
            StreamReader  reader  = new StreamReader(file);

            //goes through a textfile and ad these to the list amoebe
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                // 4
                // Insert logic here.
                // ...
                // "line" is a line in the file. Add it to our List.
                //lines.Add(line);
                amoebe   Data   = new amoebe();
                string[] values = line.Split(';');
                Data.name = Convert.ToInt32(values[0]);
                Data.sex  = values[1];
                Data.xPos = Convert.ToInt32(values[2]);
                Data.yPos = Convert.ToInt32(values[3]);
                Data.age  = Convert.ToInt32(values[4]);

                aAmoe.Add(Data);
            }
        }
Ejemplo n.º 2
0
        public void create_amoebe(Int32 x, Int32 y, Int32 age)
        {
            Int32  rdm_sex = rdm.Next(1, 101);
            amoebe baby    = new amoebe();

            if (rdm_sex < 50)
            {
                baby.sex  = "M";
                baby.xPos = x;
                baby.yPos = y;
                baby.age  = age;
                baby.name = aAmoe.Count() + 1;
                aAmoe.Add(baby);
            }
        }