Toyota recently showed a prototype engine that does just that. It’s called the Free Piston Engine Linear Generator (FPEG). “Free” refers to the fact that the piston isn’t attached to a crankshaft; instead, as the piston is forced downward during its power stroke, it passes through windings in the cylinder to generate a burst of three-phase AC electricity. The FPEG operates like a two-stroke engine but adds direct gasoline injection and electrically operated valves. It can also be run like a diesel, using compression rather than a spark plug to ignite its fuel mixture.