Valcour Fiction (C#)

I’m attempting to make an IF engine library in C#. You will be able to code your entire game using Visual Studio or your code editor of choice. It is very much a work in progress.

If you would like to help, please add me on Discord. My name is Haravin#9622.

Here is a picture of the parser dealing with ambiguity and determining the amount of things specified based on articles.

Before you write too much in c#, is that the best language to choose?

Firstly, i like c# and have written several projects with it in the past, BUT;

That’s all well and good when your app is for Windows. What’s the deal these days with c# on linux/osx/android etc. I suppose we’re talking Xamarin. Anyone have any experience with this. is it really cross platform? what happens on iOS, for example. Also, i guess it means being stuck with Xamarin, which could go bad one day…

Then you need an answer to why not use Quest, which i think is the leading c# IF system.

However, it’s not that im trying to dissuade you from taking a different path, because if you tread the same (recommended) path, you end without differentiating. However;

It might be worth having a think about how the graphic UI might work or more design of the world model. So there’s architecture there. Do you split the game engine from the UI? do you split the world model from the story? Perhaps there are modules and/or perhaps some of them eg (eg story) is a domain specific language. etc

hope that helps. Good luck with the project.

I believe there’s a path many of us take when we engage in IF, one of which is to attempt developing our own platform. Not necessarily to be used by anyone, but because it’s such an intriguing problem. How do you build a parser, world model, and engine that has simplicity and elegance? How do you implement a componentized standard library?

As for C#, there are many things you could do with it that would enable excellent IF programming concepts. And it is cross-platform with .NET Core 2.0 (MacOS, Linux, Windows). App development would still be tricky, but I think it’s premature to expect a fledgling system to be that ambitious.

I applaud anyone that attempts this feat.

That said: To Haravin: Don’t expect any help from the IF community outside of advice and review. We’re notoriously like a herd of cats. Some of us may sniff around your code, but we’re likely to be distracted by something very quickly.

I’m proud to announce that, after several years of studying and hard work, I finally crossed the mountain. My library now takes ambiguity into account.

This was probably the toughest thing I ever coded. I had to draw this out on paper a dozen times until it made sense enough for me to try it.

Now that I have this finished, the rest of the engine will be a piece of cake to code. Wont be long before I have my first official release. Its all downhill from here!

Hopefully, before you finish this project or make it fully available you fix the glaring spelling mistake in the samples you have posted.

And you may need even bigger paper when your player enters a command “take brown” or “open brown” in a room with two brown doors (one closed), one brown mug on the table and several same brown mugs in the cabinet :wink:

I guess you do this mainly as a learning experience, so I would kindly suggest NOT to skip over deeper look on TADS3. You can learn a lot by studying its source code - all the library (from parser to world model) is written in t3 and fully commented (almost half of the library are comments!) and a number of full-scale and very polished games with open source code are available too.

Good luck with your project!

You may find this thread interesting.

It goes into the scenario where, for example, the player is holding the red ball and the blue ball is on the ground. “take ball” would then resolve to the blue ball because it makes no sense taking something the player already has (the red ball). Likewise, “drop ball” would drop the red ball without asking which ball.

Interesting point, I am probably going to handle this with a special “flag” or something. Thanks for the link!

Yes I know, I don’t really care about grammar in things like that. That was more of a test to see if it actually works or not. But, I understand your point. It doesn’t look very professional. I will try to avoid doing that in the future.

Yes, I have already looked at that code quite a bit. Thanks for the suggestion!

EDIT: Here is my main issue. This library is almost feature complete, but as you can see, its very clunky to code right now.

I would love ideas of how to make this easier to code in. It works, it just looks ugly.

I know - that’s the reason I suggested to take deeper look on TADS :slight_smile: You may realize that domain specific languages like TADS has lots of tiny little tweaks to make programming of IF much more practical. One of most obvious is that you can directly declare objects in TADS (as opposite to declare class and then instantiate an object from class in second step) and that it is dynamic language so you can add any property or method to object, not just the ones declared on class. Inform approaches same problem with radically different approach, but with same efficiency in comparison to universal programming languages.

Ok, so to be more constructive. Keep in mind I don’t know C# even a tiny bit. I do mainly PHP and other web technologies and also know C++. I’ve quickly looked around StackOverflow and it seems C# like other languages should be able to do fluent interface (google that term if you don’t know), so you should be able to optimize API a bit. I believe something like:

var ball = Thing // Not to repeat class twice .create("red,squishy/ball") // static method of class to instantiate object, parameters for constructor passed here .desc("Hello") // should also accept callback instead of static text, that's common in IF .addFlag("isScrewable"); // method to add to list of flags instead of assembling by yourself in main, can call many times to add many flags
should be possible in C#. This could help you a with readability of code, but you won’t be able to achieve same level as with domain specific languages.

That is a wonderful idea. I was thinking about using delegates instead of overridden classes for verbs, so I can define them in the main method instead of having to make a whole new class for each one. I figured out a way of doing this with just constructors.

Some nouns:

Some verbs:

Perhaps there is a way I can make the arguments more dynamic, so you can pass in anything in any order while building the object. Also, maybe combining this with your method would be smart too, to give people options while building their games.

I’m going to take a break from this project for a few days and do other things. When I come back, I should be able to finish this very quickly. Please stay tuned!

Look at C# Fluent interfaces. If you search around you’ll find various implementations, but it would allow you to change the code to:

    .Room("Living Room")
    .Description("You are standing in the living room.")
    .SourthOf("Dining Room")
        Verb.DoAttack( () => { .. code .. } ),
        Verb.DoTalkTo( () => { .. code .. } ),
        Verb.DoAttack( () => { .. code .. } ),
        Verb.DoTalkTo( () => { .. code .. } ),

This is a good page:

1 Like

C# has named arguments. You can just do:

new Thing( desc: "A thing.", vocab: "thing", name: "thing" location: kitchen, // ... );

I’ve thought of learning C#; maybe testing this library will give me a reason to learn it. Will probably create a version of Cloak of Darkness for the lib.
Also, tomasb is write; take a look at TADS 3. The syntax is sort of C#-like.
(TADS 3 is 2 parts C#, 1 part Java and 1 part TADS 2 IMHO, so studying T3 would do you some good.)

I’m afraid that Haravin has given up the project like a day or two after his last post.

Oh well, that kinda sucks. :frowning:

That’s unfortunate. I would love to have a running discussion of a C# based IF platform.