Microsoft wants to help you sword fight without the physical risks of getting stabbed. The company's solution? A team at Microsoft Research has created a hardware localization technology that enables you to play a multi-player sword fighting game using only smartphones.

No, you won't need to attach any crazy lasers or peripheral accessories to make it work. The team's aptly named SwordFight game requires only the existing hardware in most shipping smartphones. But it's also not quite as simple as an app like Star Wars: Lightsaber Duel.

"There’s a lot of technology now that allows phones to connect. But if you want to enable games that have a more active flavor, then you need more," Thomas Moscibroda, a Lead Researcher in the Mobile & Sensing Systems Research Group at Microsoft Research Asia, told Wired. "What you need is a technology that allows mobile devices to localize each other. If I move, I need to know how close your phone is next to me."

Moscibroda and his colleagues on the Microsoft Research team have developed a technology called FAR. It's a new sound-ranging scheme that makes it possible for a smartphone to locate another smartphone by measuring sound. One phone sends out a chirp, and a second phone determines the distance and the position of the first phone by measuring the time it takes for the chirp to travel to its speaker.

In SwordFight, two players aim their phones toward each other, and try to jab at the other person's handset. When one player's phone strikes within 15 centimeters of the other player's phone, the second player loses a point. It's as if there are imaginary swords, albeit very tiny ones, jutting out from each device. With the help of a phone's accelerometer and digital compass, the game can tell which opponent did the striking. But what's unique is the fact that the phones can know how close they are to one another. (See the video example below.)

The process of measuring distance with sound is nothing new. But the Microsoft team created faster, more accurate algorithms built on top of the core processing principles. Traditional techniques can take about one second to turn around a measurement, David Chu, one of the Microsoft researchers on the SwordFight project told Wired. But in that one second, a person can move his arms up to 4 meters.

"If you think about the fact that you could only take one measurement per second, you could have an error of 4 meters. We’ve been able to improve that, so that we can go 12 samples per second and theoretically up to 22 samples per second," Chu said. "On average, based on our testing, we can actually achieve within 2-centimeter accuracy."

In essence, the technology is incredibly fast, allowing users to play an interactive, phone-to-phone game in real time. But it isn't limited to just a silly sword fighting game. The researchers were first inspired to create this localization technology to make games more interactive, but they see other potential applications.

"Overall, there’s really a broad applicability to it. We’re not simply talking about phones. A fundamental part of the research that we’ve done is not tied to any particular operating system or anything like that," Chu said.

All a device needs to use the FAR technology is a speaker and a microphone – components that the vast majority of modern-day tablets, PCs and phones come with.

The FAR ranging scheme works through a four-step process, starting with phones sending out a tone. Image: Microsoft Research

Unfortunately, you won't get these capabilities on your phone anytime soon. In theory, SwordFight could be released as an app on Windows Phone or other platforms, but the Microsoft Research team has no current plans to release FAR or its SwordFight game to the general public.

The technology still faces challenges. For example, the chirping noises the phone sends are very noticeable, because smartphone mics and speakers only support audible frequency range. (One solution is to make the chirps part of a game's music.) Another challenge: Users can easily block their mics or speakers, causing inaccurate measurements.

Moscibroda, Chu and the rest of the Microsoft Research team plan on further developing the technology to address these issues and create more prototype games and applications. They've already created another game called ChaseCat, which uses the same technology to let you play a two-player running game where one person attempts to get within a certain distance of another user to score points.

"We’ve seen some other developers taking the underlying technology in a completely different direction than what we had thought of," Chu said. "We think there is a healthy amount of uses in gaming and outside."