Making a simple parser wouldn’t be too difficult, since English parser commands can be easily mapped to Chinese. One character per command. Something like:
- 看 - look
- 拿 - take
- 东南西北 - east, south, west, north respectively
- 上下 - up, down respectively
- 进出 - in, out respectively
- 吃 - eat
- 等 - wait
- 开 - open
- 关 - close
And so on. Adding complex grammar would be more complicated, but far from impossible.
- 把[object name]给[recipient] or just 给[recipient][object name] - implementation of “give [object name] to [recipient]”
- 用[object name][command] - implementation of “use [object name] to [command]”, so for example 用钥匙开门 would be use keys (钥匙) to open door (门)
There are some interesting aspects to consider like measure words, which you might want to put in if you’re doing an inventory system. I’m sure there’s a library out there to get the right measure words for a noun, and barring that you could just do the simple, stupid option of having the object name and then the number of it in your inventory after, in parentheses.
Does a parser really need reliable markers between words? When I tried my hand at a custom parser, I hardcoded it to recognize specific command verbs, which would go at the start of a player command, and then hardcoded in edge cases like give x to y where the parser would recognize the word “give” at the start of the string and then look for the other stuff. This grammar works for Chinese as well. The way I implemented it for English didn’t require spaces and could’ve easily been modified to accept commands without spaces. My parser sucked though, so I don’t know if there’s a better paradigm out there.
I looked at the Chinese parser linked in this post, and it already does a lot of what I talked about here. Interestingly, it seems to only accept traditional characters, not simplified. The traditional/simplified split should be fine to manage, as you’d just need to code the input to accept simplified only and convert all traditional into simplified beforehand. Doing everything in traditional would be more difficult, because the conversion from Traditional → Simplified is lossy and there are certain simplified characters that map to multiple traditional ones, but I don’t think it would be an issue for a simple parser.
I guess there’s possible ambiguity introduced with commands like 给[recipient][object name]. You’d have to start with a full list of all the possible recipients and objects and check each character after 给 in turn, crossing off the recipients/objects whose names don’t match, until you reach a recipient match. Then do the same thing with the remaining characters for an object match.
As a side note, my lack of Chinese is hampering my ability to look for any Chinese parsers. The Chinese-language Wikipedia article for MUDs, which has a section on the history of Chinese MUDs, may hold some interest. You’ll have to paste it into a translation service. It basically says the earliest MUDs were English-only, but in the 90s people worked on getting the tech to support Chinese characters. Then, it seems, you had MUDs that required you to input commands in English but gave you Chinese output. As full Chinese support was reached, there was an explosion of Chinese MUDs as people built on each other’s software.
[Edit: There’s a small but devoted Chinese MUD community that still plays text-based MUDs. According to the Chinese-language Wikipedia article on Chinese MUDs, and several videos I found on bilibili, one of the most popular early MUDs was created in late 1995 by a group of Chinese students studying abroad in the US. It’s called 北大侠客行 or just 侠客行 (Xiá Kè Xíng), meaning Ode to Gallantry. It’s titled after a highly popular novel of the same name, which was serialised in Hong Kong from 11 June 1966 to 19 April 1967 and still gets a lot of modern TV adaptations. I found this video on bilibili, which shows the gameplay, but is entirely in Chinese. The video says Ode to Gallantry still gets about 600-700 players a day. Not entirely relevant to your search, but not irrelevant either.]
[Edit 2: There are a few videos of Ode to Gallantry on Youtube, if you look up 北大侠客行, but they’re all in Chinese. There’s also a Baidu Baike article on the game, which can be copied into a translation service if you want to skim it, though no Wikipedia article. I’ll stop looking for now, since this is a serious rabbit hole.]