You may make it a bit more complex considering the position on the board and so on, but there will be a compromise with performance here. For example, in chess you may give pieces a value (pawn 1, knight 3, and so on) and simply add up.
This enables you to apply minimax even if the analysis of all movements up to game endings is not possible. Most importantly, you need a heuristic to assign a value to intermediate game positions. There are measures to combat this limitation, at the very general level of your question. Other games, like chess, will be too deep and have too many options at every movement (large branching factor). The tree of movements for a game can only be explore fully for simple stuff like tic-tac-toe.