Cellular Movement


#1

@tjwhale and I have been discussing some specifics of microbe movement in this thread and it’s probably time to move the discussion to a more appropriately titled thread.

Basically we are discussing ways to balance the top speeds of cells as functions of their size (number of hexes), weight (depends on number of organelles and their respective weights), and the number and position of flagella relative to the center of mass of the cell.


Compound Rebalancing
#2

Maybe it’s worth thinking about what the objectives are, we want movement that feels good / is fun and which is also reasonably realistic.

I wonder if maybe just using the built in physics engine might be quite a simple way of getting something realistic and balanced. @andross Taking a few of your ideas from the other thread, let force direction be a normalized vector which points from the flagella to the center of mass of the cell.

Then you take a button press direction, for example W = (0,1) for straight up, and, when you press W, take a dot product of each flagella’s force direction with the button press direction.

So total_force = sum max(0, button_press_direction dot flagella_force_direction)

the max is taken so that flagella which are pointing away from the movement won’t push against the cell. Then when we have this total_force we define the drag on the cell to be a function of the number of organelles, maybe linear, not sure, could be quadratic. We also make the mass of the cell very low for all sizes of cell (so that the acceleration time is low).

And I think if we plug this force and drag into the physics engine it will solve it for us such that the terminal velocity is reached quickly where the drag is equal to the force supplied by the flagella. I think this would be realistic but we could balance it by adjusting the drag formula.

Something it doesn’t do is let all cells move even if they don’t have any flagella. I wonder if giving every cell an invisible flagella pointing backwards is a reasonable way of doing this, then it fits into this system well.

Does that make sense? Does it work? I’d be interested in feedback. It seems simpler to me than trying to create a big formula.


#3

An invisible flagella isn’t a good way of solving this. Not all cells in real life have flagella, perhaps it would be better if we just added an invisible pseudopod organelle that lets you move extremely slowly in any direction you wish, once you have any other movement organnele it ceases functioning


#4

Why not just have a base movement force that works in any direction. So that would allow all cells to move in any direction and then movement organelles add force on top of that to make the movement faster.


#5

Yeah I think both of those sound good.

I think it would be good if the base movement force /invisible organelle doesnt’t turn off when you add a first flagella because that could lead to situations where you get slower by adding a flagellum, and I’m pretty sure that’s not what we want.

Also, if the base force worked in any direction, it would be nice as then all cells could reverse with S, even if slowly, which is a useful feature I think.


#6

Base movement force is definitely a better idea gameplay wise than an invisible organelle. The invisible organelle would wind up counting towards the drag which isn’t something that we want. I’m all for this system. We just need to test it a bit and play around with drag. I haven’t been able to get the code built yet but is there a testing option where you can freely play with your cell’s biology and have unlimited ATP? That seems like the best way to see if drag and the effect per flagella feels right.


#7

Unfortunately, no. The closest alternative is probably to edit the starting atp to be ridiculously high and edit the starting organelle, which is a bit tricky as the organelle positions need to be specified as angular positions (q, r, rotation).


#8

Couldn’t I edit the ATP costs to be 0 instead of the starting ATP to be high?

On another note if we’re using a dot product between flagella direction and button press for force -> acceleration -> velocity then we should use the cross product for torque -> angular acceleration -> angular velocity. Inertia about the center of mass isn’t difficult to compute if we simply treat each hex of the cell as a point mass.


#9

Re angular acceleration I think one thing to be careful of it’s that it’s easy to make a harmonic oscillator. So if you have “if your angle is larger than desired then accelerate left and if it is higher then accelerate right” then that will result in oscillations.

I wrote a quick python script which sets the angle directly, which works quite nicely. https://pastebin.com/HY49QvxW

Taking a cross product with (0,0,1) would work I agree. It would also incentivise keeping your cell circular, which might be nice.


#10

The rate_of_turn variable is the thing I was thinking about.
Torque = sum_over_flagella(force * distance_to_CM)
Inertia = mass_unit*sum_over_hexes(distance_to_CM^2)

Then we would need to model angular drag as some sort of skin_friction * perimeter + drag_constant * rate_of_turn or maybe rate_of_turn^2


#11

I think it’s a bit of an odd one because what felt good when I was making that prototype is to have the cell turn fast the further you are from the target. So if you are trying to do a 180 it happens quite fast but if you turn a few degrees it happens quite smoothly.

You can use F=ma but then the whole thing becomes quite complex. For example to do a 180 you need to accelerate to your max turning speed, then hold steady for a while, and then decelerate so that you come to rest at the right angle. I think that’s probably going to be overkill, it’s a dynamical systems control problem, which is a lot to deal with.

IMO it might be best to just start with a fixed turning rate for all cells that feels good.

Then maybe make larger cells turn slower and check if that makes the game feel better or not. I think beyond that there’s not a huge amount to be gained from realism, though if you want to try it then I’m ok with it.


#12

What I suggested is probably more complicated than needed. I do think that you should turn faster with more flagella (maybe also by putting them further from CM) and slower for larger cells. I’ll play with things when I get a chance and we’ll see what feels good. I think you’re right that you should turn faster for a big turn (up to some max) than for a small turn simply for ease of control for the players. A bunch of rapid little wiggles would be really annoying to play with and look at.


#13

Isn’t cilia for turning, I thought that was the plan.


#14

If that’s the case then excuse me for being new and not knowing that.


#15

That’s fine. I’m not sure if that’s STILL the plan though it was the last time I started getting involved again. Though I personally like it as an idea. It really separates the two organelles.not trying to upset you or anything.


#16

Cilia is not purely for turning. The plan is that flagella are more ATP expensive but give a large force in one direction with less manueverability, while cilia are less ATP expensive but give a smaller force with more manueverability.


#17

Adding these 2 statements we should basically replace the total force equation with
total_force = sum max(0, button_press_direction dot flagella_force_direction)
total_force += sum max(x, button_press_direction dot cilia_force_direction)

where x will be some value greater than 0 so that cilia increase force in any direction which satisfies the “more manueverability” idea.

Just an idea. Thoughts?


#18

Personally I think it would be good to get flagella into a good place and then work on other methods of locomotion.

I like the idea of cillia too however we need to think about how the gameplay will be different. It needs to be differentiated enough to make it worth spending part of the complexity budget on it, the idea of more maneuverability at the cost of speed is an interesting one.


#19

I’m working on a prototype right now. My code includes an editor mode where you can build your cell (no MP or ATP) and then a test-drive mode where you can see how fast it moves. I still need to make it so new organelles snap to the hex grid and implement the directional dependence (I’m not up to date on microbiology, is the center of the nucleus pretty much the center of mass like an atom or no?) But I’ll post what I’ve got later this week. Also, you can adjust variables like force_per_flagella, global_top_speed, and the masses of each organelle.


#20

Sounds cool :slight_smile:

We were talking about having a prokaryote section of the game, so basically you start without a nucleus and add it later so it may be that, in the future, some cells don’t have them.

More info is here