I have an idea for a game. A few games, actually, that can built on top of the same general design.
There is a game world that the player and the other actors exist in. The player can get information from the world about his surroundings. The player can also interact with the world, picking up an object for example. Now, I would like the same thing to be possible for other, scripted actors. They are the player's competition. Instead of navigating the world and performing actions based on human input, a script should decide what they do.
I want to do this using a 2d world eventually, so I might as well give the example I want to build:
There is a 2d world with objects of various sizes and shapes. Every actor has their own field of view. They get information from the world about the objects in their field of view. For the player, this information is displayed on the screen of the user. The player navigates the world by user input.
Scripted actors navigate the world in a scripted way. They walk in a general direction, they follow a wall or things like that. Their scripts should be able to get the information about the objects in their field of view and act on it. If an other actor is detected in their field of view, they should walk in that direction for example.
All of this should happen in pretty much real-time.
The information gotten from the world (showed to the player, and given to the scripted actors) in this case would be something like a collection of "what", "where", and "in what orientation".
My question is: how I can program this effectively and efficiently?
I am thinking to build this with C and Lua. C++ is also an option. I would store the game state and display the graphics using C. The part that I don't know how to handle is the interaction between C and Lua. Not programming-wise, but design-wise. The interaction between the world and the scripted actors.
Should C provide the Lua actors with information, and then have the Lua actors call C functions that change their direction, move a step forward, etc? Will this work in real-time?
I realize that this question is broad, but I think it's not unreasonable. There are obviously ways to do this and I would like to know some.