Quaternity
Functions
main.cpp File Reference
#include <algorithm>
#include <iostream>
#include <string>
#include "debug.h"
#include "input.h"
#include "opts.h"
#include "settings.h"
#include "state.h"
#include "update.h"
#include "validate.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 13 of file main.cpp.

14 {
15  Settings settings = options(argc, (const char**)argv);
16  State state = init_state(settings);
17 
18  std::cout << settings;
19  std::cout << state;
20 
21  while (std::find(state.quartets.begin(), state.quartets.end(), -1) != state.quartets.end()) {
22  bool *valid_answers;
23 
24  // QUESTION
25  Question question;
26  do {
27  question = ask_question();
28  std::cout << question;
29  valid_answers = valid_question(settings, state, question);
30  } while (valid_answers == NULL);
31 
32  // ANSWER
33  Answer answer;
34  do {
35  answer = ask_answer();
36  std::cout << "Answer: " << answer << "." << std::endl;
37  } while (!valid_answers[answer]);
38 
39  // UPDATE STATE
40  update_state(settings, state, question, answer);
41  std::cout << state;
42  }
43 
44  return 0;
45 }
Answer ask_answer()
Ask the user to provide an answer.
Definition: input.cpp:37
Question ask_question()
Ask the user to provide a question.
Definition: input.cpp:25
Settings options(const int argc, const char **argv)
Parse the command line arguments and generate the settings from these.
Definition: opts.cpp:85
bool Answer
An answer returned by a player. The answer is either true or false denoting he/she has or does not ha...
Definition: round.h:39
State init_state(const Settings &settings)
Initialize the starting state corresponding to the given settings.
Definition: state.cpp:58
A question asked by a player. The player asks another player for a specific card from a certain set.
Definition: round.h:17
The settings which characterize a game.
Definition: settings.h:22
The complete game state.
Definition: state.h:57
std::vector< int > quartets
The information of who has a certain quartet.
Definition: state.h:90
void update_state(const Settings &settings, State &state, const Question &question, const Answer &answer)
Update the state of the game according to the question asked and the answer which is given.
Definition: update.cpp:155
bool * valid_question(const Settings &settings, const State &state, const Question &question)
Check if the question asked is valid.
Definition: validate.cpp:89