• Stars
    star
    109
  • Rank 319,077 (Top 7 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 12 years ago
  • Updated about 12 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Letterpress game engine for Ruby

Linotype

Linotype is a simple ruby implementation of the Letterpress for iOS game mechanic. Letterpress was created by Loren Brichter and is sold on iTunes. Linotype is meant to be used to write other programs such as simple player command line games, cheating/simulation programs, web-based versions, or whatever else you can think of. My goal is that the community will submit pull requests to this project so that programs can share a common engine.

The project was inspired by this tweet by Andy Baio.

The project was started by @barelyknown.

Installation

$ gem install linotype

Usage

The library provides a very simple interface using built in Ruby objects. The goal of the design is to use object oriented design strategies internally but to keep the public interface very simple to make it easy to use and extend.

Here's a basic rundown of the primary public methods:

>   game = Linotype::Game.new

>   game.board
=>  [[{:letter=>"N", :row=>0, :column=>0, :covered_by=>1, :defended=>true},
      {:letter=>"S", :row=>0, :column=>1, :covered_by=>1, :defended=>false},
      {:letter=>"L", :row=>0, :column=>2, :covered_by=>nil, :defended=>false},
      {:letter=>"K", :row=>0, :column=>3, :covered_by=>nil, :defended=>false},
      {:letter=>"W", :row=>0, :column=>4, :covered_by=>nil, :defended=>false}],
     [{:letter=>"T", :row=>1, :column=>0, :covered_by=>1, :defended=>true},
      {:letter=>"P", :row=>1, :column=>1, :covered_by=>1, :defended=>false},
      {:letter=>"Y", :row=>1, :column=>2, :covered_by=>nil, :defended=>false},
      {:letter=>"E", :row=>1, :column=>3, :covered_by=>1, :defended=>false},
      {:letter=>"E", :row=>1, :column=>4, :covered_by=>nil, :defended=>false}],
     [{:letter=>"L", :row=>2, :column=>0, :covered_by=>1, :defended=>false},
      {:letter=>"O", :row=>2, :column=>1, :covered_by=>nil, :defended=>false},
      {:letter=>"L", :row=>2, :column=>2, :covered_by=>nil, :defended=>false},
      {:letter=>"Z", :row=>2, :column=>3, :covered_by=>nil, :defended=>false},
      {:letter=>"Z", :row=>2, :column=>4, :covered_by=>nil, :defended=>false}],
     [{:letter=>"T", :row=>3, :column=>0, :covered_by=>nil, :defended=>false},
      {:letter=>"B", :row=>3, :column=>1, :covered_by=>nil, :defended=>false},
      {:letter=>"W", :row=>3, :column=>2, :covered_by=>nil, :defended=>false},
      {:letter=>"M", :row=>3, :column=>3, :covered_by=>nil, :defended=>false},
      {:letter=>"F", :row=>3, :column=>4, :covered_by=>nil, :defended=>false}],
     [{:letter=>"B", :row=>4, :column=>0, :covered_by=>nil, :defended=>false},
      {:letter=>"O", :row=>4, :column=>1, :covered_by=>nil, :defended=>false},
      {:letter=>"F", :row=>4, :column=>2, :covered_by=>nil, :defended=>false},
      {:letter=>"M", :row=>4, :column=>3, :covered_by=>nil, :defended=>false},
      {:letter=>"V", :row=>4, :column=>4, :covered_by=>nil, :defended=>false}]] 

>   # Takes about 8 seconds on a laptop -- brute force solution
>   game.potential_plays
=>  ["WORD","MATCHES","FROM","DICTIONARY","IN","AN","ARRAY"]

>   next_play = game.best_next_play

>   game.play(*next_play[:coordinates])
=>  true

>   game.moves.last.to_hash
=>  { :player=>1,
      :word=>"SPLENT",
      :valid=>true,
      :coordinates=>[[0, 1], [1, 1], [2, 0], [1, 3], [0, 0], [1, 0]],
      :invalid_reason=>nil,
      :player_sequence=>1,
      :total_sequence=>1,
      :score => {
        :defended_before=>0,
        :covered_before=>0,
        :defended_after=>2,
        :covered_after=>6,
        :defended=>2,
        :covered=>6}
      }

>   game.scores
=>  {1=>2, 2=>0}

#   pass by playing a nil move
>   game.play
=>  true

>   game.play
=>  true

>   game.over?
=>  true

>   game.winner
=>  1

Dictionary

The default dictionary is based on the the Internet Scrabble Club's TWL06 dictionary. Any dictionary can be used by replacing the contents of the words.txt file in the /lib/linotype/dictionary directory.

Feature Ideas

  • Game board loading from iOS screen shot
  • Word suggestions (faster)
  • One player command line game
  • Vowel/consonant ratio setting for random boards
  • Built in dictionaries for different languages or topics

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
  6. Thanks <3

More Repositories

1

json-api-example

JSON API example presented at Boston Ember on July 9, 2015.
Ruby
24
star
2

charity_auction-server

A Ruby on Rails JSON API compliant server to host charity auctions.
Ruby
23
star
3

gendered

Guess the gender of names with the help of the genderize.io.
Ruby
21
star
4

apexcalendar

A set of classes and component to easily add calendar pageblocks (with data) to any visualforce page.
12
star
5

blekko-search

Search and manage slashtags for blekko.com
Ruby
10
star
6

charity_auction-web

Example Ember application for charity auction management.
JavaScript
10
star
7

scoreboard

A toy scoreboard app inspired by the one that I remember from high school
JavaScript
8
star
8

apexamazonemail

An sObject and classes to use Amazon Web Services' Simple Email Service in Force.com
OpenEdge ABL
6
star
9

layout_by_action

layout_by_action method for Rails controllers
Ruby
6
star
10

little-professor

Little Professor backward calculator replica created in Ember
JavaScript
6
star
11

rspec-context-private

RSpec shared context to make private methods temporarily public.
Ruby
5
star
12

apexgooglestaticmap

Interface with the Google Static Maps API v2 in Force.com apps.
5
star
13

manifesto

JavaScript
4
star
14

daringfiresearch

A rails search engine app for every source ever used by Daring Fireball.
Ruby
3
star
15

reading_tutor

Help kids learn to read.
Ruby
2
star
16

five_question_interview

Solution to "five programming problems every software engineer should be able to solve in less than 1 hour"
Ruby
2
star
17

time_clock

Calculate the amount of business time between two times based on any arbitrary work calendar.
Ruby
2
star
18

ruler

Converts a float into a formatted string with approximate ruler measurements.
Ruby
1
star
19

identical_sort_by

Demonstrates 2.3.0 sort_by bug
Ruby
1
star
20

keep-beats-1-playing

Opens iTunes and plays Beats 1 radio if iTunes is not currently playing.
AppleScript
1
star
21

elasticsearch_distance_unit_validator

Validator for Elasticsearch distance units.
Ruby
1
star