Up to Main Index Up to Journal for January, 2019 JOURNAL FOR THURSDAY 24TH JANUARY, 2019 ______________________________________________________________________________ SUBJECT: Cleaning up my mess DATE: Thu 24 Jan 22:49:09 GMT 2019 When I wrote the item search and matching code, just over a week ago, I was literally throwing together a prototype. The prototype was then pushed out as quick as possible to get some feedback. I know that the code for the prototype was a bit of a mess and hard to follow. Okay, it was an unmaintainable, convoluted mess. However, it worked and served its purpose of getting the feedback I needed. Over the past week I’ve tried to clean up the code, restructure it and turn it into something I’m happy with. Last night I threw it all away and started writing MatchLimit again from scratch. I’m not afraid of throwing away code and starting over. Hell, I threw away decades of code when I switched from Java to Go for WolfMUD! The new code is much cleaner, easier to follow, easier to maintain and more performant. The functionality has changed slightly. The match methods now return a []Result. This allows for non-matches to be returned in the order they appear in the input. The WHICH command has been updated for the new functionality. For example, assume we have some balls and a chest but no frogs: >which ball frog chest You see a large green ball here. You see no 'FROG' here. You see an iron bound chest here. Previously the “You see no 'FROG' here.” would have been tagged onto the end of the messages. The new functionality also allows reporting when there are not enough items for the limits specified. For example, assuming we have a bag, four balls and a chest: >which bag 5th ball chest You see a small bag here. You don't see that many 'BALL' here. You see an iron bound chest here. >which bag 10-15 ball chest You see a small bag here. You don't see that many 'BALL' here. You see an iron bound chest here. >which bag 3-15 ball chest You see a small bag here. You see a large red ball here. You see a small green ball here. You see an iron bound chest here. The difference between the second and third examples? In the second example no balls match the limits given, while in the third example some balls matched and hence no error. The upper limit is only a maximum, so here 3-15 is the 3rd ball up to a maximum of the 15th or just however many are available. I was worried about the additional code that would have to be written for each command to handle matches and different non-matches. Updating the WHICH command wasn’t too bad. I’ll have to see how things pan out for the rest of the commands as I update them. Some people have been asking why I am spending time on this. Others have asked why I am spending SO much time on this. The game’s command line is where players live. It’s the only way they can interact with the game world. It is therefore important to try and make it as friendly and forgiving as possible. Until now the command processing has been very, very simple. I’ve put off improving it for a long time. However I’ve decided that now was a good time to try and improve the situation. The rewritten matcher code and updated WHICH command has been pushed out to the public dev branch. Next job will be to update all of the current commands, where appropriate, to take advantage of the new functionality. I’ll also have to review and revise aliases in the zone files. Group aliases are going to become more important so that you can use commands like ‘GET ALL WEAPON’, ‘EXAMINE ALL ITEM’ and ‘READ ALL BOOK’. On a side note, I did think about trying to automatically detect plurals. Then commands like ‘GET ALL BALL’ as well as ‘GET ALL BALLS’ would work. For the most part detecting ‘s’, ‘es’ or ‘ies’ on the end of words would work for English. Take for example apples, boxes and cherries. Maybe it would be enough to have ‘box’ and ‘boxes’ as aliases instead of trying to be clever? Maybe indicate plurals with a special prefix, like the ‘+’ for qualifiers? Hrm, maybe ‘=’ or ‘~’? Alias: +RED CHERRY CHERRIES Alias: +RED CHERRY =CHERRIES Alias: +RED CHERRY ~CHERRIES Three alternatives I could choose from. It would complicate things more. For example ‘GET BOX’ could imply the first box available, whereas ‘GET BOXES’ could imply all boxes. Plenty to be thinking about while I update all the commands… -- Diddymus Up to Main Index Up to Journal for January, 2019