Code Monkey home page Code Monkey logo

card-game-exercise's Introduction

card-game-exercise

Simple card game exercise demo application.

Installation

Clone the repository

git clone [email protected]:elcobvg/card-game-exercise.git

Switch to the repo folder

cd card-game-exercise

Run the game

node app.js

Note on modelling vs. performance

For this exercise I've chosen to model the application so that it closely resembles its real-world counterpart. This has the benefit that the code is easy to read and understand. However, it doesn't necessarily give the optimal result in terms of performance. In this scenario that isn't relevant, but in a 'real' application, this may become an issue. For example, if instead of a single deck of cards we have a very large array of data objects, to be distributed over a large number of container objects instead of a handful of players, it will be necessary to optimise for performance. Even if that will make the code harder to follow.

For example, shuffling such a very large array may become too expensive, so it may be better to retrieve an item by removing it at a random index. Or instead of using iteration to find a match, it might be better to build an indexed dictionary first, for direct lookups. If I find the time, I'll try to add a version that implements some optimisations along these lines.

Game tactics

This is a simple, naive implementation of the game, i.e. in each turn the first encountered matching card is played. Of course, it may be smarter to keep track of which cards have already been played and - in case a player has more than one match to choose from - play the card that minimises the opponents chances. Again, if I find the time I'll try to add a version implementing some simple tactical heuristics.

card-game-exercise's People

Contributors

elcobvg avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.