jeudi 30 juin 2016

Making sure you can win by testing obstacle spawns

I am currently trying to code an android game (I will not describe it in detail as it is irrelevant) in which I am faced with something I have no idea how to do:

In this game, you control a point on a 4x4 square (like a 4x4 chess board for example).

You can only move 1 square in each turn. Obstacles spawn on a random side-square (on the outer limits) of the board, and travel from one side to the other (so their direction is the same throughout their whole life-span), moving 1 square each turn. They disappear once they've reached the other side of the board. More than 1 obstacle can spawn each turn.

You lose the game instantly if you end up colliding with an obstacle.

My problem is the following : How do I make sure the obstacles always spawn so that there is at least one way of succeeding in dodging all of them? What are the tests I should operate on their spawn location that would ensure that?

The answer may be simple but I do not have a lot of experience in this kind of mathematics-applied-to-programming problems.

Thanks in advance!

(PS: I wasn't sure if Stack Overflow was the right Stack Exchange forum to ask this question, please do tell me if I should ask somewhere else.)




Aucun commentaire:

Enregistrer un commentaire