Giter VIP home page Giter VIP logo

scrabble-server's People

Contributors

yahiaetman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

scrabble-server's Issues

Premium squares from previous turns affect newly-created-words scores

Describe the bug
The scrabble-utils class uses premium squares from tiles placed in previous turns while calculating the score for a new moves.

To Reproduce
Steps to reproduce the behavior:

  1. const scores = {10: 1, 20: 2, 5: 3, 100: 0};
  2. const design = [[2, 0, 0, 0, 2], [0, 1, 0, 1, 0], [4, 0, 3, 0, 4], [0, 1, 0, 1, 0], [2, 0, 0, 0, 2]];
  3. const words = [[{tile: 10, src: 'rack', position: {col: 1, row: 1}}, {tile: 20, src: 'rack', position: {col: 2, row: 1}}, {tile: 5, src: 'board', position: {col: 3, row: 1}}]];
  4. const score = ScrabbleUtils.calculateScore(words, design, scores);
  5. score will be equal 10.

Expected behavior
score should be equal 7.

Explanation
The score should be calculated as: scores[10]*2 + scores[20] + scores[5] = 1*2 + 2 + 3 = 7.
However, since the the tile 5 lies on a double-letter square, the server calculated the score as: scores[10]*2 + scores[20] + scores[5]*2 = 1*2 + 2 + 3*2 = 10.
But according to the rules:

Letter and word premiums count only on the turn in which they are played. On later turns, letters already played on premium squares count at face value.

So the double letter beneath tile 5 should be ignored since the tile was already on the board when the word was played. So the correct sore is 7.

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.