Introduction

Immune System title screen
Screenshot of the title screen and instructions from the second milestone.
Immune System screenshot
Screenshot of the system when bacteria have multiplied and killed some cells. From the second milestone.

This project came from a Java focused programming course from the IAT program during my Spring 2020 semester. It was an individual project where I had 4 weeks to plan and create a multimedia interactive program. I created a simplified simulation of a human immune system, with cells being attacked by bacteria or viruses and the body’s response. I will be going through how this project was developed and delving into its technical aspects whenever possible.

For technical requirements, I needed to utilize:

Planning the Program

Sketch organizing classes
Sketching and planning objects and relationships to each other.
Sketch of program's appearance
Sketch of the program's final form and how it would look like.

In the first week, I planned out the system and how it would meet the requirements. I was fairly set on the immune system because of the rising COVID-19 pandemic, and I thought it would be interesting to make. With a concept in mind, I thought about the objects I needed, their roles and thinking of connections for hierarchies. I decided to feature immune cells such as macrophages, helper t-cells and antibodies because their roles seemed simple to program.

Explanation of the System

Screenshot of the program as it just started
Screenshot of the program starting out. A few cells would have green spots indicating their infection. From the second milestone.
Screenshot of the program with a higher spread of intruders
Screenshot of the program when invaders (bacteria in the image) are given time to multiply. From the second milestone.
Screenshot of the program when all intruders have been eliminated
Screenshot of one of two possible end states of the program. The other end state is if all of the organ cells (circles on the right while the program is running) are gone. From the second milestone.

Though I did not fully plan out the system this early in development, this section is to explain the program’s components and procedure. The program starts off with a few cells infected by virus or bacteria and it will try to spread to the other cells. The intruders drift in random directions and infect animal cells they come into contact to. Macrophages actively target the intruders to consume them and if the problem persists, helper t-cells and antibodies will come to assist. Helper t-cells supply macrophages with more energy and antibodies drift around the body, stopping any invaders they touch. The program ends when the vital organ cells have died, or all the intruders have been eliminated and the body returns to normal.

The First Milestone

Screenshot of the first milestone
Screenshot from the first milestone. Cells did not have any visual indication of their infection in this iteration.
Screenshot of the first milestone
Screenshot of the first milestone with bacteria multiplying.

During this phase of development, I created the program’s foundation. I decided I would have 4 packages: main, intruder, immune system, and body cells. Cells that had similar purposes were grouped up together to make the file structure more organized. For example, the intruder package contained classes for bacteria, virus, and their shared abstract superclass. By the second week, many of the cells were functionally complete with only a few tweaks needed. It wasn’t difficult to make cells move in a direction and bounce off walls. I also already figured out how to make objects track another object from a previous assignment in the same course. With the project being close to functional, I just needed to implement the graphics which would implement the perlin noise, fractals, and decorators.

Issues with using Iterators

I planned to use the iterator at the start of the program to go through an arraylist which held the body cells and have it pick out a few cells to be infected. However, this arraylist is dynamic and having an iterator go through the collection caused concurrent modification exception errors. To work around this issue, I created an organ cell wall, an arraylist of objects with a set number of objects. The iterator would to go through this arraylist to check each cell’s status and change them from a dead or alive state on intervals.

The Second Milestone

Screenshot of the program as it just started
Screenshot of the second milestone as the simulation has started.
Screenshot of the program with a higher spread of intruders
Screenshot of the second milestone with more bacteria inside the system.
Screenshot of the program when all intruders have been eliminated
Screenshot of the second milestone with more macrophages in response to the higher bacteria.

In program’s final iteration, I completed the rest of the requirements. I had two weeks to work since the first milestone and I incorporated GUI buttons, perlin noise to appear as DNA strands, fractals to create capillaries, decorators to show cell infection, and an FSM to control the program’s states. I also made the system respond differently depending on how many cells are alive, but this was implemented somewhat late into development and I didn’t have much time to make it more complex.

Conclusion

I am really happy how this project turned out. I finished most things I set out to do, it visually looks good and there aren’t too many bugs (at least ones that I know of). I also got a really good grade on this too, getting a 37/33 because I fulfilled all of the coding requirements and a lot of bonus points for my effort. Working on this project really shows my capabilities and potential with creating software.

Run the Program!

You can run the program by downloading the zip file, unzipping and running the .jar file. This project is also on GitHub so you can also download the project files and see my code.

Download files GitHub