Skip to content

Commit

Permalink
Added Immune cells
Browse files Browse the repository at this point in the history
Also source code for Version 1.3
  • Loading branch information
1Codealot authored Mar 21, 2023
1 parent 0936c1a commit c25ba69
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions Infection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@

Generation = 0


f = open("Infection_Settings.txt","r")

X=f.readline()
Y=f.readline()
Healing=f.readline()
MinGensToUninfect=f.readline()
ChanceOfHealing=f.readline()
Immunity=f.readline()
ImmuneCellCount=f.readline()

X=int(X[2:])
Y=int(Y[2:])
Healing=int(Healing[8:]) #1 = True because I couldn't get srings to work and idc
MinGensToUninfect=int(MinGensToUninfect[18:])
ChanceOfHealing=int(ChanceOfHealing[16:])
Immunity=int(Immunity[9:])
ImmuneCellCount=int(ImmuneCellCount[16:])

Cells=[] #Main List
InCells=[] #Place where cells were infected
Expand All @@ -26,7 +29,21 @@
for i in range(0,X):
Cells.append("○") #○ = uninfected, ● = infected
Gen_Infected.append(-1)


if Immunity == 1:
for u in range(ImmuneCellCount):
Cells[u] = "X"
Gen_Infected[u] = 9999

temp = list(zip(Cells, Gen_Infected))
random.shuffle(temp)
random.shuffle(temp)
random.shuffle(temp) #So it gets more shufflesd.
Cells, Gen_Infected = zip(*temp)

Cells=(list(Cells))
Gen_Infected=(list(Gen_Infected))

def Print_As_Grid(X,Y):
for n in range(len(Cells)):
if n % X == 0:
Expand All @@ -52,31 +69,31 @@ def Print_As_Grid(X,Y):

if CellInfecting != X*Y-1 and CellInfecting % X != X-1:
Infected = random.randint(1,4)
if Infected == 1:
if Infected == 1 and Cells[CellInfecting+1] != "X":
Cells[CellInfecting+1]="●"
if CellInfecting+1 in InCells:
InCells.remove(CellInfecting+1)
InCells.append(CellInfecting+1)

if CellInfecting <= X*Y-X:
if CellInfecting <= (X*Y-X)-1:
Infected = random.randint(1,4)
if Infected == 2:
if Infected == 2 and Cells[CellInfecting+X] != "X":
Cells[CellInfecting+X]="●"
if CellInfecting+X in InCells:
InCells.remove(CellInfecting+X)
InCells.append(CellInfecting+X)

if CellInfecting >= 1 and CellInfecting % X != 0:
Infected = random.randint(1,4)
if Infected == 3:
if Infected == 3 and Cells[CellInfecting-1] != "X":
Cells[CellInfecting-1]="●"
if CellInfecting-1 in InCells:
InCells.remove(CellInfecting-1)
InCells.append(CellInfecting-1)

if CellInfecting >= X+1:
Infected = random.randint(1,4)
if Infected == 4:
if Infected == 4 and Cells[CellInfecting-X] != "X":
Cells[CellInfecting-X]="●"
if CellInfecting-X in InCells:
InCells.remove(CellInfecting-X)
Expand All @@ -91,11 +108,11 @@ def Print_As_Grid(X,Y):
InCells.remove(h)

Generation += 1
print("\n\n\n\n\n")
print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
Print_As_Grid(X,Y)

print("\n",len(InCells), "Cells infected.")
print("Generation:", Generation)
time.sleep(0.5)
time.sleep(0.35)

input()

0 comments on commit c25ba69

Please sign in to comment.