title: How to recursively fill a tree with 4 children below each node in Java
body: <p>I've built my own tree data class in Java which is to be used in a minimax algorithm. Each node in the tree will hold a Board object (something else I created) representing a unique game state, and edges (Integer's representing move directions —— the game is Tron) in the tree will represent the move made by a user to reach the state the edge leads to. I want to make a function which takes in a Tree and recursively fills it up to a depth 'DEPTH' (held as a constant elsewhere, not a parameter) with modified game states given each of the four possible Integer moves made by each player at each level. I'm just not quite sure how best to do it...</p>
  
  <p>Also, since it's being used for minimax, the tree structure has to be as follows:</p>
  
  <ul>
  <li>A root representing the current, unchanged game state</li>
  <li>1st level children representing the altered game states given the user's 4 possible moves</li>
  <li>2nd level children representing the altered game states given the opponent's 4 possible moves</li>
  <li>3rd level game states for the user's 4 moves given the opponent's moves, and so on... extending on to DEPTH number of levels</li>
  </ul>
  
  <p>Here are the basic methods that I have to work with:</p>
  
  <ul>
  <li>a constructor for Tree taking a Board and an Integer direction leading to the board</li>
  <li>a method called produceChildren() that takes a Tree and boolean 'userMove' and adds 4 new Board's to the Tree's internal list of children which represent the altered game states given each of the user or opponent's 4 possible moves. The 'userMove' parameter designates whether the Board's produced as children should be results of a user's 4 moves or an opponent's 4 moves.</li>
  <li>a method of Tree called getDepth() that return the node's depth within a larger tree consisting of its parent and children (if it has any) --> returns 0 if it is the root</li>
  </ul>
  
  <p>Could anyone perhaps provide me with a bit of pseudocode (using the methods I've provided, unless other methods are needed) for how I would fill a Tree in this alternating, minimax-catered way?</p>