From: Bill Kelly Date: 2010-02-16T15:03:56+09:00 Subject: Re: Ruby "Save Game" function Michael Brodeur wrote: > > I am currently working on a text-based RPG and I wanted to implement a > function that allowed the user to save their game at any point, so that > it could be resumed later. Of course, this would need to be complimented > by a load function that would resume the game at that previous state. For starters, I'd suggest looking at PStore and YAML::Store. PStore: http://ruby-doc.org/stdlib/libdoc/pstore/rdoc/classes/PStore.html YAML::Store exmaple: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/113207 PStore and YAML::Store are essentially equivalent in functionality, the difference is PStore saves objects in Ruby's binary marshal format, whereas YAML::Store saves objects in human-readable YAML text format. And the trade-off is that YAML is slower than marshal. Further possibilities for key/value stores with Ruby: http://www.engineyard.com/blog/2009/key-value-stores-in-ruby/ http://www.engineyard.com/blog/2009/key-value-stores-for-ruby-part-2-tokyo-cabinet/ http://www.engineyard.com/blog/2009/cassandra-and-ruby-a-love-affair/ http://www.engineyard.com/blog/2009/key-value-stores-for-ruby-part-4-to-redis-or-not-to-redis/ http://www.engineyard.com/blog/2009/mongodb-a-light-in-the-darkness-key-value-stores-part-5/ http://www.engineyard.com/blog/2009/key-value-stores-in-ruby-the-wrap-up/ Hope this helps, Bill