Answers.Body: <p>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 <em>environment</em> will process the action and update the game's <em>state</em>, allowing the cycle to repeat with new values.</p>
  <p>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.</p>
  <p>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.</p>
  <p>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 <a href="http://incompleteideas.net/book/the-book-2nd.html" rel="noreferrer">Reinforcement Learning: An Introduction</a> (link has an official free download PDF made by the authors).</p>
  <p>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. &quot;reinforcement learning connect 4&quot; to get example grid-based games that will be very similar to solve as yours.</p>
  <p>You don't <em>have</em> 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 <a href="https://en.wikipedia.org/wiki/Negamax" rel="noreferrer">negamax with alpha-beta pruning</a> and the Wikipedia article in the link includes full pseudocode implementation.</p>
  <p>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)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-06T11:11:31.363Z
Answers.LastActivityDate: 2023-11-06T11:11:31.363Z
Answers.UserDisplayName: Neil Slater
Body: <p>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.</p>
  <p>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.</p>
  <p><a href="https://i.sstatic.net/iCn2q.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iCn2q.png" alt="enter image description here" /></a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-11-09T11:12:55.287Z
Comments.Text: What's the question? Could you please edit the post to actually ask a question? Please, also put it in the title.
Comments.UserDisplayName: nbro
Tags: <neural-networks><machine-learning><game-ai>
Title: Neural network for game
UserDisplayName: user3576767
ThreadText: # Neural network for game
  
  (Asked by: username_0 on 2023-11-06)
  
  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](https://i.sstatic.net/iCn2q.png)](https://i.sstatic.net/iCn2q.png)
  
  **Tags:** neural-networks, machine-learning, game-ai
  > **Comments:**
  > **username_1**: What's the question? Could you please edit the post to actually ask a question? Please, also put it in the title.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2023-11-06. Score: 8 | Accepted answer
  
  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](http://incompleteideas.net/book/the-book-2nd.html) (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](https://en.wikipedia.org/wiki/Negamax) 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)
  
  
  ---
  
  