Archived
1
0

+ added properties instead of class variables

x removed Typliste (integrated in Einwohner)
This commit is contained in:
Markus Birth 2009-01-30 21:57:37 +01:00
parent 422210793e
commit 497fd500d9
9 changed files with 153 additions and 72 deletions

View File

@ -3,40 +3,49 @@ using System;
namespace vampi namespace vampi
{ {
class Einwohner : Spielfigur { class Einwohner : Spielfigur {
public const int F_SEX = 10;
public const int SEX_MALE = 1;
public const int SEX_FEMALE = 2;
public const int F_INFECTED = 11;
private static int count = 0; private static int count = 0;
public static int Count { public static int Count {
get { return Einwohner.count; } get { return Einwohner.count; }
} }
private bool infected = false;
public bool Infected { public bool Infected {
get { return this.infected; } get { return (this.props[F_INFECTED] != 0); }
} }
public static int legalSexAge = Settings.humanLegalSexAge; public string name;
public static int vampireConversionRate = Settings.humanVampireConversionPercent;
public bool ismale;
public Einwohner(Spielfeld sfeld) public Einwohner(Spielfeld sfeld)
: base(sfeld) { : base(sfeld) {
this.typ = Typliste.EINWOHNER; this.props[F_TYPE] = TYPE_HUMAN;
this.maxAge = Settings.humanMaxAge; this.props[F_MAXAGE] = Settings.humanMaxAge;
this.age = Program.random.Next(0, Settings.humanMaxInitAge); this.props[F_AGE] = Program.random.Next(0, Settings.humanMaxInitAge);
Einwohner.count++; Einwohner.count++;
if (Program.random.Next(0, 100) < 85) this.ismale = true; else this.ismale = false; this.props[F_SEX] = (Program.random.Next(0, 100) < 85)?SEX_MALE:SEX_FEMALE;
if (this.props[F_SEX] == SEX_MALE) {
this.name = Settings.namesMale[Program.random.Next(0, Settings.namesMale.GetLength(0))];
} else {
this.name = Settings.namesFemale[Program.random.Next(0, Settings.namesFemale.GetLength(0))];
}
// Console.WriteLine(this.name+" is born! (" + ((this.ismale)?"m":"f") + ")");
} }
public void infect() { public void infect() {
if (this.infected) if (this.Infected)
return; return;
this.infected = true; // Console.WriteLine(this.name+" got infected!");
if (this.age < this.maxAge - Settings.humanInfectedMaxAge) this.age = this.maxAge - Settings.humanInfectedMaxAge; this.props[F_INFECTED] = 1;
if (this.props[F_AGE] < this.props[F_MAXAGE] - Settings.humanInfectedMaxAge) this.props[F_AGE] = this.props[F_MAXAGE] - Settings.humanInfectedMaxAge;
} }
public override void die() { public override void die() {
Einwohner.count--; Einwohner.count--;
if (this.infected) { if (this.Infected) {
int rvalue = Program.random.Next(0, 100); int rvalue = Program.random.Next(0, 100);
if (rvalue <= Einwohner.vampireConversionRate) { if (rvalue <= Settings.humanVampireConversionPercent) {
new Vampir(this.sfeld); new Vampir(this.sfeld);
return; return;
} }
@ -46,8 +55,11 @@ namespace vampi
public override void runStep() { public override void runStep() {
base.runStep(); base.runStep();
this.tryMate();
}
if (this.infected && !Settings.humanInfectedCanReproduceWithNormal) return; protected void tryMate() {
if (this.Infected && !Settings.humanInfectedCanReproduceWithNormal) return;
// search for constraints (empty field, partner to mate > 10 yrs) // search for constraints (empty field, partner to mate > 10 yrs)
Spielfeld birthplace = null; Spielfeld birthplace = null;
@ -55,12 +67,13 @@ namespace vampi
for (int i = 1; i <= 8; i++) { for (int i = 1; i <= 8; i++) {
Spielfeld neighbor = this.sfeld.getNachbarfeld(i); Spielfeld neighbor = this.sfeld.getNachbarfeld(i);
if (neighbor != null && neighbor.Sfigur != null) { if (neighbor != null && neighbor.Sfigur != null) {
if (neighbor.Sfigur.Typ == Typliste.EINWOHNER) { if (neighbor.Sfigur.props[F_TYPE] == TYPE_HUMAN) {
if (neighbor.Sfigur.Age >= Einwohner.legalSexAge && (Settings.humanNormalCanReproduceWithInfected || !((Einwohner)neighbor.Sfigur).Infected)) { if (neighbor.Sfigur.Age >= Settings.humanLegalSexAge && (Settings.humanNormalCanReproduceWithInfected || !((Einwohner)neighbor.Sfigur).Infected)) {
if (((Einwohner)neighbor.Sfigur).ismale != this.ismale) if (neighbor.Sfigur.props[F_SEX] != this.props[F_SEX]) {
mateFound = true; mateFound = true;
} }
} }
}
} else if (neighbor != null && neighbor.Sfigur == null) { } else if (neighbor != null && neighbor.Sfigur == null) {
birthplace = neighbor; birthplace = neighbor;
} }
@ -69,7 +82,6 @@ namespace vampi
if (mateFound && birthplace != null) { if (mateFound && birthplace != null) {
new Einwohner(birthplace); new Einwohner(birthplace);
} }
} }
} }
}//namespace }//namespace

View File

@ -81,13 +81,13 @@ namespace vampi {
Console.BackgroundColor = Settings.colorEmpty; Console.BackgroundColor = Settings.colorEmpty;
else { //Spielfeld besetzt else { //Spielfeld besetzt
switch (sf.Typ) { switch (sf.Typ) {
case Typliste.EINWOHNER: case Spielfigur.TYPE_HUMAN:
if (((Einwohner)sf).Infected) if (((Einwohner)sf).Infected)
Console.BackgroundColor = Settings.colorHumanInfected; Console.BackgroundColor = Settings.colorHumanInfected;
else else
Console.BackgroundColor = Settings.colorHuman; Console.BackgroundColor = Settings.colorHuman;
break; break;
case Typliste.VAMPIR: case Spielfigur.TYPE_VAMPIRE:
Console.BackgroundColor = Settings.colorVampire; Console.BackgroundColor = Settings.colorVampire;
break; break;
}//switch }//switch

View File

@ -115,13 +115,16 @@ namespace vampi {
if (sf == null) c = Settings.guiColorEmpty; //Spielfeld leer if (sf == null) c = Settings.guiColorEmpty; //Spielfeld leer
else { //Spielfeld besetzt else { //Spielfeld besetzt
switch (sf.Typ) { switch (sf.Typ) {
case Typliste.EINWOHNER: case Spielfigur.TYPE_HUMAN:
if (((Einwohner)sf).Infected) if (((Einwohner)sf).Infected)
c = getGradient(Settings.guiColorHumanInfected, 100-(double)(sf.Age-Settings.humanMaxAge+Settings.humanInfectedMaxAge)*100/(double)Settings.humanInfectedMaxAge); c = getGradient(Settings.guiColorHumanInfected, 100-(double)(sf.Age-Settings.humanMaxAge+Settings.humanInfectedMaxAge)*100/(double)Settings.humanInfectedMaxAge);
else else
c = getGradient(Settings.guiColorHuman, 100-(double)sf.Age*100/(double)Settings.humanMaxAge); if (sf.props[Einwohner.F_SEX] == Einwohner.SEX_MALE)
c = getGradient(Settings.guiColorHumanMale, 100-(double)sf.Age*100/(double)Settings.humanMaxAge);
else
c = getGradient(Settings.guiColorHumanFemale, 100-(double)sf.Age*100/(double)Settings.humanMaxAge);
break; break;
case Typliste.VAMPIR: case Spielfigur.TYPE_VAMPIRE:
c = getGradient(Settings.guiColorVampire, 100-(double)sf.Age*100/(double)Settings.vampireMaxAge); c = getGradient(Settings.guiColorVampire, 100-(double)sf.Age*100/(double)Settings.vampireMaxAge);
break; break;
} }
@ -144,11 +147,11 @@ namespace vampi {
int Ecount = Einwohner.Count; // sflaeche.countTypeOccurrences(Typliste.EINWOHNER); int Ecount = Einwohner.Count; // sflaeche.countTypeOccurrences(Typliste.EINWOHNER);
int Vcount = Vampir.Count; // sflaeche.countTypeOccurrences(Typliste.VAMPIR); int Vcount = Vampir.Count; // sflaeche.countTypeOccurrences(Typliste.VAMPIR);
g.DrawString(String.Format("Step: {0:D5}", Program.AnzSimDone), Settings.guiFont, Settings.guiFontBrush, 5, 0); g.DrawString(String.Format("Step: {0:D5}", Program.AnzSimDone), Settings.guiFont, Settings.guiFontBrush, 5, 0);
g.DrawString(String.Format("T{0:N} = {1:D}/sec", Program.lastCalcTime+Program.lastStatsTime, (int)Math.Floor(1000/(Program.lastCalcTime+Program.lastStatsTime))), Settings.guiFont, Settings.guiFontBrush, 100, 0); g.DrawString(String.Format("T{0:N} = {1:D}/sec", Program.lastOverallTime, (int)Math.Floor(1000/(Program.lastOverallTime))), Settings.guiFont, Settings.guiFontBrush, 100, 0);
g.DrawString(String.Format("C{0:N} D{1:N}", Program.lastCalcTime, Program.lastStatsTime), Settings.guiFont, Settings.guiFontBrush, 200, 0); g.DrawString(String.Format("C{0:N} D{1:N}", Program.lastCalcTime, Program.lastStatsTime), Settings.guiFont, Settings.guiFontBrush, 200, 0);
g.DrawString(String.Format(String.Format("Einwohner: {0:D} / Vampire: {1:D}", Ecount, Vcount), Program.AnzSimDone), Settings.guiFont, Settings.guiFontBrush, 5, 1*lineSpc); g.DrawString(String.Format(String.Format("Humans: {0:D} / Vampires: {1:D}", Ecount, Vcount), Program.AnzSimDone), Settings.guiFont, Settings.guiFontBrush, 5, 1*lineSpc);
g.DrawString(String.Format(String.Format("Verhältnis Vampire/Einwohner = 1/{0:N5}", (double)Ecount / Vcount), Program.AnzSimDone), Settings.guiFont, Settings.guiFontBrush, 5, 2*lineSpc); g.DrawString(String.Format(String.Format("V/H Ratio = 1/{0:N5}", (double)Ecount / Vcount), Program.AnzSimDone), Settings.guiFont, Settings.guiFontBrush, 5, 2*lineSpc);
g.DrawString(String.Format(String.Format("Bedeckung: {0:N5} %", (double)(Ecount + Vcount) / (Settings.size*Settings.size) * 100), Program.AnzSimDone), Settings.guiFont, Settings.guiFontBrush, 5, 3*lineSpc); g.DrawString(String.Format(String.Format("Coverage: {0:N5} %", (double)(Ecount + Vcount) / (Settings.size*Settings.size) * 100), Program.AnzSimDone), Settings.guiFont, Settings.guiFontBrush, 5, 3*lineSpc);
g.Dispose(); g.Dispose();
g = Graphics.FromHwnd(f.Handle); g = Graphics.FromHwnd(f.Handle);
g.DrawImageUnscaled(this.stats, 0, 0); g.DrawImageUnscaled(this.stats, 0, 0);

View File

@ -16,17 +16,25 @@ namespace vampi {
public static Spielflaeche sflaeche = new Spielflaeche(Settings.size, Settings.coveragePercent, Settings.vampireRatio); public static Spielflaeche sflaeche = new Spielflaeche(Settings.size, Settings.coveragePercent, Settings.vampireRatio);
public static double lastCalcTime = 0; public static double lastCalcTime = 0;
public static double lastStatsTime = 0; public static double lastStatsTime = 0;
public static double lastOverallTime = 0;
static void Main(string[] args) { static void Main(string[] args) {
Output output = new Output_GUI(); Output output = new Output_GUI();
Stopwatch sw = new Stopwatch(); Stopwatch sw = new Stopwatch();
Stopwatch sw2 = new Stopwatch();
for (anz_sim_done=0; anz_sim_done < anz_sim; anz_sim_done++) { for (anz_sim_done=0; anz_sim_done < anz_sim; anz_sim_done++) {
if (anz_sim_done % Settings.drawEveryNthStep == 0) { if (anz_sim_done % Settings.drawEveryNthStep == 0) {
sw2.Stop();
Program.lastOverallTime = sw2.Elapsed.TotalMilliseconds/Settings.drawEveryNthStep;
sw2.Reset();
sw2.Start();
sw.Reset(); sw.Reset();
sw.Start(); sw.Start();
Program.lastCalcTime /= Settings.drawEveryNthStep;
output.doOutput(); output.doOutput();
sw.Stop(); sw.Stop();
Program.lastCalcTime = 0;
Program.lastStatsTime = sw.Elapsed.TotalMilliseconds; Program.lastStatsTime = sw.Elapsed.TotalMilliseconds;
} }
if (output.requestAbort) break; if (output.requestAbort) break;
@ -34,7 +42,7 @@ namespace vampi {
sw.Start(); sw.Start();
sflaeche.simulateStep(); sflaeche.simulateStep();
sw.Stop(); sw.Stop();
Program.lastCalcTime = sw.Elapsed.TotalMilliseconds; Program.lastCalcTime += sw.Elapsed.TotalMilliseconds;
} }
}//Main }//Main
}//class }//class

View File

@ -17,6 +17,8 @@ namespace vampi {
public static Color guiColorHumanInfected = Color.DarkMagenta; public static Color guiColorHumanInfected = Color.DarkMagenta;
public static Color guiColorVampire = Color.Red; public static Color guiColorVampire = Color.Red;
*/ public static Color[] guiColorHuman = {Color.FromArgb(0, 60, 0), Color.LimeGreen}; */ public static Color[] guiColorHuman = {Color.FromArgb(0, 60, 0), Color.LimeGreen};
public static Color[] guiColorHumanFemale = {Color.FromArgb(60, 60, 0), Color.Yellow};
public static Color[] guiColorHumanMale = {Color.FromArgb(0, 60, 0), Color.LimeGreen};
public static Color[] guiColorHumanInfected = {Color.FromArgb(60, 0, 60), Color.DarkMagenta}; public static Color[] guiColorHumanInfected = {Color.FromArgb(60, 0, 60), Color.DarkMagenta};
public static Color[] guiColorVampire = {Color.FromArgb(60, 0, 0), Color.Red}; public static Color[] guiColorVampire = {Color.FromArgb(60, 0, 0), Color.Red};
public static Color guiColorEmpty = Color.Wheat; public static Color guiColorEmpty = Color.Wheat;
@ -40,5 +42,62 @@ namespace vampi {
public const bool vampireInfectOnlyOneHuman = false; public const bool vampireInfectOnlyOneHuman = false;
public const bool vampireInfectOneOrMoreHumans = false; public const bool vampireInfectOneOrMoreHumans = false;
public static string[] namesMale = {
"Aaron", "Achim", "Adalger", "Adam", "Adelar", "Adrian", "Aginulf", "Agomar", "Alain", "Alarich", "Alban", "Albero", "Albert", "Alderich", "Aldo", "Alexander", "Alger", "Ali", "Allen", "Amon", "Andrew", "Antoine", "Arnaud", "Arnie", "Art", "Arwed", "Arve", "Aquarius",
"Benny", "Beowulf", "Billy", "Bobby", "Bela", "Binti", "Biko", "Bastian", "Brian", "Boris", "Bero", "Bert", "Bertil", "Bernard", "Berenger", "Benoit", "Bernd", "Baldur", "Baptist", "Baldwin", "Basil", "Björn", "Bohumil", "Brad", "Burkhard", "Brix",
"Carl", "Carlo", "Cedric", "Claude", "Claus", "Cletus", "Cestos", "Colbert", "Coleman", "Cole", "Chris", "Cajetan", "Candid", "Cassian", "Castor", "Cecil", "Clark", "Cliff", "Clive", "Clemens", "Conrad", "Cosmas", "Curt", "Cyrus",
"Damian", "Dan", "Darwin", "Dave", "David", "Denis", "Derek", "Dilbert", "Dionys", "Don", "Duras", "Diablo", "Domenic", "Dorian", "Dale", "Didier", "Diego", "Dieter", "Dietrich", "Dietwald", "Dino", "Dirk", "Dismas", "Dominik", "Donald", "Doug", "Drawo", "Duncan",
"Edmond", "Eliah", "Enki", "Eric", "Etienne", "Emmerich", "Einstein", "Encke", "Earl", "Eberhard", "Ecki", "Eddi", "Edmond", "Einar", "Elias", "Elmar", "Elmo", "Emile", "Ephraim", "Erik", "Erasmus", "Ernst", "Erwin", "Esra", "Esteban", "Eugen", "Ezzo",
"Fabrice", "Felix", "Fjodor", "Francis", "Frederic", "Fritz", "Fredegar", "Furtwängler", "Florin", "Frido", "Fabian", "Falko", "Farold", "Fides", "Flodoard", "Florian", "Franz", "Fridolin", "Friedrich", "Frowin", "Fritz",
"Gaston", "Gene", "Georges", "Gerard", "Gert", "Gilbert", "Gilles", "Gino", "Guy", "Guilio", "Ghiberti", "Gismo", "Guntbert", "Gerrik", "Ged", "Gordy",
"Heiko", "Henner", "Henri", "Hubert", "Hask", "Herluf", "Hilbert", "Han Solo", "Harrison", "Herodot", "Hinrich", "Halfred",
"Ian", "Igor", "Ibert", "Immanuel", "Indy", "Ingres", "Ingram", "Ingvar", "Ignatius", "Irving", "Ivan", "Ivar", "Isbert", "Ismael",
"Jacob", "Jake", "Jamie", "Jan", "Jason", "Jay", "Jean", "Jeannot", "Jeff", "Jeffrey", "Jeremy", "Jerome", "Jimmy", "Joel", "Jon", "Jost", "Jules", "Julien", "Jervis", "Johann", "Jodokus",
"Kolya", "Kor", "Kras", "Kurn", "Kelkad", "Kenny", "Kant", "Korbinian", "Kai", "Kalle", "Karl", "Kaspar", "Kevin", "Klaas", " Klaus", "Konrad", "Kurd", "Kurt",
"Larry", "Laurent", "Lennart", "Leon", "Leonard", "Lionel", "Louis", "Luc", "Lucien", "Linné", "Lohengrin", "Leif", "Leslie", "Lewis", "Lorenz", "Loriot",
"Malcolm", "Marc", "Marcel", "Marco", "Martial", "Marvin", "Maurice", "Maxime", "Michel", "Mike", "Miles", "Momo", "Mordok", "Morten", "Manuzai", "Milio", "Meelo", "Maurice", "Machiavelli", "Micha",
"Nicolas", "Nives", "Noel", "Norbert", "Nathan", "Nahum", "Nithard", "Nick", "Nivard", "Nando",
"Odo", "Olivier", "Odin", "Oliver", "Orion", "Orlando", "Ojoro", "Orki", "Oruio", "Otker", "Otthermann",
"Pascal", "Paul", "Pete", "Peter", "Philip", "Pierre", "Pelle", "Pilo", "Pindo", "Pisto", "Poulo",
"Quark", "Quasimodo", "Quirin", "Quintus", "Quantus", "Questo", "Quasto", "Quentin", "Quentino",
"Raoul", "Remi", "Rom", "Romeo", "Romain", "Ronny", "Rudy", "Ruprecht", "Raimo", "Rudenz", "Reinold", "Rolando", "Rowland", "Rudolf", "Rodolopho", "Ray", "Raymond",
"Sammy", "Scotty", "Severin", "Simon", "Sisko", "Spock", "Steve", "Stuart", "Sven", "Sylvain", "Serge", "Sheyel", "Stephen", "Soren", "Sordes", "Strubbel",
"Tassilo", "Theo", "Thibaut", "Tilman", "Titi", "Toby", "Tom", "Tristan", "Thomas", "Tyus", "Telly", "Thilo",
"Urban", "Urs", "Udo",
"Vince", "Vincenzo", "Vincent", "Valentin", "Vaclaw", "Victor", "Vivien", "Volker", "Volkhart", "Volkmar", "Vitus", "Vittorio",
"Willi", "Wolfgang", "Worf", "Wallenstein", "Walter", "Welf", "Wennemar", "Werther", "Wigand", "Winfried", "Wolf", "Wotan",
"Xenophanes", "Xenopoulos", "Xerxes", "Xaver", "Xavier",
"Yannick", "Yvan", "Yves", "Yvon", "Yfri", "Yorick", "Yorck", "Yul", "Yvo",
"Zenji", "Zorg", "Zeltan", "Zacharias", "Zoltan", "Zyprian"
};
public static string[] namesFemale = {
"Adalie", "Adda", "Adeline", "Adelita", "Agnes", "Agneta", "Alexis", "Alice", "Aline", "Allison", "Almud", "Amanda", "Amelia", "Amy", "Andrea", "Anemone", "Angelica", "Anita", "Anja", "Annabel", "Anne", "Annette", "Anouk", "Antonia", "Ariana", "Aude", "Audrey", "Auguste", "Aurora", "Ayla", "Alouette", "Alyssa", "April", "Arlene", "Askama", "Auriga",
"Babette", "Baltrun", "Barbara", "Belannah", "Belinda", " Bernadette", "Bertha", "Betty", "Bibi", "Biggi", "Birte", "Blanche", "Britta", "Beekje", "Bilba", "Bonnie", "Beate", "Bovista",
"Camille", "Carine", "Carla", "Carmen", "Carola", "Caroline", "Cathy", "Celia", "Chantal", "Charlene", "Chloe", "Christina", "Cindy", "Claire", "Clemence", "Coco", "Colette", "Connie", "Corinne", "Cora", "Cynthia", "Carmina", "Columba",
"Dalia", "Dana", "Dani", "Danielle", "Darla", "Delphine", "Denise", "Desiree", "Dette", "Dina", "Doris", "Dunja", "Djalao", "Drawida", "Debra", "Dyonisia", "Domenica", "Dora", "Dalila",
"Edita", "Edith", "Eliane", "Elisa", "Elli", "Elsa", "Emilie", "Emma", "Erika", "Esmeralda", "Estelle", "Ethel", "Eve", "Euklida", "Eva Maria", "Elina", "Emmanuelle", "Erdtrud", "Emmi", "Ester", "Evita",
"Fafa", "Fanette", "Fatima", "Felicie", "Fiona", "Flora", "Florence", "Franzi", "Frauke", "Friederike", "Fia", "Frizzi", "Florina", "Fenjala", "Froane", "Fabienne", "Francine",
"Gerda", "Gesine", "Ginger", "Grausi", "Grenda", "Grilka", "Griselda", "Gundela", "Gwen", "Gerlis", "Gaia", "Gallia", "Grenouille", "Gea", "Gabrielle", "Gisela",
"Hannah", "Hannelore", "Helena", "Helga", "Heloise", "Henna", "Henrike", "Habima", "Haifa", "Halma", "Hero", "Huberta", "Hilaria", "Helke", "Henrietta", "Hidda",
"Ines", "Ingeborg", "Irene", "Iris", "Irma", "Isabelle", "Isolde", "Ilma", "Imperia", "Inka", "Irina", "Imura", "Inken", "Inka", "Ilka", "Ishtar",
"Janet", "Janina", "Jeanne", "Jeannie", "Jessica", "Jill", "Joanna", "Josette", "Julia", "Julianne", "Juliette", "Jellina", "Jovana", "Juliana", "June", "Jennifer", "Jordana",
"Kassandra", "Katja", "Kelly", "Kes", "Kim", "Kira", "Kordia", "Kendra", "Killy", "Kissy", "Kate", "Kathryn", "Karin", "Karla", "Kulka",
"Lara", "Laura", "Lea", "Leila", "Lili", "Linda", "Lis", "Lucia", "Lursa", "Lydie", "Lale", "Lisbeth", "Larissa", "Lelia", "Lidia", "Lora", "Loretta",
"Madeleine", "Mafalda", "Maia", "Makeba", "Mandy", "Manon", "Manuela", "Mara", "Marcelle", "Margo", "Marie", "Martine", "Mary", "Maryse", "Mathilda", "Meg", "Melusine", "Merita", "Micaela", "Michelle", "Minerva", "Minette", "Miriam", "Monika", "Marketta", "Molina", "Miranda", "Marthe", "Mariana", "Melissa", "Mona", "Mila", "Mizzi", "Molly", "Morgane",
"Nadege", "Nadine", "Naomi", "Nathalie", "Nina", "Noelle", "Norina", "Nilly", "Nadia", "Norma", "Nuptia", "Nadura",
"Odette", "Oona", "Oceana", "Odessa", "Ombra", "Ophra", "Ophelia",
"Paloma", "Pascale", "Pauline", "Pam", "Phila", "Paola", "Pelagia", "Punta", "Paula", "Perdita", "Pella", "Petra", "Panja", "Pasta", "Petula",
"Quantana", "Quentina", "Quirina", "Quanta", "Quesera", "Quarka", "Questa", "Quilla",
"Rachel", "Rebecca", "Robyn", "Roselyne", "Ruth", "Rahel", "Ricarda", "Raya", "Rea", "Renata", "Rasta",
"Sabine", "Sally", "Samantha", "Sandra", "Sandy", "Sarah", "Sarana", "Sieglinde", "Sina", "Solange", "Sophie", "Stacy", "Sibylle", "Sylvie", "Salina", "Seltar", "Setha", "Suleika", "Sunna", "Sasa", "Silvana", "Sonja", "Sinja", "Siska", "Sirta", "Sujin",
"Tabita", "Tamara", "Tanja", "Terri", "Tiffany", "Tilly", "Tina", "Tonja", "Troi", "Taina", "Tassila", "Thornia", "Tildy", "Tanita",
"Undine", "Ursula", "Ulla",
"Vekma", "Veronique", "Viviane", "Valentina", "Vilma", "Valentine", "Valerie", "Vanessa", "Vivien",
"Wanda", "Wendy", "Wilma", "Wally", "Willa", "Wismut", "Wulfila", "Wilgund", "Wilhelmina", "Wilrun", "Winny", "Wisgard", "Wiska", "Witta",
"Xenia", "Xanthia", "Xana", "Xanthippe", "Xandra",
"Yolande", "Yvette", "Yerba", "Yvonne",
"Zoe", "Zenja", "Zancara", "Zarah"
};
} }
} }

View File

@ -4,17 +4,22 @@ using System.Collections;
namespace vampi namespace vampi
{ {
public abstract class Spielfigur { public abstract class Spielfigur {
public const int F_TYPE = 0;
public const int TYPE_HUMAN = 1;
public const int TYPE_VAMPIRE = 2;
public const int F_AGE = 1;
public const int F_MAXAGE = 2;
public int[] props = new int[20];
protected Spielfeld sfeld; protected Spielfeld sfeld;
protected int typ;
protected int maxAge = 80;
protected int age = -1;
public int Age { public int Age {
get { return this.age; } get { return this.props[F_AGE]; }
} }
public int Typ { public int Typ {
get { return this.typ; } get { return this.props[F_TYPE]; }
} }
public Spielfigur(Spielfeld sfeld) { public Spielfigur(Spielfeld sfeld) {
@ -23,13 +28,11 @@ namespace vampi
} }
public virtual void runStep() { public virtual void runStep() {
if (this.age != -1) { this.props[F_AGE]++;
this.age++; if (this.props[F_AGE] >= this.props[F_MAXAGE]) {
if (this.age >= this.maxAge) {
this.die(); this.die();
} }
} }
}
public virtual void die() { public virtual void die() {
this.sfeld.Sfigur = null; this.sfeld.Sfigur = null;

View File

@ -1,7 +0,0 @@
namespace vampi
{
public abstract class Typliste {
public const int EINWOHNER = 1;
public const int VAMPIR = 2;
}
}

View File

@ -3,18 +3,19 @@ using System;
namespace vampi namespace vampi
{ {
class Vampir : Spielfigur { class Vampir : Spielfigur {
public const int F_FILLER = 10;
private static int count = 0; private static int count = 0;
public static int Count { public static int Count {
get { return Vampir.count; } get { return Vampir.count; }
} }
private int filler = Settings.vampireInitialFill;
public Vampir(Spielfeld sfeld) public Vampir(Spielfeld sfeld)
: base(sfeld) { : base(sfeld) {
this.typ = Typliste.VAMPIR; this.props[F_TYPE] = TYPE_VAMPIRE;
this.maxAge = Settings.vampireMaxAge; this.props[F_MAXAGE] = Settings.vampireMaxAge;
this.age = Program.random.Next(0, Settings.vampireMaxInitAge); this.props[F_AGE] = Program.random.Next(0, Settings.vampireMaxInitAge);
this.props[F_FILLER] = Settings.vampireInitialFill;
Vampir.count++; Vampir.count++;
} }
@ -25,23 +26,26 @@ namespace vampi
public override void runStep() { public override void runStep() {
base.runStep(); base.runStep();
this.filler -= Settings.vampireDecreaseFillPerStep; this.props[F_FILLER] -= Settings.vampireDecreaseFillPerStep;
if (this.filler <= 0) { if (this.props[F_FILLER] <= 0) {
this.die(); this.die();
return; return;
} }
this.tryInfect();
} // runStep()
protected void tryInfect() {
// count humans around me // count humans around me
int humans = 0; int humans = 0;
for (int i = 1; i <= 8; i++) { for (int i = 1; i <= 8; i++) {
Spielfeld neighbor = this.sfeld.getNachbarfeld(i); Spielfeld neighbor = this.sfeld.getNachbarfeld(i);
if (neighbor != null && neighbor.Sfigur != null) { if (neighbor != null && neighbor.Sfigur != null) {
if (neighbor.Sfigur.Typ == Typliste.EINWOHNER) { if (neighbor.Sfigur.props[F_TYPE] == TYPE_HUMAN) {
if (Settings.vampireInfectOnlyOneHuman) { if (Settings.vampireInfectOnlyOneHuman) {
humans++; humans++;
} else { } else {
((Einwohner)neighbor.Sfigur).infect(); ((Einwohner)neighbor.Sfigur).infect();
this.filler += Settings.vampireIncreaseFillPerBite; this.props[F_FILLER] += Settings.vampireIncreaseFillPerBite;
// humans is still 0, so runStep() will return after this // humans is still 0, so runStep() will return after this
} }
} }
@ -56,17 +60,17 @@ namespace vampi
for (int i = 1; i <= 8; i++) { for (int i = 1; i <= 8; i++) {
Spielfeld neighbor = this.sfeld.getNachbarfeld(i); Spielfeld neighbor = this.sfeld.getNachbarfeld(i);
if (neighbor != null && neighbor.Sfigur != null && neighbor.Sfigur.Typ == Typliste.EINWOHNER) { if (neighbor != null && neighbor.Sfigur != null && neighbor.Sfigur.props[F_TYPE] == TYPE_HUMAN) {
if (infect == 0) { if (infect == 0) {
((Einwohner)neighbor.Sfigur).infect(); ((Einwohner)neighbor.Sfigur).infect();
this.filler += Settings.vampireIncreaseFillPerBite; this.props[F_FILLER] += Settings.vampireIncreaseFillPerBite;
if (!Settings.vampireInfectOneOrMoreHumans) break; if (!Settings.vampireInfectOneOrMoreHumans) break;
} else { } else {
infect--; infect--;
} }
} }
} }
} // runStep() }
} }
} }

View File

@ -68,7 +68,6 @@
<Compile Include="Spielfeld.cs" /> <Compile Include="Spielfeld.cs" />
<Compile Include="Spielfigur.cs" /> <Compile Include="Spielfigur.cs" />
<Compile Include="Spielflaeche.cs" /> <Compile Include="Spielflaeche.cs" />
<Compile Include="Typliste.cs" />
<Compile Include="Vampir.cs" /> <Compile Include="Vampir.cs" />
<Compile Include="Output.cs" /> <Compile Include="Output.cs" />
<Compile Include="Output_CLI.cs" /> <Compile Include="Output_CLI.cs" />