Editor's note: This story was originally published Nov. 19, prior to being rebroadcast on WBUR's Here and Now.

When you think of bacteria, you might think about a bunch of mindless, single-celled bugs blindly roaming the world in complete ignorance. But over the past few decades, scientists have found bacteria are much more complicated than that.

Now, a group of scientists at the University of Texas at Austin has come up with a new way of studying how bacteria interact with the world – and each other.

You see, scientists have a couple of problems when it comes to studying bacteria.

“I mean since the time of Pasteur, we’ve been growing bacteria in these large glass tubes,” says Dr. Marvin Whiteley, a microbial physiologist at UT-Austin. “The problem is most of those bacteria in those conditions – that’s not how they grow out in nature.”

“It just doesn’t look like the body to cells. You throw cells down on a piece of glass,” says Jason Shear, a chemist at UT.

The second problem is you can’t control who comes and goes. That’s a big deal, because bacteria know what other bacteria are around them. And the company a bacterium keeps can make a big difference.

“Bacteria, we seem to think, are lone rangers,” says Shear. “Really, bacteria function quite differently when they're en mass. They change their behavior – they start making different proteins and different molecules.”

In some cases, bacteria use those molecules to talk to each other.

Whiteley points to a bacterium called vibrio fischeri that lives in the ocean off the coast of Hawaii. This bacterium produces visible light.

“It does this because it has a symbiosis with a small squid there. It actually colonizes the squid and makes light for the squid,” says Whiteley. “What’s so interesting about this bacterium is it doesn’t make light until there’s a whole lot of them around.”

The vibrio fischeri actually count each other by sensing this certain molecule.

“It makes this molecule at a constant rate and as their numbers build, this molecule builds. And then as it gets to a certain point, they all respond collectively and begin to make light,” says Whiteley.

Bacteria, it turns out, are social creatures. Who they’re with and how many there are matters. Their behavior changes as their numbers grow. The results can be beautiful. Or it can be ugly. The same thing happens when some bacteria are in you. It starts with just a few of them and they lie dormant.

“They just grow and they count their numbers,” says Whiteley. Like building up an army before an attack. "Until there are so many of them that they start causing havoc and your immune system can’t clear them."

We know bacteria are changed by what’s around them, but “relatively little is known about at what point do those changes occur,” says Shear. “How many cells, for instance, need to be clustered together in what volume?”

That, in part, has been because it’s hard to isolate bacteria in little groups .

“The big problem has been how do you confine, you know, a few hundred bacteria in a place where they stay, so you can observe them over time?” says Whiteley.

What scientists need is a way to hold the cells – a very small number of them – to watch how they react when other stuff is around them.

That’s where Jodi Connell comes in. She’s a researcher in Marvin Whiteley’s lab.

She came across was a way to do just that: Trap teeny, tiny clusters of bacteria in what are essentially teeny, tiny cages.

“Instead of looking at a really well-mixed culture in a flask, this lets us look at these small aggregates that can seed an infection and lets us see how these processes transpire in small groups,” says Connell.

To do this, Connell used three things: a computer projector, some Jell-O and a laser.

Connell mixed up some store-bought Jell-O, put some bacteria in it and then chilled it. So it’s like a Jell-O mold, but the bacteria is the fruit – really tiny fruit.

Then, she used a laser and a chip from a computer projector to shoot the laser beam in a shape around a clump of bacteria.

“What the laser does is take that set gelatin and permanently links up gelatin molecules,” says Shear. The gelatin becomes permanently jelled – the molecules become mortared together like bricks.

From there, you can basically draw a microscopic house around a clump of bacteria one layer at a time. It’s kind of like 3D printing. And really, these little Jell-O houses can be pretty much any shape. They’ve made a box, a sphere, even a human skull to contain a little batch of bacteria.

With your bacteria trapped, you warm up your Jell-O mold and everything except your little cages melts away.

So then what?

“The question in bacteria is we really don’t know like how close do they need to be to each other before they actually can know the other’s there,” says Whiteley.

“Doing it this way, we can control every variable that they encounter,” says Connell.

Who they see, how close they get and how big the group is.

“By having a house and having physical walls surrounding them, they’re not able to leave,” says Whiteley. “What we’re able to do is confine them and see how they respond to certain stimuli or to each other.”

Perhaps most importantly, you can study how one group of bacteria react when a different kind of bacteria is introduced. Right now, we don’t know a lot about what happens when two bacteria types are together. But we do know that different bacteria can influence the behavior of other ones.

Staphylococcus aureus is a common bacteria that causes a lot of infections. If you surround it with another common bacteria called pseudomonas – which is resistant to an antibiotic that usually kills staphylococcus – the pseudomonas’ ability to resist the antibiotic is conferred to the staph.

But how close do they have to be? How many of each does there need to be?

Studying bacteria in little houses, and moving them around like blocks, scientists might be able to answer those questions. They may be able work out the mechanisms at work in these inter-species bacterial interactions, which could lead to more effective treatments for infections in the future.

“It may not be that you have to treat the staph because it’s really hard to treat. You may be able to treat some other bug that’s helping the staph out,” says Whiteley.

So the more we learn about the social lives of bacteria, the better we can fight them. And the next time you have an army of bad bacteria inside you, you might only have to kill off specific soldiers to win the war.