We’re rewarding the question askers & reputations are being recalculated! Read more.
4

The most naive answer would be to create a method that would set all the variables and objects the game uses to their default value. Do that thing. In the spot where you create a new game (for the first time or are resetting variables), call that function. It will set all of your variables to default and its called from both places. This is perfectly DRY. ...


1

You raise an interesting question, for which there is no definite answer. The idea of designing an engine is for ease of re-use, and to make it easier for others to use to make games quickly. With that in mind, an easy to use, high level API is desirable. Think about a power drill: I do not want, or need, to know how it functions. I Only need to know ...


1

The most portable way to do this in languages without coroutines is to convert the code into a state machine. For every yield you make a new state. Then you write code that starts from each yield point and executes the code through all paths up until the next yield. And you have to make sure that every variable that needs to persist across a yield does so. ...


1

I solved this problem in many different ways in the past. Unfortunately there is no silver bullet here. Every architecture has advantages and drawbacks. So I am going to describe several approaches here so you can choose which one is most appropriate for the game you want to create. First of all, such mechanics usually requires that a modifiable character ...


1

There are a small fixed set of possible locations on the board so measuring each one against your metrics and picking the best one would be no problem. The issue is, whether you can come up with good, (or merely good enough,) metrics. In other words, if you want the best place(s) to place a settlement then you need to define what best means. Then the rest ...


1

As you might know, it is common for ai to act and change behaviour in a Finite State Machine. This a state referes to some kind emotional state of the ai: idle, searching, fighting, running etc. Now normally, these states are context-free. Its not important, that state of the ai changed from B to K, only that the state right now is in K. You could use a ...


1

I know this question was asked a few months ago but I figured i'd go ahead and answer. The way I do it in my mud, is every player / mob have a home area/home room, and a current area/room field in their code, and each of those is associated with an integer which corresponds with the area id_number / room id_number so when they go through exits, the numbers ...


Only top voted, non community-wiki answers of a minimum length are eligible