Search Unity

Discussion Would an ideal game engine allow you to do one thing in game with a single line of code?

Discussion in 'General Discussion' started by Arowx, Aug 24, 2022.

Thread Status:
Not open for further replies.
  1. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    What amazing game things can you do in Unity with one line of code?
    And what things take multiple lines of code?

    Would the ideal game engine allow one line of code to do any in game action?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,990
    Code (CSharp):
    1. transform.position = Random.onUnitSphere;
    That's pretty amazing if you ask me. Consider how many assembler statements this used to be back in the 80s.

    You may be interested in functional programming. F# for instance, or LINQ which uses this concept.
    And you may want to consider not lines, which is a formatting concept, but statements. For example, this code example, even though it spans multiple lines, is a single statement:

    Code (CSharp):
    1. from inter in
    2.                                        from thing in traceRayArgs.Scene.Things
    3.                                        select thing.Intersect(testRay)
    4.                                    where inter != null
    5.                                    orderby inter.Dist
    6.                                    select inter
    This was taken from a raytrace renderer implemented entirely with LINQ.

    Anyhow, the answer to your last question is: no.
     
    Arowx likes this.
  3. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,779
  4. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Good point maybe the last question should be:

    Should a great game engine let you build a small codebase that lets you do any in game action in one line of code?

    The emphasis on the small codebase being key to a good to great game engine API.
     
  5. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Isn't that what methods/functions effectively are in code though?
    You hide complexity into a single function call.

    For example a Walk action can be called in one line, and all the code required to make a character walk is all contained within that function.
    But that has to be our job to implement, because a walk action in one game will require a different implementation to another game.
     
    xexuxjy likes this.
  6. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    But is it a game engines job to make our code as easy as possible to work.

    Or how many lines of code should a walk function have?
     
  7. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,203
    I can simulate application errors. :p

    Code (csharp):
    1. Application.Quit(1);
     
  8. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    Above all else code should be easy to read, the number of lines doesn't really matter as long as it all has purpose.

    It's precisely because there is no single answer to that question as to why Unity doesn't try to solve that problem for you, it just gives you the tools to write your own implementation specific to your needs.
    My point was really that once any function is written it is only one line to call it. Programming languages already do what you seem to be wanting them to do. The inner complexity in a function (specific to a given project) no longer matters once it's written.

    But if an engine tries to second guess what you mean and provide generic functions for complex tasks they wont be of use to most people anyway, because they wont do exactly what you need them to do.

    This conversation reminds me of the theory as to why AI code generation has its limits for solving specifically defined computing tasks, because code itself is the best design specification and the only way to remove ambiguity.

    In other words, hypothetically you could ask an advance AI machine to "build a Doom clone" and it would.
    But the only way to get *exactly* the Doom clone you want from your imagination you would have to be so specific in your description as to need to write a detailed logical specification (so you are back to writing code!).

    (You can replace "Doom Clone" with "Walk" function or anything else higher level then standard engine API functionality and the same applies).
     
    stain2319 likes this.
  9. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    to me, an ideal that i can visualize that i might expect to exist in my lifetime would be voice-commanded visual scripting, with something akin to auto-correct that might ask for clarification when needed.

    The system must be designed so that every change you make provides immediate ability to test things out - ideally there is never a period where it cannot be tested.

    Typing on keys is slow and requires too much brain power all on its own. When people are able to just sort of think out loud and the computer handles translation, that would be ideal.
     
  10. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,052
    pointless and off-topic.
     
    MadeFromPolygons likes this.
Thread Status:
Not open for further replies.