GithubHelp home page GithubHelp logo

connect-4's Introduction

The Challenge

We have created a very simple Connect 4 game using some of our favorite front-end technologies. The rules of the game are simple: the first player to connect 4 of the same colored discs in a row (either vertically, horizontally, or diagonally) wins. There is one issue that we'd like you to solve: the logic to determine a winner does not check for 4 in a row diagonally, you should implement this logic with tests. We've also come up with a list of possible improvements. Feel free to implement as many or as few of these as you like or try something not on this list (you have complete creative freedom). We understand that your time is precious so try not to spend more than a couple of hours on this.

Getting Started

npm i - install dependences

npm start - run the application

npm t - run the tests

Possible Improvements

Technology Choices

Changelog

  • Added two unit tests one to test diagonal upwards to the right and other diagonal downwards to the right (Followed TDD principals)
  • Added diagonal win feature (tried to use the same methodology of horizontal win to show my adaptability) in usePlayPiece.ts
  • Added state atoms for player scores and player names & colours
  • Changed const file to have variables with default player names and colours
  • Added two components Scores.tsx and Settings.tsx using Chakra-ui
  • Scores shows user scores on the app and settings allows you to configure player name's and colours
  • Used recoil to state manage properties so no need to rerender the page
  • Managed to have board persistance and active player persistance along with scores using AtomEffects from recoil

Comments

  • This was my first time understanding Typescript syntax so it took me a while to comprehend the codebase and everything going on.
  • First time using Chakra-ui and Recoil too as state management.
  • Chakra-ui was really easy to use and complements React really well.
  • Recoil was interesting to use, it took me a bit to read docs and understand what was going on but once I did utilising it was really simple.
  • I noticed that my tests fail when adding the AtomEffect to the board state, from debuggin I think its to do with setting the new value in the localstorage as a string that is messing it up, in './state/game.ts' commenting out line 85 allows all tests to pass but obviously removes board state persistance between sessions.

connect-4's People

Contributors

sidaroz 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.