Could unity be used to create a programming game (like robocode for example)?

I'm currently working on a programming game in a custom 2d engine, but came across unity and am really impressed! I think development could be much quicker if I can switch to unity.

The method I'm using at them moment is to have the game read user created scripts at runtime, and use those scripts to control the game's AI. Currently those scripts are in lua (as that's the game engine's language), but it's not really important what the script language is. However it is important that the game can load scripts at runtime, and those scripts should not have to be pre-compiled.

As unity has scripts compiled before use, I'm not sure if this is possible in unity, or if there's an alternative method I could use to get around it. Does anyone have any experience in this area or suggestions as to how I might go forward?

Javascript in Unity has eval(), which you can use to execute code at runtime. You could also write your own script interpreter in Unity, which would take significantly more development time, but would allow you to use whatever language you want (including one of your own invention), and would provide the most control.

You can't easily use on the fly compiling of .NET code to add things during runtime, but as you have to define an API for the client scripts a possible solution would be to have the client scripts communicate through sockets. Not ideal, but easier to prevent cheating as access for the scripts is really limited to what your API defines. Another possibility would be to make a plugin for Unity that loads the binaries generated by LUA and acts like a bridge between the scripts and Unity.

I’ve actually research quite a bit on this regarding a few project ideas I’ve had.

My conclusion was that you should build up your own “API” for the users to access.
Then make a run-time interprenter that parses/compiles the users scripts into logic blocks of instructions, just like MONO/.NET does it.

Afterwards you have some resulting arrays and these can be parsed quite easily with clever usages of multiple Switch/case statements.

I dont say its easy, but certainly possible. The speed of the processing will not match Unity/Mono speed, as its another layer below it. But you can still use Unity3D speed to move objects, render 3D surfaces etc.

So YES!