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

LB.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 LB : Cellule
00025         {
00026                 int active_by_il = 0;
00027                 int last_ag_detect;
00028 
00029                 public LB(int x, int y) : base(x,y)
00030                 {
00031                         Life = 5000;
00032                         specificite = rnd.Next(5);
00033                         last_ag_detect = 0;
00034                         cell_plusproche = null;
00035                 }
00036 
00037                 public LB(int x, int y, int spe) : base(x,y)
00038                 {
00039                         Life = 10000;
00040                         specificite = spe;
00041                         last_ag_detect = 0;
00042                         cell_plusproche = null;
00043                 }
00044 
00045                 public LB(int x, int y, int spe, int life) : base(x,y)
00046                 {
00047                         Life = life;
00048                         specificite = spe;
00049                         last_ag_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 Antigen)
00066                                         {
00067                                                 if(specificite == cell.specificite)
00068                                                 {
00069                                                         if(last_ag_detect != cell.index)
00070                                                         {
00071                                                                 int b = rnd.Next(1,3);
00072                                                                 for(int a=0;a<b;a++)
00073                                                                 {
00074                                                                         ProdPlasmo(this);
00075                                                                 }
00076                                                                 frmMain.log.NewEvent("Ag n°" + cell.index.ToString() + " detecté,prod. de Plasmocyte(s) de spé:" + specificite.ToString());
00077                                                                 int c = rnd.Next(1,4);
00078                                                                 for(int a=0;a<c;a++)
00079                                                                 {
00080                                                                         ProdLBMemoire(this);
00081                                                                 }
00082                                                                 last_ag_detect = cell.index;
00083                                                                 tmp++;
00084                                                         }
00085                                                 }
00086                                         }
00087                                         else if(cell is VIH && specificite == cell.specificite && last_ag_detect != cell.index)
00088                                         {
00089                                                 int b = rnd.Next(1,10);
00090                                                 for(int a=0;a<b;a++)
00091                                                 {
00092                                                         ProdPlasmo(this);
00093                                                 }
00094                                                 frmMain.log.NewEvent("VIH n°" + cell.index.ToString() + " detecté,prod. de Plasmocyte(s) de spé:" + specificite.ToString());
00095                                                 int c = rnd.Next(1,10);
00096                                                 for(int a=0;a<c;a++)
00097                                                 {
00098                                                         ProdLBMemoire(this);
00099                                                 }
00100                                                 last_ag_detect = cell.index;
00101                                                 tmp++;
00102                                         }
00103                                 }
00104                         }
00105                         return;
00106                 }
00107 
00108                 private void ProdPlasmo(Cellule icell)
00109                 {
00110                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00111                         int count = 0;
00112                         foreach(Cellule cell in ccol_copy)
00113                         {
00114                                 if(cell is Plasmocyte)
00115                                         if(cell.specificite == icell.specificite)
00116                                         {
00117                                                 count++;        
00118                                         }
00119                         }
00120                         if(count < 20)
00121                         {
00122                                 int x = rnd.Next(-5,5);
00123                                 int y = rnd.Next(-5,5);
00124                                 Plasmocyte pc1 = new Plasmocyte(icell.Location.X+x,icell.Location.Y+y,specificite);
00125                                 frmMain.ccol.Add(pc1);
00126                                 pc1.Activation(this);
00127                         }
00128                 }
00129 
00130                 private void ProdLBMemoire(Cellule icell)
00131                 {
00132                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00133                         int count = 0;
00134                         foreach(Cellule cell in ccol_copy)
00135                         {
00136                                 if(cell is LBm)
00137                                         if(cell.specificite == icell.specificite)
00138                                         {
00139                                                 count++;        
00140                                         }
00141                         }
00142                         if(count < 20)
00143                         {
00144                                 int x = rnd.Next(-5,5);
00145                                 int y = rnd.Next(-5,5);
00146                                 LBm lbm1 = new LBm(icell.Location.X+x,icell.Location.Y+y,icell.specificite);
00147                                 frmMain.ccol.Add(lbm1);
00148                                 frmMain.log.NewEvent("Production d'un LBm de spé : " + icell.specificite.ToString());
00149                         }
00150                 }
00151 
00152                 public void Activation(Cellule cell)
00153                 { 
00154                         if(active_by_il == 0)
00155                 active_by_il = 200;
00156                 }
00157 
00158                 private void Mouvement()
00159                 {
00160                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00161                         if(cell_plusproche != null)
00162                         {
00163                                 if((TestIfAlive(cell_plusproche)))
00164                                 {
00165                                         if(cell_plusproche.Location.X < this.Location.X)
00166                                                 this.Location.X = this.Location.X - 5;
00167                                         else
00168                                                 this.Location.X = this.Location.X + 5;
00169                                         if(cell_plusproche.Location.Y < this.Location.Y)
00170                                                 this.Location.Y = this.Location.Y - 5;
00171                                         else
00172                                                 this.Location.Y = this.Location.Y + 5;
00173                                 }
00174                                 else
00175                                         cell_plusproche = null;
00176                         }
00177                         else
00178                         {
00179                                 foreach(Cellule cell in ccol_copy)
00180                                 {
00181                                         int perimetre;
00182                                         if(active_by_il != 0)
00183                                                 perimetre = 45000;
00184                                         else
00185                                                 perimetre = 20000;
00186                                         if(DistTo(this,cell) < perimetre)
00187                                         {
00188                                                 if(cell is Antigen || cell is VIH)
00189                                                 {
00190                                                         if(cell.specificite == this.specificite)
00191                                                         {
00192                                                                 if(!(TestIfDejaSelect(cell)))
00193                                                                 {
00194                                                                         if(cell_plusproche == null)
00195                                                                                 cell_plusproche = cell;
00196                                                                         if(DistTo(this,cell_plusproche) > DistTo(this,cell))
00197                                                                                 cell_plusproche = cell;
00198                                                                 }
00199                                                         }
00200                                                 }
00201                                         }
00202                                 }
00203                                 int tmp2 = rnd.Next(2);
00204                                 int x,y;
00205                                 if(tmp2 == 0)
00206                                 {
00207                                         x = this.Location.X + rnd.Next(-5,5);
00208                                         y = this.Location.Y + rnd.Next(-5,5);
00209                                 }
00210                                 else
00211                                 {
00212                                         x = this.Location.X - rnd.Next(-5,5);
00213                                         y = this.Location.Y - rnd.Next(-5,5);
00214                                 }
00215                                 this.Location.X = x;
00216                                 this.Location.Y = y;
00217                         }
00218                 }
00219 
00220                 private bool TestIfAlive(Cellule cell)
00221                 {
00222                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00223                         bool tmp = false;
00224                         foreach(Cellule icell in ccol_copy)
00225                         {
00226                                 if(icell.index == cell.index && icell.specificite == cell.specificite  && tmp == false)
00227                                 {
00228                                         if(icell is Antigen || cell is VIH)
00229                                         {
00230                                                 double dst = DistTo(cell,icell);
00231                                                 if(dst < 200)
00232                                                         tmp = true;
00233                                         }
00234                                 }
00235                         }
00236                         return tmp;
00237                 }
00238 
00239                 private bool TestIfDejaSelect(Cellule cell)
00240                 {
00241                         ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
00242                         bool tmp = false;
00243                         foreach(Cellule icell in ccol_copy)
00244                         {
00245                                 if(icell is LB && tmp == false)
00246                                 {
00247                                         if(icell.cell_plusproche == cell)
00248                                                 tmp = true;
00249                                         else
00250                                                 tmp = false;
00251                                 }
00252                         }
00253                         return tmp;
00254                 }
00255         }
00256 }

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