Skip to content

A terminal game based on the coins in a line problem, featuring nice graphics and a cute bunny character

License

Notifications You must be signed in to change notification settings

SamHamamji/cards-in-a-line

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cards in a line

This game is a card variant of the coins in a line problem (also known as the pots of gold problem), implemented in Typescript.

Demo

Setup

npm install

Usage

npm start

Game modes

  • Single Player
  • MultiPlayer
  • Custom (any number of bots or players)
  • Tutorial

Strategies

Strategy Description Parameter(s)
AlwaysFirst Always chooses the first card -
AlwaysLast Always chooses the last card -
ChooseMaximum Compares the values of the two cards and chooses the card having highest value
  • breakTie: TieBreaker
  • Is set to choose randomly by default
  • Clone
  • Chooses from the same side as the previous player
  • If it is the first move (no player has played previously), then it chooses randomly
  • -
    Minimax
  • Visualizes all the possible scenarios and finds the most optimal one assuming that the opponent(s) also play optimally, read this for more
  • Uses dynamnic programming, reducing its complexity from O(2^n) to O(n^2), n being the number of cards
  • breakTie: TieBreaker
  • Is set to choose the card with the highest value by default
  • Random Randomly chooses one of the two options
  • firstProbability: number
  • Represents the probability of choosing the first card
  • Is set to 0.5 by default
  • UserInput Prompts the user to input their choice -

    To add a custom strategy

    1. Create a file in ./src/Strategies
    2. Write a class implementing the Strategy interface found here
    3. Add the class to the Strategies object in ./src/Strategies/index.ts

    Platforms

    Tested on Windows 10 and Linux.

    License

    Licensed under the GNU General Public License v3.0 license.

    About

    A terminal game based on the coins in a line problem, featuring nice graphics and a cute bunny character

    Topics

    Resources

    License

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published