Chess engines work in a few different ways depending on the complexity.
First, as you said, the computer needs to understand it's legal moves. This can be done easily enough by giving each piece a list of valid move offsets from their current location. For example, on an 8x8 board, and counting tiles from the upper left going left to right and then wrapping down to the next row left side (which a 2 dimensional array can model for you) a bishop can move (+/-)n(7) or (+/-)n(9) spaces. You would need to figure out how to define each of these moves and give the pieces the appropriate settings.
Movement is the easy part, the A.I. is where it really gets fun.
Because there are many different ways a chess system A.I. can be written, I am going to just outline a very simple one. For this A.I. all pieces need to have a value so we know what pieces are worth more than the others. Below is how I value my pieces when I play chess. This can be different but I believe this is a pretty common valuation:
1 - king
2 - queen
3 - rook
4 - bishop
5 - knight
6 - pawn
The next step is to define how the A.I. will start a game or act when no piece is in range. Giving a set of random first moves is a good way to start. After the first play, when no valid attacks exist, you could have an aggressive A.I. set itself up for a run on the king. In other words, move a strong piece into an attack position. Or you could move a piece to back up another piece for a more defensive A.I.
Finally, you would want to define the attack strategy rules. At the beginning of each turn, the A.I. needs to evaluate if a piece is in danger. If it is, it should check if it's piece is backed up and if the opposing piece is of greater or lesser value than itself (this is because a piece of greater value will not usually put itself in danger for a piece of lesser value). If no action needs to be taken to protect itself, then it should check to see if it can take any pieces and again, check if the other piece is backed up and if it is higher or lower value. After gathering this list of actions, both defense and offense, the A.I. would need to evaluate which move would be the most productive. Again here you could define if the A.I. is more defensive by backing up or backing off pieces in danger or if it is more aggressive by pressing the attack.
This is of course a very simplified set of instructions but if you can get this to work, then you can look into implementing more advanced A.I. techniques.
I hope this at least gets you a starting point. Good luck with your project.