Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have to build a 2D version of this game:

http://en.wikipedia.org/wiki/Carcassonne_(board_game)

counting scores for Towns and Roads seems easy enough (but I'm not sure), but for Lands I feel I don't have a clue.

I'm guessing I can define 3 "plugs" for each side, 12 for each tile, and then using pairs to create links between them inside a tile...

I remembered seeing that there is some book about graphes with boost, but I'm sure I don't need that...

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Lands are only being counted at the end of the game, so you'll only have to do this once per game-session.

Since you'll know all completed cities beforehand (to calculate points for the cities), I'll probably do the following:

  • Remove one "follower" from the list of followers (list A) that were placed on "land". Add the follower to list B.
  • Start a flood-fill at the followers position.
  • If your fill hits a city (which wasn't added before), add it to a list of adjacent cities.
  • If your fill hits another follower, remove it from list A and add it to list B
  • Separating road-pieces, rivers or missing pieces will obviously stop the flood fill.

After your flood-fill completes, count the number of followers from list B for each player. Depending on what ruleset (second edition, third edition) you'll have to implement, you can now split up points for all players that placed their followers in the land in question.

Now repeat this procedure, as long as list A still contains any followers.

I might be mistaken, but I guess one plug (or node) per corner should be sufficient to model the different possible connections.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.