public bool recognizeDynamite(Frame.Shape?shape, Frame.Colour?colour, Frame.Material?material, Frame.Hardness?hardness, Frame.Weight?weight, Frame.Size?size, bool hasLight, bool makesSound) { Frame.Dynamite dynamite = new Frame.Dynamite(); if (shape == dynamite.shape || shape == null) { if (material == dynamite.material || material == null) { if (hardness == dynamite.hardness || hardness == null) { return(true); } } } return(false); }
public void Recognize(Frame.Explosive explosive) { Frame.BouncingBetty bouncingbetty = new Frame.BouncingBetty(); Frame.C4 c4 = new Frame.C4(); Frame.Claymore claymore = new Frame.Claymore(); Frame.Dynamite dynamite = new Frame.Dynamite(); Frame.Semtex semtex = new Frame.Semtex(); Frame.Explosive unknownExplosive = new Frame.Explosive(); bool isBouncingBetty, isC4, isClaymore, isDynamite, isSemtex, recBouncingBetty = false, recC4 = false, recClaymore = false, recDynamite = false, recSemtex = false; if (chromosome.GetGenes() != null) { foreach (KeyValuePair <String, bool> gene in chromosome.GetGenes()) { if (gene.Key == "recBouncingBetty" && gene.Value) { recBouncingBetty = true; } if (gene.Key == "recC4" && gene.Value) { recC4 = true; } if (gene.Key == "recClaymore" && gene.Value) { recClaymore = true; } if (gene.Key == "recDynamite" && gene.Value) { recDynamite = true; } if (gene.Key == "recSemtex" && gene.Value) { recSemtex = true; } } } //TODO: Zaimplementować logikę: za każdym razem, // przy przeszukiwaniu pola jeden parametr ładunku (losowo) // będzie zakrywany (będzie przyjmował wartość null) isBouncingBetty = recognizeBouncingBetty(explosive.shape, explosive.colour, explosive.material, explosive.hardness, explosive.weight, explosive.size, explosive.hasLight, explosive.makesSound); if (isBouncingBetty && recBouncingBetty) { minefield.fields[GetX(), GetY()].explosive = bouncingbetty; return; } isC4 = recognizeC4(explosive.shape, explosive.colour, explosive.material, explosive.hardness, explosive.weight, explosive.size, explosive.hasLight, explosive.makesSound); if (isC4 && recC4) { minefield.fields[GetX(), GetY()].explosive = c4; return; } isClaymore = recognizeClaymore(explosive.shape, explosive.colour, explosive.material, explosive.hardness, explosive.weight, explosive.size, explosive.hasLight, explosive.makesSound); if (isClaymore && recClaymore) { minefield.fields[GetX(), GetY()].explosive = claymore; return; } isDynamite = recognizeDynamite(explosive.shape, explosive.colour, explosive.material, explosive.hardness, explosive.weight, explosive.size, explosive.hasLight, explosive.makesSound); if (isDynamite && recDynamite) { minefield.fields[GetX(), GetY()].explosive = dynamite; return; } isSemtex = recognizeSemtex(explosive.shape, explosive.colour, explosive.material, explosive.hardness, explosive.weight, explosive.size, explosive.hasLight, explosive.makesSound); if (isSemtex && recSemtex) { minefield.fields[GetX(), GetY()].explosive = semtex; return; } minefield.fields[GetX(), GetY()].explosive = unknownExplosive; return; }