Meeting the Brief Investigation and Plan Design Implementation Testing Evaluation References Word Count

Testing

Examination number: 142150

Test Case Test Case Description Expected Result Actual Result Pass/Fail
1 Test if the game loads with 30 cards in total and each player has 15 cards. The game should load with a total of 30 cards, with each player starting with 15 cards. 30 cards are loaded and each player has 15 cards. Pass
2 Test if the player loses a turn, they lose a card and the other player gains it. When a player loses a turn, they should lose a card and the other player should gain it. Player 1 loses a turn and a card, while Player 2 gains the card. Pass
3 Test if the game displays a message when a player has 0 cards left. When a player has 0 cards left, the game should display a message indicating that they have lost/won. Player 1 has 0 cards left and a message is displayed indicating they have lost/won Pass
4 Test if the game modes buttons work. The game modes buttons should switch between single player, multiplayer, and simulation play modes. Clicking on each button switches the game mode accordingly. Pass
5 Test if the game modes buttons disable during game. The game modes buttons should disable when a game is being played to avoid confusion. The buttons except reset are disabled. Pass
6 Test if the stat buttons are showing and hiding. The stat buttons should be hidden unless if it is the player's turn. Stat buttons are hidden unless and visible during the player's turn. Pass
7 Test if the game ends when one player has all the cards. When one player has all the cards, the game should end and a message should be displayed indicating the winner. Player 1 has all the cards and a message is displayed indicating they have won. Pass
8 Test if the game allows for tie-breakers. If a round ends in a tie, a tie-breaker should be played to determine the winner. A round ends in a tie and a tie-breaker round is played. Fail
9 Test if the game uses the correct card stats. When a player selects a card, the game should use the card's stats. Player 1 selects a card and the game uses the correct card's stats Pass
10 Test if the game allows for players to select a stat. When a player selects a stat, the game should compare the selected stat of each player's card, and the player with the highest stat wins the round. Player 1 selects a stat and their card has a higher value than Player 2's card, so they win the round. Pass
11 Test if the game allows for players to select a stat. When a player selects a stat, the game should compare the selected stat of each player's card, and the player with the highest stat wins the round. Player 1 selects a stat and their card has a higher value than Player 2's card, so they win the round. Pass
12 Test if the data about the game is being stored in the window local storage. All the data recorded during the game should be stored. Data is stored. Pass
13 Test if the analysis appears after each game. In addition the pie chart should be reset after each game. The game analysis should appear after each game and the chart should have been cleaned from the previous game data. The analysis appears and the chart is cleaned from the previous game data. Pass
bug

Finding bugs

During the testing of the game, I found the following bugs:
  • If the game mode is swapped from simulation to another very quickly, a stat button will be clicked by the computer even though it is not its turn. This is due to a timeout set in the code.
  • During the computer's turn player 1 is able to click on one of the computer's stat buttons disturbing its input.

Hypothesis - What if...

• At the moment when the game is in simulation mode the computer randomly chooses a stat to compare. But what if one of the simulated players was able to detect some specific type of airplanes and choose a stat accordingly? Would that make it win more often?
• In order to test that, I am going to modify my code to make the player 1 (in simulation mode) able to detect if its card is a big airplane (Airbus or Boeing). If that's the case, it will choose the stat "payload" to compare, which will increase the chances to win the turn.
• By checking if player 1 won the last three games using this strategy I will discover if this is making player 1 more likely to win.
Hypothesis: Player 1 wins more games if it is able to detect a bigger airplane and choose a specific stat.

Original code:

        if (currentState == State.Simulation && currentPlayer === 1) {
            const button = pickRandom(p1buttons);
            setTimeout(() => {
                button.style.background = "green";
            }, responseTime / 2);
            setTimeout(() => {
                button.click();
                button.style.background = "";
            }, responseTime);
        }
      
Modified code:

        if (currentState == State.Simulation && currentPlayer === 1) {
            const Tcard = p1Card.name.split(" ").shift();
            console.log(Tcard);
            let button;
            if (Tcard == "Airbus" || Tcard == "Boeing") {
                button = p1buttons[5];
                console.log(button);
            } else {
                button = pickRandom(p1buttons);
            }
    
            setTimeout(() => {
                button.style.background = "green";
            }, responseTime / 2);
            setTimeout(() => {
                button.click();
                button.style.background = "";
            }, responseTime);
        }
      
Note: the modified code will be commented in the Javascript file, if willing to test, comment the original and uncomment the modified. Code fragment inside stateMachine function.

Results:
Data of six games with original code:
Who won? Game duration (in seconds)
Player 2 25.41
Player 1 28.90
Player 2 22.79
Player 2 26.17
Player 1 23.12
Player 1 26.89

Data of six games with modified code:
Who won? Game duration (in seconds)
Player 1 28.17
Player 1 26.44
Player 1 28.88
Player 1 24.57
Player 2 35.65
Player 1 28.17
From the results above, we can clearly appreciate that Player 1 won more times with the modified code. This demonstrates that the my hypothesis is valid. Player 1 does win more games when it detects bigger airplanes and chooses payload to compare.