yahiaetman / scrabble-server Goto Github PK
View Code? Open in Web Editor NEWScrabble Server is a 2-Player Websockets Scrabble Judging Server.
License: MIT License
Scrabble Server is a 2-Player Websockets Scrabble Judging Server.
License: MIT License
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:
const scores = {10: 1, 20: 2, 5: 3, 100: 0};
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]];
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}}]];
const score = ScrabbleUtils.calculateScore(words, design, scores);
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
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.