Notice that for each side of a board there are 7 places to place another board. (To see all the possibilities place a board so that only one square touches the other board, then slide the first one along that side.)
So you can place the first board in the center to get started, then randomly choose a side and then choose one of the 7 positions. Now it gets a little tricky. We can randomly choose a board and then a side and then a position, but we don’t want overlaps so we need to check for those and pick again if the board would overlap.
You can use a
Dictionary<string, boolean> to keep track of which spaces are taken by taking the integer coords and concatenating then together with a comma (or whatever separator), and storing
true in the dictionary for all the taken spaces.
So if you do that, then you can generate a potential place to put a board, check if it is taken (that is, if any of the squares it would cover are already in the dictionary,) and if not, place it and add its squares to the dictionary. Otherwise try another place.
You may also want to keep track of the spaces you have already tried so you don’t end up trying them more than once.