There is a game for two, which is an NxN field (always the same size). Players take turns. The first player's goal is to connect the two points (not necessarily at the corners) given on this field. The path from one point to another is a continuous chain of points. The second player's goal is to interfere with the first player. Points are connected if they are neighbors.

As I understand it, I need something like adversarial networks, where one of them tries to connect the endpoints, and the other tries to interfere. If this is the case, then I don't understand what would be meant by generator and discriminator. Perhaps I'm wrong and some other network is needed. Because I'm a complete noob in machine learning, please point me in the right direction.

enter image description here

  • $\begingroup$ What's the question? Could you please edit the post to actually ask a question? Please, also put it in the title. $\endgroup$
    – nbro
    Nov 9, 2023 at 11:12

1 Answer 1


Neural networks do not directly take actions in games. Instead, some code needs to supply the current state of the game to the neural network, interpret its output and take the action. Typically yet more code that is separate and considered part of the environment will process the action and update the game's state, allowing the cycle to repeat with new values.

Adversarial networks, although the name suggests might be suitable for representing opponents in a game, are not normally used for this. Instead these are more tightly bound to each other and typically used to create a kind of curriculum learning starting from simple solutions and getting more sophisticated. The image generating GANs are typical examples.

Game playing with two opponents is a variation of sequential decision making problems. These have a long history of study in AI, and there are a few different ways to approach solutions.

A lot of modern techniques that apply neural networks to make game agents are based around reinforcement learning. A good introduction to the subject as a whole is Reinforcement Learning: An Introduction (link has an official free download PDF made by the authors).

It would take some time to read that book, so if you are feeling more like jumping straight in with some code examples and implementations that use neural networks, then there are lots of tutorials and example applications for agents playing various board games. Search for e.g. "reinforcement learning connect 4" to get example grid-based games that will be very similar to solve as yours.

You don't have to use neural networks or reinforcement learning. For a game as simple as yours, it is possible to write agents purely on game tree search techniques. A popular approach would be negamax with alpha-beta pruning and the Wikipedia article in the link includes full pseudocode implementation.

You can also combine search and reinforcement learning, and this is a popular technique as it speeds training for RL and makes early steps of game play with search more efficient (because the neural networks can calculate best decisions learned from starting states without needing to search as deeply)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .