How to make sure a game is compatible?

I'm buying a sims 2 game (or sims medieval) for my laptop which (I don't know if this info matters or not) is a lenovo g580 with windows 8.1
how do I make sure it will work?

You could do a google search for the game requirements!

Here are the specs for system requirements:

800 MHz processor

256 MB RAM if Windows XP
128 MB RAM if Windows 98, Windows ME, or Windows 2000
At least 3.5 gigs of free hard drive space

If you have a non-T&L capable video card (such as TNT2, Intel, or Rage for example) then you need at least:
2.0 GHz processor
256 MB RAM if Windows XP
128 MB RAM if Windows 98, Windows ME, or Windows 2000
At least 3.5 gigs of free hard drive space

Recommened video cards (and the more video memory the better):
ATI Radeon 9800 Pro
Nvidia Geforce 4

Being that Sims 2 is an older game, it should work fine although I've read posts in which people claimed they had issues running it on Windows 8 but it played fine on Windows 7.

It will work no worries.