Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members

LT8.cs

Go to the documentation of this file.
00001 /*
00002 SimImmuno version 1.0
00003 Copyright (C) 2005 sebeuh.ajsinfo.net
00004 
00005 SimImmuno est libre, vous pouvez le redistribuer et/ou le modifier
00006 selon les termes de la Licence Publique Générale GNU publiée par la
00007 Free Software Foundation (version 2).
00008 
00009 SimImmuno est distribué car potentiellement utile, mais SANS AUCUNE GARANTIE,
00010 ni explicite ni implicite, y compris les garanties de commercialisation
00011 ou d'adaptation dans un but spécifique. Reportez-vous à la
00012 Licence Publique Générale GNU pour plus de détails.
00013 
00014 Texte de la license officielle (anglais) :
00015 http://simimmuno.ajsinfo.net/text.aspx?code=no&txt_file=GPL.txt
00016 Traduction francaise (non-officielle) :
00017 http://simimmuno.ajsinfo.net/text.aspx?code=no&txt_file=GPL-fr.txt
00018 */
00019 using System;
00020 
00021 namespace SimImmuno
00022 {
00023         [Serializable]
00024         public class LT8 : Cellule
00025         {
00026                 int active_by_il = 0;
00027                 int last_infect_detect;
00028 
00029                 public LT8(int x, int y) : base(x,y)
00030                 {
00031                         Life = 5000;
00032                         specificite = rnd.Next(5);
00033                         last_infect_detect = 0;
00034                         cell_plusproche = null;
00035                 }
00036 
00037                 public LT8(int x, int y, int spe) : base(x,y)
00038                 {
00039                         Life = 5000;
00040                         specificite = spe;
00041                         last_infect_detect = 0;
00042                         cell_plusproche = null;
00043                 }
00044 
00045                 public LT8(int x, int y, int spe, int life) : base(x,y)
00046                 {
00047                         Life = life;
00048                         specificite = spe;
00049                         last_infect_detect = 0;
00050                         cell_plusproche = null;
00051                 }
00052 
00053                 new public void Action()
00054                 {
00055                         if(active_by_il != 0)
00056                                 active_by_il--;
00057                         Mouvement();
00058                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00059                         int tmp = 0;
00060                         foreach(Cellule cell in ccol_copy)
00061                         {       
00062                                 double dst = DistTo(cell,this);
00063                                 if(dst < 200 && tmp == 0)
00064                                 {
00065                                         if(cell is CellInfect)
00066                                         {
00067                                                 if(specificite == cell.specificite)
00068                                                 {
00069                                                         if(last_infect_detect != cell.index)
00070                                                         {
00071                                                                 int b = rnd.Next(1,3);
00072                                                                 for(int a=0;a<b;a++)
00073                                                                 {
00074                                                                         ProdLTc(this);
00075                                                                 }
00076                                                                 frmMain.log.NewEvent("Cellule infectée n°" + cell.index.ToString() + " detectée,création de LTc de spé:" + specificite.ToString());
00077                                                                 tmp++;
00078                                                                 last_infect_detect = cell.index;
00079                                                         }
00080                                                 }
00081                                         }
00082                                         else if(cell is InfectVIH)
00083                                         {
00084                                                 if(last_infect_detect != cell.index)
00085                                                 {
00086                                                         int b = rnd.Next(1,3);
00087                                                         for(int a=0;a<b;a++)
00088                                                         {
00089                                                                 ProdLTc(this);
00090                                                         }
00091                                                         frmMain.log.NewEvent("Cell. infectée VIH n°" + cell.index.ToString() + " detectée,création de LTc de spé:" + specificite.ToString());
00092                                                         tmp++;
00093                                                         last_infect_detect = cell.index;
00094                                                 }
00095                                         }
00096                                 }
00097                         }
00098                         return;
00099                 }
00100 
00101                 private void ProdLTc(Cellule lt8_producteur)
00102                 {
00103                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00104                         int count = 0;
00105                         foreach(Cellule cell in ccol_copy)
00106                         {
00107                                 if(cell is LTc)
00108                                         if(cell.specificite == lt8_producteur.specificite)
00109                                         {
00110                                                 count++;        
00111                                         }
00112                         }
00113                         if(count < 30)
00114                         {
00115                                 int x = rnd.Next(-5,5);
00116                                 int y = rnd.Next(-5,5);
00117                                 LTc ltc1 = new LTc(lt8_producteur.Location.X+x,lt8_producteur.Location.Y+y,lt8_producteur.specificite);
00118                                 frmMain.ccol.Add(ltc1);
00119                                 int c = rnd.Next(1,5);
00120                                 for(int a=0;a<c;a++)
00121                                 {
00122                                         ProdLT8Memoire(this);
00123                                 }
00124                         }
00125                 }
00126 
00127                 private void ProdLT8Memoire(Cellule icell)
00128                 {
00129                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00130                         int count = 0;
00131                         foreach(Cellule cell in ccol_copy)
00132                         {
00133                                 if(cell is LT8m)
00134                                         if(cell.specificite == icell.specificite)
00135                                         {
00136                                                 count++;        
00137                                         }
00138                         }
00139                         if(count < 20)
00140                         {
00141                                 int x = rnd.Next(-5,5);
00142                                 int y = rnd.Next(-5,5);
00143                                 LT8m lt8m1 = new LT8m(icell.Location.X+x,icell.Location.Y+y,icell.specificite);
00144                                 frmMain.ccol.Add(lt8m1);
00145                                 frmMain.log.NewEvent("Production d'un LT8m de spé : " + icell.specificite.ToString());
00146                         }
00147                 }
00148 
00149                 public void Activation(Cellule cell)
00150                 {
00151                         if(active_by_il == 0)
00152                                 active_by_il = 200;
00153                 }
00154 
00155                 private void Mouvement()
00156                 {
00157                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00158                         if(cell_plusproche != null)
00159                         {
00160                                 if((TestIfAlive(cell_plusproche)))
00161                                 {
00162                                         if(cell_plusproche.Location.X < this.Location.X)
00163                                                 this.Location.X = this.Location.X - 5;
00164                                         else
00165                                                 this.Location.X = this.Location.X + 5;
00166                                         if(cell_plusproche.Location.Y < this.Location.Y)
00167                                                 this.Location.Y = this.Location.Y - 5;
00168                                         else
00169                                                 this.Location.Y = this.Location.Y + 5;
00170                                 }
00171                                 else
00172                                         cell_plusproche = null;
00173                         }
00174                         else
00175                         {
00176                                 foreach(Cellule cell in ccol_copy)
00177                                 {
00178                                         int perimetre;
00179                                         if(active_by_il != 0)
00180                                                 perimetre = 45000;
00181                                         else
00182                                                 perimetre = 20000;
00183                                         if(DistTo(this,cell) < perimetre)
00184                                         {
00185                                                 if(cell is CellInfect || cell is InfectVIH)
00186                                                 {
00187                                                         if(cell.specificite == this.specificite)
00188                                                         {
00189                                                                 if(!(TestIfDejaSelect(cell)))
00190                                                                 {
00191                                                                         if(cell_plusproche == null)
00192                                                                                 cell_plusproche = cell;
00193                                                                         if(DistTo(this,cell_plusproche) > DistTo(this,cell))
00194                                                                                 cell_plusproche = cell;
00195                                                                 }
00196                                                         }
00197                                                 }
00198                                         }
00199                                 }
00200                                 int tmp2 = rnd.Next(2);
00201                                 int x,y;
00202                                 if(tmp2 == 0)
00203                                 {
00204                                         x = this.Location.X + rnd.Next(-5,5);
00205                                         y = this.Location.Y + rnd.Next(-5,5);
00206                                 }
00207                                 else
00208                                 {
00209                                         x = this.Location.X - rnd.Next(-5,5);
00210                                         y = this.Location.Y - rnd.Next(-5,5);
00211                                 }
00212                                 this.Location.X = x;
00213                                 this.Location.Y = y;
00214                         }
00215                 }
00216 
00217                 private bool TestIfAlive(Cellule cell)
00218                 {
00219                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00220                         bool tmp = false;
00221                         foreach(Cellule icell in ccol_copy)
00222                         {
00223                                 if(icell.index == cell.index && icell.specificite == cell.specificite  && tmp == false)
00224                                 {
00225                                         if(icell is CellInfect || cell is InfectVIH)
00226                                         {
00227                                                 double dst = DistTo(cell,icell);
00228                                                 if(dst < 200)
00229                                                         tmp = true;
00230                                         }
00231                                 }
00232                         }
00233                         return tmp;
00234                 }
00235 
00236                 private bool TestIfDejaSelect(Cellule cell)
00237                 {
00238                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00239                         bool tmp = false;
00240                         foreach(Cellule icell in ccol_copy)
00241                         {
00242                                 if(icell is LT8 && tmp == false)
00243                                 {
00244                                         if(icell.cell_plusproche == cell)
00245                                                 tmp = true;
00246                                         else
00247                                                 tmp = false;
00248                                 }
00249                         }
00250                         return tmp;
00251                 }
00252         }
00253 }

Generated on Sat Jun 4 15:03:42 2005 for SimImmuno by  doxygen 1.4.2