Giter VIP home page Giter VIP logo

bulls_and_cows's Introduction

This repo builds a game of Bulls and Cows, which is a math based game similar to Mastermind.

The game works as follows:

A player competes against the computer, which generates a random 4 digit number of unique values.

If the player guesses any one of those numbers, then they receive a 'cow'. For example, if the computer's number is '1234', and the player guessed '3421', then they receive 4 cows.

The player receives a bull if the numbers are in the same position as the computer's. For example, if the computer's number is '1234' and the player guesses '1243', then they will receive 2 bulls and 4 cows, as they guessed all 4 numbers correctly, but only 2 in the right place. The game ends when the player scores 4 bulls

The game is built in Ruby, tested with Rspec, and deployed with Rails.

Why Rails

I decided to use Rails for this because it was much easier setting up a database and user authentication with the Devise gem. I wanted to have a leadership board, where users high scores are saved into the database for other users to compete against, and the most efficient way to achieve this was through using Rails, PostgreSQL, ActiveRecord and Devise.

What Needs Improving

The front end design is not yet complete. In fact it's rather disgusting. Most of my efforts go into back-end functionality as that's what I enjoy most, so I didn't want to get caught up in the front end too much. It's still a work in progress, however, and I'll improve the layout and design over time.

Setting up

git clone https://github.com/Adrian1707/bulls_and_cows
cd bulls_and_cows
bundle install
rails s
visit localhost:3000
Get Playing!

Tests Tests Tests

Set up first (see above)
rspec

bulls_and_cows's People

Contributors

adrian1707 avatar yorkshireman avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

yorkshireman

bulls_and_cows's Issues

StaticPagesController too fat

I think alot of stuff i.e. the save_number method and the private methods, needs to be refactored out. Requires some careful thought, I think, but shouldn't be a big drama.

I think save_number should maybe be renamed to something, too.

No test coverage for the session

There are no tests that check the state of the session across requests. For example, there is no test that checks if the comp_choice has numbers when a game is started and there is no test to check that those numbers remain the same across requests.

I suspect this could be done with dedicated controller tests.

It might fall under the bracket of 'Integration Test', but my knowledge of what exactly that means is a bit shaky, but one could be forgiven because I think a lot of developers get the meaning wrong and it is often a bit of a grey area. But my gut instinct is that this is prime integration test material :-)

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.