https://github.com/gilbert/lomic
Programming language for the game Nomic
https://github.com/gilbert/lomic
Last synced: 9 months ago
JSON representation
Programming language for the game Nomic
- Host: GitHub
- URL: https://github.com/gilbert/lomic
- Owner: gilbert
- License: mit
- Created: 2010-06-03T17:47:55.000Z (about 16 years ago)
- Default Branch: master
- Last Pushed: 2010-06-17T18:52:07.000Z (about 16 years ago)
- Last Synced: 2025-03-05T22:49:17.356Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 121 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: LICENSE
Awesome Lists containing this project
README
= Lomic
Lomic is a Domain Specific Language (DSL) intended to be used for Pomic, a programming version of the game Nomic.
== Getting Started
=== Installing
Install the gem:
$ gem install lomic
Or grab the latest code from github:
$ git clone git://github.com/mindeavor/lomic.git
$ cd lomic
$ rake install
=== Quick Example
Here's a self-contained, offline example. For a networking example, check out listen_path.rb[http://github.com/mindeavor/lomic/blob/master/examples/listen_path.rb] in the examples[http://github.com/mindeavor/lomic/tree/master/examples/] folder
simple.rb:
class Globals < Lomic
var :didiwin => 'No...'
end
rule 101 do |g| # g refers to globals
event "game:start" do
puts '[Example: simple.rb]'
g.didiwin = 'Yes!'
set_next "game:test1"
end
event "game:test1" do
puts "Did I win? #{g.didiwin}"
end
end
myParseFile.rb:
require 'lomic'
game_state = Lomic.parse('simple.rb', 'game:start')
== What does Lomic look like?
Lomic is designed to be expressive in declaring rules for the game Nomic:
class Globals < Lomic
var :players => []
var :currentPlayer
end
class Player < Lomic
resource :hp => 15 # resources have a max and min value
end
rule 101 do |g| # g refers to globals
### The game begins with 4 players.
### Each player is assigned a unique number.
event "game:start" do
Player.new_var :number => 0
4.times do |i|
p = Player.new
p.number = i
g.players.push(p)
end
end
end
rule 102 do |g|
### At the beginning of each player's turn,
### that player takes 3 damage
event "turn:start" do
currentPlayer.hp -= 3
end
end
Check out the `examples/` folder to see what Lomic is supposed to look like, and `parse.rb` to see how to use Lomic (in its current, underdeveloped state)
== Contributing
Lomic is currently in the concept and development stage. To discuss contributing, syntax, goals, or implementation, join us at #lomic on irc.freenode, or email me at gilbertbgarza aT gmail
== Copyright
Copyright (c) 2010 Gilbert B Garza. See LICENSE for details.