Source: Wikipedia, "Heiankyo Alien", available under the CC-BY-SA License.
Heiankyo Alien (平安京エイリアン Heian-kyō Eirian) is a video game created by the University of Tokyo's Theoretical Science Group (TSG) in 1979. The game was originally developed as a personal computer game, and was first published by Denki Onkyō Corporation as an arcade game in January, 1980. The game has been ported to several other gaming systems since its original release.
The player controls a Heian period police officer (kebiishi) who must defend the capital city (Heian-kyō) from an alien invasion by digging holes in the ground and filling them back up after an alien falls inside. The player scores points for every alien trapped, and the quicker the hole is filled up after the alien falls in, the higher the amount of points are scored. The aliens increase in number as the levels progress, and they can escape from holes after a certain period of time elapses or if another alien passes above their hole. The player loses if they come in contact with an alien. There is a time limit for each level, and the number of aliens increases drastically when this limit is reached, essentially preventing the player from completing the level.
Meldac released a Game Boy version of the game in Japan and North America in 1990. This port includes a remake version where a new type of alien appears to chase after the player's character.
Taken from the manual:
The time is 1,000 years ago, way back in the Heian Age. The peaceful city of Kyo is suddenly invaded by aliens. A kebiishi (knight of the past) is entrusted to defend the city. He decides to confront the terrible aliens in a bold plan to bury the dreaded beasts alive.
People are being horribly devoured bite by bite by the aliens as they ravages down Miyako Ooji (The city's main street). Without even a hinawaju (type of firearm) to shoot the aliens, the keibiishi has no choice but to try to bury the aliens alive. He sets himself to the task, digging a hole on the road where the aliens are headed.
Then he hides and waits. Should any alien fall into the hole, he must quickly bury it before it can climb back out. In this game, you are to play the role of the keibiishi trying to defend the city.