Two mobile NASA robots named Gromit and K-9 showed off their talents Monday at the Ames Research Center in Mountain View, and they seemed mighty smart indeed.

Gromit navigated a rock-strewn patch of earth at a stately pace of 5 centimeters (2 inches) per second, while K-9 -- smarter and twice as fast -- moved across the simulated Martian terrain, snapping pictures of the rocks and analyzing their composition with half-minute pauses for reasoned reflection along the way.

The robots, loaded with combinations of sophisticated software, cameras, spectrometers and global positioning system location-finders are prototypes of the robots NASA plans to send to the moon in a dozen years and to Mars after that as part of President Bush's vision for an invigorated space program.

"If we're going to have humans on the moon and Mars," said computer scientist David E. Smith, "it's clear we'll need increasingly advanced robotic systems -- and that means autonomous robots, machines that can operate on their own using their own built-in intelligence."

Although only two robots were rolled out to demonstrate their skills Monday, Smith said he expected there could be hundreds of them roving the lunar surface by 2018 before the next human astronauts set foot there.

Those "intelligent" machines, says the Ames team of robot scientists, will be able to build habitats for future human pioneers, pinpoint promising target regions for joint human-machine exploration and even warn of potentially dangerous areas that might be OK for a machine, but too perilous for humans to approach.

Tubby little Gromit, red-painted and distantly resembling R2-D2 of Star Wars fame, was named for the faithful companion of the dog named Wallace in the Oscar-winning Claymation cartoon series. He trundled toward a simulated lunar rock named Broccoli, responding dutifully to voice commands from computer scientist Andrew Ring, who was tricked out like an astronaut, equipped with a laptop and a computer program that translated his orders into software-ese.

K-9, with its six ribbed wheels and its gangly mast obviously modeled after the twin Mars Rovers Spirit and Opportunity, used its own built-in intelligence to wheel around obstacles in order to photograph Broccoli. It obeyed generalized commands from computer-wielding technicians placed inside a simulated nearby habitat.

William J. Clancey, a 30-year veteran of artificial intelligence research at Stanford University and now a member of the "Collaborative Decision Systems" team at Ames, said his group had begun its work by reviewing the needs of the Apollo astronauts on the moon three decades ago.

"Computers are thinking a lot slower than our brains do," he said. "So they can only act as personal agents for the astronauts who use them."

On Mars, the two Rovers Spirit and Opportunity have been operating spectacularly for 20 months -- far longer than their expected lifetimes of three months each. And Clancey said there was a strong possibility that at least one of them could continue exploring for another two full years.

That's time enough, he said, for some of the software now under development cooperatively at Ames, at the Jet Propulsion Laboratory in Pasadena and at Carnegie-Mellon University in Pittsburgh, to beam fresh software up to the rovers that would enable them to operate with far greater "autonomy" and fewer commands from Earth than they need now.

"That's an exciting possibility for us," Clancey said.