Test fill in for day21
This commit is contained in:
parent
992492f14d
commit
dd28f1a81a
2 changed files with 35 additions and 8 deletions
BIN
day21/day21Part1
Executable file
BIN
day21/day21Part1
Executable file
Binary file not shown.
|
@ -1,4 +1,5 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -8,28 +9,54 @@ int main (void)
|
||||||
int player1Score = 0;
|
int player1Score = 0;
|
||||||
int player2Position = 8; //This is 5 for true, 8 for test
|
int player2Position = 8; //This is 5 for true, 8 for test
|
||||||
int player2Score = 0;
|
int player2Score = 0;
|
||||||
int dieRoll = 0;
|
int dieRoll = 1;
|
||||||
int dieRollover = 0;
|
|
||||||
int turnAdd = 0;
|
int turnAdd = 0;
|
||||||
|
int rollCount = 0;
|
||||||
bool player1Add = true;
|
bool player1Add = true;
|
||||||
|
|
||||||
//
|
//Run the game loop until someone has the highest score
|
||||||
while (player1Position >= 1000 || player2Position >= 1000)
|
while (player1Position < 1000 || player2Position < 1000)
|
||||||
{
|
{
|
||||||
if ((dieRoll % 3) == 0)
|
//If there's three values in the roll
|
||||||
|
if ((rollCount % 3) == 0)
|
||||||
{
|
{
|
||||||
|
//If its player 1s turn, add their score
|
||||||
if (player1Add)
|
if (player1Add)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
player1Position = player1Position + turnAdd;
|
player1Position = player1Position + turnAdd;
|
||||||
|
player1Position = ((player1Position - 1) % 10) + 1;
|
||||||
player1Score += player1Position;
|
player1Score += player1Position;
|
||||||
}
|
}
|
||||||
|
//It its player 2s turn, add their score
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
player2Position = player2Position + turnAdd;
|
||||||
|
player2Position = ((player2Position - 1) % 10) + 1;
|
||||||
|
player2Score += player2Position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Add until 3 values have been rolled
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rollCount++;
|
||||||
|
//Implement rollover
|
||||||
|
if(dieRoll > 100) dieRoll = 1;
|
||||||
|
turnAdd += dieRoll;
|
||||||
|
dieRoll++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if(player1Add)
|
||||||
// TODO : Multiply loserScore by (100 * dieRollover) + dieRoll
|
{
|
||||||
|
bool test;
|
||||||
|
test = (player1Position >= 1000 || player2Position >= 1000);
|
||||||
|
cout << player1Position << endl;
|
||||||
|
cout << player2Position << endl;
|
||||||
|
cout << test << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cout << "Player 2 Wins" << endl;
|
||||||
|
}
|
||||||
|
// TODO : Multiply loserScore by rollCount
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue