Python - simulated cellular organism

profilejtk101

In 2014 Virginia scientist Eric Betzig won a Nobel Prize for his research in microscope technology. Since receiving the award, Betzig has improved the technology so that cell functions, growth and even movements can now be seen in real time while minimizing the damage caused by prior methods. This allows the direct study of living nerve cells forming synapses in the brain, cells undergoing mitosis and internal cell functions like protein translation and mitochondrial movements.

 

 

Your assignment is to write a Python program that graphically simulates viewing cellular organisms, as they might be observed using Betzig’s technology. These simulated cells will be shown in a graphics window (representing the field of view through Betzig’s microscope) and must be animated, exhibiting behaviors based on the “Project Specifications” below. The simulation will terminate based on user input (a mouse click) and will include two (2) types of cells, Crete and Laelaps, (pronounced KREET and LEE-laps).

Crete cells should be represented in this simulation as three (3) small green circles with a radius of 8 pixels. These cells move nonlinearly in steps of 1-4 graphics window pixels. This makes their movement appear jerky and random. Crete cells cannot move outside the microscope slide, (the ‘field’), so they may bump along the borders or even wander out into the middle of the field at times. These cells have the ability to pass “through” each other.

A single red circle with a radius of 16 pixels will represent a Laelaps cell in this simulation. Laelaps cells move across the field straight lines, appearing to ‘bounce’ off the field boundaries. Laelaps sometimes appear to pass through other cells, however this is an optical illusion as they are very thin and tend to slide over or under the other cells in the field of view.

page1image21840 page1image22000

Project Specifications: ==================== Graphics Window

  • 500 x 500 pixel window

  • White background

  • 0,0 (x,y) coordinate should be set to the lower left-hand corner

    Crete Cells

  • Three (3) green filled circles with radius of 8 pixels

  • Move in random increments between -4 and 4 pixels per step

  • Movements are not in straight lines, but appear wander aimlessly

    Laelaps Cells

  • One (1) red filled circle with a radius of 16 pixels

  • Move more quickly than Crete cells and in straight lines

  • The Laelaps cell should advance in either -10 or 10 pixels per step

    TODO #1: Initialize the simulation environment ========================================

  • Import any libraries needed for the simulation

  • Display a welcome message in the Python Shell. Describe the program’s functionality

  • Create the 500 x 500 graphics window named “Field

  • Set the Field window parameters as specified

    TODO #2: Create the Crete cells – makeCrete() ========================================

  • Write a function that creates three green circle objects (radius 8) and stores them in a list

  • Each entry of the list represents one Crete cell

  • The starting (x, y) locations of the Crete cells will be random values between 50 – 450

  • The function should return the list of Crete cells

    TODO #3: Create the Laelaps cell – makeLaelaps() ===========================================

  • Write a function that creates a list containing a single entry; a red filled circle (radius 16) representing the Laelaps cell

  • The starting (x, y) location of these cells should be random values between 100–400

  • Add two randomly selected integers to the list. They should be either -10 or 10

  • The function should return the Laelaps cell list

 

TODO #4: Define the bounce() function ==================================

  • Write a function that accepts two (2) integers as parameters

  • If the first integer is either less than 10 or greater than 490, the function should return the

    inverse value of the 2nd integer, (ie: multiplying it by -1)

  • Otherwise, the function should return the 2nd integer unmodified

    TODO #5: Define the main() function ==================================

  • Using the makeCrete() function, create a list of Crete cells

  • Draw the Crete cells in the Field graphics window

  • Using the makeLaelaps() function, create the Laelaps list

  • Draw the Laelaps cell in the Field window

  • Using a while loop, animate the cells in the Field window

o Animate each Crete cell by moving it’s (x,y) position by a number of pixels specified

by a randomly selected integer between -4 and 4
o Animate the Laelaps cell by moving it’s (x,y) position by the number of pixels

specified in the integer values in it’s list (this will always be either -10 or 10 pixels)
o HINT: Use the bounce() function to make sure the change in a cell’s position doesn’t

move the cell outside the Field boundaries
o End the while loop if a mouse click is detected in the Field graphics window

  • Close the Field graphics window

  • Print a message that the simulation has terminated

    Extra Credit Challenges: 10 points each only if TODO #1 - 5 are complete ===============================================================

  • CROSSING GUARD: Laelaps cell ‘bounces’ off the Crete cells instead sliding past them

  • NO PASSING ZONE: Crete cells bounce off each other instead of passing through 

    • 11 years ago
    • 15
    Answer(0)