Code Monkey home page Code Monkey logo

ruby-mmo's Introduction

Ruby MMO

Ruby MMO is a programming challenge in which players compete to gain the highest level in an MMO simulation.

How to play

Fork this repo and commit a module inside the /players directory. The module is then used to extend a player object with a couple of methods:

  1. The move method returns an array with two elements: the method to be called (can be one of :attack or :rest), and the method arguments. In the case of :attack the argument should be an instance of an opponent Player (see below for how to get this). In the case of :rest no argument is required. See the examples in the /players directory.

  2. to_s (optional) returns the name of the player.

Exploring

The player modules have access to the Game.world hash. This hash contains all the players and monsters in the world and their current stats. For example, to get the stats of a random player you could do:

player_count = Game.world[:players].count
opponent = Game.world[:players].select{|p|p != self}[rand(player_count - 1)]
opponent.stats

The select is to ensure the player is not fighting itself.

There is also a method alive that returns false if the player is dead.

Running the simulation

./engine.rb -r 100 where -r sets the number of rounds (default is 10).

Winning

The player with the highest level and experience wins.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.