You need to generate all the vaild moves for the given state. Then for every possibility you should to check the opponents possible moves. If there is at least one of them which makes your position worse then you should not follow that branch. To do this you need some kind of scoring to determine how well you are doing. Chess already have some rules about which unit worth how much points. It is enough to look ahead only a few steps like this. Beating the program will still be challenging.
This is of course far from perfect: real players can sacrifice some units to achieve long term goals. This algorithm will not do that.