# \[LINK\] Ruby DSL for turn-based strategy game

**URL:** <https://www.ruby-forum.com/t/link-ruby-dsl-for-turn-based-strategy-game/67854>\
**Category:** Ruby\
**Created:** [September 7, 2006, 11:34am UTC](https://www.ruby-forum.com/t/link-ruby-dsl-for-turn-based-strategy-game/67854 "2006-09-07T11:34:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicwilliams](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/aca169/32.png) [@nicwilliams](https://www.ruby-forum.com/u/nicwilliams)\
**Post date:** [September 7, 2006, 11:34am UTC](https://www.ruby-forum.com/t/link-ruby-dsl-for-turn-based-strategy-game/67854/1 "2006-09-07T11:34:10Z")

</div>

"I continue to develop Dr Nicâ??s Civilizations game. This lead me to  
develop a DSL for the specification of game rules. You need to see this.

"Hereâ??s an example definition of some terrain:

class Desert \< Terrain  
title “Desert”  
letter “d”  
graphic “desert”  
movement\_cost 1  
defense\_bonus 10  
food 0  
shield 1  
trade 0  
end  
class Oasis \< Desert  
title “Oasis”  
special\_code 1  
food 3  
shield 1  
trade 0  
graphic “oasis”  
end

“An Oasis is a special version of the Desert terrain, so Ruby subclasses  
offer a compatible relationship.”

I’ve written up why I used a Ruby DSL for this static configuration, and  
how it is implemented here:  
[http://drnicwilliams.com/2006/09/07/turn-based-game-dsl/](http://drnicwilliams.com/2006/09/07/turn-based-game-dsl/)

Cheers  
Nic
