Counting | Rules of the game
Counting

The game in the diagram on the left is finished. Black has captured three white stones and white one black. There is one dead stone in black's territory and there are two dead stones in white's territory. These dead stones are removed from the board and put aside as prisoners. Black has in total 4 prisoners and white has 3.

After removing the dead stones black has 20 points territory and white has 27.
So black has 3 + 1 + 20 = 24 points.
White has 1 + 2 + 27 = 30 points.
White has won the game by six points.

To make counting easier, the prisoners can be put in the opponent's territory. Stones can be moved inside a territory in order to form rectangular empty spaces. If you do that black ends up with 17 points and white with 23. The difference is again 6 points.

Note that points are scored primarily by making territory.
Also note that a dead stone is worth 2 points: one as a prisoner and one as a point of territory.