public void Divide() { Point p = ComExec.PointFromDir(this, (Direction)ComExec.FindEmptyDir(this)); Bot bot = new Bot(p); bot.Genotype = this.Genotype; bot.Gptr = (new Random()).Next(63); bot.RefreshImage(); MainItems.botstoadd.Add(bot); }
public void Multi() { Bot prev = this.previous; Bot nxt = this.next; if (ComExec.isMulti(prev) > 0 && ComExec.isMulti(nxt) > 0) { return; } this.Energy -= 150; if (this.Energy <= 0) { this.Die(); return; } int n = ComExec.FindEmptyDir(this); if (n == -1) { this.Die(); return; } Bot newbot = new Bot(ComExec.PointFromDir(this, (Direction)n)); newbot.Genotype = this.genom; int imo = (new Random()).Next(0, 5); if (imo == 3) { newbot.Genotype[(new Random()).Next() % 63] = (new Random()).Next() % 64; } newbot.Energy = this.Energy / 2; newbot.BotColor = this.color; this.next = newbot; newbot.previous = this; MainItems.botstoadd.Add(newbot); newbot.Napruamok = (Direction)((new Random()).Next() % 8); }
public void DoubleBot() { this.Energy -= 150; if (this.Energy <= 0) { this.Die(); } else { int dirfromorigin = ComExec.FindEmptyDir(this); Point pos = new Point(); if (dirfromorigin != -1) { switch (dirfromorigin) { case 0: { pos = ComExec.PointFromDir(this, Direction.Up); break; } case 1: { pos = ComExec.PointFromDir(this, Direction.UpRight); break; } case 2: { pos = ComExec.PointFromDir(this, Direction.Right); break; } case 3: { pos = ComExec.PointFromDir(this, Direction.RightDown); break; } case 4: { pos = ComExec.PointFromDir(this, Direction.Down); break; } case 5: { pos = ComExec.PointFromDir(this, Direction.LeftDown); break; } case 6: { pos = ComExec.PointFromDir(this, Direction.Left); break; } case 7: { pos = ComExec.PointFromDir(this, Direction.LeftUp); break; } } } else { this.Die(); return; } Bot newbot = new Bot(pos); newbot.RefreshImage();; newbot.Genotype = this.genom; int imo = (new Random()).Next(0, 5); if (imo == 3) { newbot.Genotype[(new Random()).Next() % 63] = (new Random()).Next() % 64; } newbot.Energy = this.Energy / 2; newbot.BotColor = this.color; this.next = newbot; newbot.previous = this; MainItems.botstoadd.Add(newbot); } }