From 96f01627edcc112696e919843a3fbcfce1ce56b2 Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Tue, 11 Jul 2023 08:31:34 +0200 Subject: [PATCH 01/17] Convert Python example to use version 3 It is mostly adding braces for print(). --- python/trivia.py | 50 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/python/trivia.py b/python/trivia.py index 676a6f2c97..7799c643d7 100755 --- a/python/trivia.py +++ b/python/trivia.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 class Game: def __init__(self): @@ -33,8 +33,8 @@ def add(self, player_name): self.purses[self.how_many_players] = 0 self.in_penalty_box[self.how_many_players] = False - print player_name + " was added" - print "They are player number %s" % len(self.players) + print (player_name + " was added") + print ("They are player number %s" % len(self.players)) return True @@ -43,42 +43,42 @@ def how_many_players(self): return len(self.players) def roll(self, roll): - print "%s is the current player" % self.players[self.current_player] - print "They have rolled a %s" % roll + print ("%s is the current player" % self.players[self.current_player]) + print ("They have rolled a %s" % roll) if self.in_penalty_box[self.current_player]: if roll % 2 != 0: self.is_getting_out_of_penalty_box = True - print "%s is getting out of the penalty box" % self.players[self.current_player] + print ("%s is getting out of the penalty box" % self.players[self.current_player]) self.places[self.current_player] = self.places[self.current_player] + roll if self.places[self.current_player] > 11: self.places[self.current_player] = self.places[self.current_player] - 12 - print self.players[self.current_player] + \ + print (self.players[self.current_player] + \ '\'s new location is ' + \ - str(self.places[self.current_player]) - print "The category is %s" % self._current_category + str(self.places[self.current_player])) + print ("The category is %s" % self._current_category) self._ask_question() else: - print "%s is not getting out of the penalty box" % self.players[self.current_player] + print ("%s is not getting out of the penalty box" % self.players[self.current_player]) self.is_getting_out_of_penalty_box = False else: self.places[self.current_player] = self.places[self.current_player] + roll if self.places[self.current_player] > 11: self.places[self.current_player] = self.places[self.current_player] - 12 - print self.players[self.current_player] + \ + print (self.players[self.current_player] + \ '\'s new location is ' + \ - str(self.places[self.current_player]) - print "The category is %s" % self._current_category + str(self.places[self.current_player])) + print ("The category is %s" % self._current_category) self._ask_question() def _ask_question(self): - if self._current_category == 'Pop': print self.pop_questions.pop(0) - if self._current_category == 'Science': print self.science_questions.pop(0) - if self._current_category == 'Sports': print self.sports_questions.pop(0) - if self._current_category == 'Rock': print self.rock_questions.pop(0) + if self._current_category == 'Pop': print (self.pop_questions.pop(0)) + if self._current_category == 'Science': print (self.science_questions.pop(0)) + if self._current_category == 'Sports': print (self.sports_questions.pop(0)) + if self._current_category == 'Rock': print (self.rock_questions.pop(0)) @property def _current_category(self): @@ -96,12 +96,12 @@ def _current_category(self): def was_correctly_answered(self): if self.in_penalty_box[self.current_player]: if self.is_getting_out_of_penalty_box: - print 'Answer was correct!!!!' + print ('Answer was correct!!!!') self.purses[self.current_player] += 1 - print self.players[self.current_player] + \ + print (self.players[self.current_player] + \ ' now has ' + \ str(self.purses[self.current_player]) + \ - ' Gold Coins.' + ' Gold Coins.') winner = self._did_player_win() self.current_player += 1 @@ -117,12 +117,12 @@ def was_correctly_answered(self): else: - print "Answer was corrent!!!!" + print ("Answer was corrent!!!!") self.purses[self.current_player] += 1 - print self.players[self.current_player] + \ + print (self.players[self.current_player] + \ ' now has ' + \ str(self.purses[self.current_player]) + \ - ' Gold Coins.' + ' Gold Coins.') winner = self._did_player_win() self.current_player += 1 @@ -131,8 +131,8 @@ def was_correctly_answered(self): return winner def wrong_answer(self): - print 'Question was incorrectly answered' - print self.players[self.current_player] + " was sent to the penalty box" + print ('Question was incorrectly answered') + print (self.players[self.current_player] + " was sent to the penalty box") self.in_penalty_box[self.current_player] = True self.current_player += 1 From 06243e248fd9c1f3c1625f4dc0ff422a3e6fde3e Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Tue, 11 Jul 2023 09:41:19 +0200 Subject: [PATCH 02/17] Add CMake project configuration for C++ --- C++/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 C++/CMakeLists.txt diff --git a/C++/CMakeLists.txt b/C++/CMakeLists.txt new file mode 100644 index 0000000000..8acf50d252 --- /dev/null +++ b/C++/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.5.0) +project(Trivia VERSION 0.1.0 LANGUAGES C CXX) + +include(CTest) +enable_testing() + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_CXX_STANDARD 14) + +add_compile_options(-g -Wall -Wextra -Werror) + +add_executable(Trivia Game.cpp GameRunner.cpp) + +set(CPACK_PROJECT_NAME ${PROJECT_NAME}) +set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) +include(CPack) From a8c97f14436d068389a7384a11fc3e1c2f273168 Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Tue, 11 Jul 2023 09:41:51 +0200 Subject: [PATCH 03/17] Ignore CMake build directory --- C++/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/C++/.gitignore b/C++/.gitignore index 79b3c8c10f..8f446da067 100644 --- a/C++/.gitignore +++ b/C++/.gitignore @@ -1,3 +1,4 @@ Debug .project .cproject +build \ No newline at end of file From e451f92fb0f755eaed7d3482afa6062618bc75ed Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Tue, 11 Jul 2023 10:02:41 +0200 Subject: [PATCH 04/17] Fix compilation with modern compilers - Order members in constructor initialization. - Use accepted syntax for array initialization. - Narrow-cast size_t to int to make the comparisons work (not a proper fix, I know). --- C++/Game.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/C++/Game.cpp b/C++/Game.cpp index 58f200d604..460859e484 100644 --- a/C++/Game.cpp +++ b/C++/Game.cpp @@ -6,7 +6,7 @@ using namespace std; -Game::Game() : currentPlayer(0), places({}), purses({}){ +Game::Game() : places{}, purses{}, currentPlayer(0) { for (int i = 0; i < 50; i++) { @@ -148,14 +148,14 @@ bool Game::wasCorrectlyAnswered() bool winner = didPlayerWin(); currentPlayer++; - if (currentPlayer == players.size()) currentPlayer = 0; + if (currentPlayer == (int)players.size()) currentPlayer = 0; return winner; } else { currentPlayer++; - if (currentPlayer == players.size()) currentPlayer = 0; + if (currentPlayer == (int)players.size()) currentPlayer = 0; return true; } @@ -174,7 +174,7 @@ bool Game::wasCorrectlyAnswered() bool winner = didPlayerWin(); currentPlayer++; - if (currentPlayer == players.size()) currentPlayer = 0; + if (currentPlayer == (int)players.size()) currentPlayer = 0; return winner; } @@ -187,7 +187,7 @@ bool Game::wrongAnswer() inPenaltyBox[currentPlayer] = true; currentPlayer++; - if (currentPlayer == players.size()) currentPlayer = 0; + if (currentPlayer == (int)players.size()) currentPlayer = 0; return true; } From 40e86179bff80d2823bc9b995a255acd7216fe6d Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Wed, 12 Jul 2023 14:43:55 +0200 Subject: [PATCH 05/17] Add CMake list for pure C project --- C/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 C/CMakeLists.txt diff --git a/C/CMakeLists.txt b/C/CMakeLists.txt new file mode 100644 index 0000000000..25479aaa66 --- /dev/null +++ b/C/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.11.0) +project(Trivia VERSION 0.1.0 LANGUAGES C) + +include(CTest) +enable_testing() + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_C_STANDARD 17) + +add_compile_options(-g -Wall -Wextra -Werror) + +add_executable(trivia game.c game_runner.c) + +set(CPACK_PROJECT_NAME ${PROJECT_NAME}) +set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) +include(CPack) From a301c9045b48a99debae431e86f0db7d95694ebd Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Wed, 12 Jul 2023 14:44:35 +0200 Subject: [PATCH 06/17] Add .gitignore --- C/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 C/.gitignore diff --git a/C/.gitignore b/C/.gitignore new file mode 100644 index 0000000000..c795b054e5 --- /dev/null +++ b/C/.gitignore @@ -0,0 +1 @@ +build \ No newline at end of file From 219a39116f3434c37f8806b8eabc28345086e1f7 Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Wed, 12 Jul 2023 14:44:50 +0200 Subject: [PATCH 07/17] Add .gitignore (with EOF) --- C/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C/.gitignore b/C/.gitignore index c795b054e5..378eac25d3 100644 --- a/C/.gitignore +++ b/C/.gitignore @@ -1 +1 @@ -build \ No newline at end of file +build From fc3c81330aba4770396c8b0468ebd2ffbf15a8aa Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Wed, 12 Jul 2023 14:50:11 +0200 Subject: [PATCH 08/17] Make code build with MSVC On Windows strdup() is deprecated because it is not part of C standard but a part of POSIX. [1] Describes how to suppress such nonsense. 1. https://stackoverflow.com/questions/7582394/strdup-or-strdup --- C/game.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/C/game.c b/C/game.c index 10e27df1dd..31bfcb6f4a 100644 --- a/C/game.c +++ b/C/game.c @@ -1,5 +1,7 @@ #include "game.h" +#define _CRT_NONSTDC_NO_DEPRECATE // allow strdup() to be used on Windows + #include #include #include From cfb13d6b35d765a2a4db683969c13839e4a61ea2 Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Tue, 30 Jan 2024 07:58:07 +0100 Subject: [PATCH 09/17] Add text-based characterization test for Python --- python/texttest_fixture.py | 8 +++ texttests/.gitignore | 1 + texttests/config.gr | 14 +++++ texttests/default/stderr.gr | 0 texttests/default/stdout.gr | 107 ++++++++++++++++++++++++++++++++++++ texttests/testsuite.gr | 1 + 6 files changed, 131 insertions(+) create mode 100644 python/texttest_fixture.py create mode 100644 texttests/.gitignore create mode 100644 texttests/config.gr create mode 100644 texttests/default/stderr.gr create mode 100644 texttests/default/stdout.gr create mode 100644 texttests/testsuite.gr diff --git a/python/texttest_fixture.py b/python/texttest_fixture.py new file mode 100644 index 0000000000..755a593934 --- /dev/null +++ b/python/texttest_fixture.py @@ -0,0 +1,8 @@ +from trivia import main + +# Make sure all runs use the same random sequence +from random import seed +seed(1) + +if __name__ == "__main__": + main() diff --git a/texttests/.gitignore b/texttests/.gitignore new file mode 100644 index 0000000000..5ceb3864c2 --- /dev/null +++ b/texttests/.gitignore @@ -0,0 +1 @@ +venv diff --git a/texttests/config.gr b/texttests/config.gr new file mode 100644 index 0000000000..9f3da99702 --- /dev/null +++ b/texttests/config.gr @@ -0,0 +1,14 @@ +full_name:Trivia Kata + +# set your preferred editor and diff tool. +view_program:subl +diff_program:diff + +# Settings for the Python version +executable:${TEXTTEST_HOME}/python/texttest_fixture.py +interpreter:python3 + +# Settings for the C++ version +#executable:${TEXTTEST_HOME}/C++/build/Trivia + +filename_convention_scheme:standard diff --git a/texttests/default/stderr.gr b/texttests/default/stderr.gr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/texttests/default/stdout.gr b/texttests/default/stdout.gr new file mode 100644 index 0000000000..bc4c4b62a5 --- /dev/null +++ b/texttests/default/stdout.gr @@ -0,0 +1,107 @@ +Chet was added +They are player number 1 +Pat was added +They are player number 2 +Sue was added +They are player number 3 +Chet is the current player +They have rolled a 2 +Chet's new location is 2 +The category is Sports +Sports Question 0 +Answer was corrent!!!! +Chet now has 1 Gold Coins. +Pat is the current player +They have rolled a 3 +Pat's new location is 3 +The category is Rock +Rock Question 0 +Answer was corrent!!!! +Pat now has 1 Gold Coins. +Sue is the current player +They have rolled a 4 +Sue's new location is 4 +The category is Pop +Pop Question 0 +Question was incorrectly answered +Sue was sent to the penalty box +Chet is the current player +They have rolled a 4 +Chet's new location is 6 +The category is Sports +Sports Question 1 +Answer was corrent!!!! +Chet now has 2 Gold Coins. +Pat is the current player +They have rolled a 2 +Pat's new location is 5 +The category is Science +Science Question 0 +Answer was corrent!!!! +Pat now has 2 Gold Coins. +Sue is the current player +They have rolled a 4 +Sue is not getting out of the penalty box +Chet is the current player +They have rolled a 4 +Chet's new location is 10 +The category is Sports +Sports Question 2 +Answer was corrent!!!! +Chet now has 3 Gold Coins. +Pat is the current player +They have rolled a 5 +Pat's new location is 10 +The category is Sports +Sports Question 3 +Answer was corrent!!!! +Pat now has 3 Gold Coins. +Sue is the current player +They have rolled a 4 +Sue is not getting out of the penalty box +Chet is the current player +They have rolled a 2 +Chet's new location is 0 +The category is Pop +Pop Question 1 +Answer was corrent!!!! +Chet now has 4 Gold Coins. +Pat is the current player +They have rolled a 3 +Pat's new location is 1 +The category is Science +Science Question 1 +Answer was corrent!!!! +Pat now has 4 Gold Coins. +Sue is the current player +They have rolled a 1 +Sue is getting out of the penalty box +Sue's new location is 5 +The category is Science +Science Question 2 +Answer was correct!!!! +Sue now has 1 Gold Coins. +Chet is the current player +They have rolled a 5 +Chet's new location is 5 +The category is Science +Science Question 3 +Answer was corrent!!!! +Chet now has 5 Gold Coins. +Pat is the current player +They have rolled a 4 +Pat's new location is 5 +The category is Science +Science Question 4 +Answer was corrent!!!! +Pat now has 5 Gold Coins. +Sue is the current player +They have rolled a 4 +Sue is not getting out of the penalty box +Chet is the current player +They have rolled a 5 +Chet's new location is 10 +The category is Sports +Sports Question 4 +Answer was corrent!!!! +Chet now has 6 Gold Coins. diff --git a/texttests/testsuite.gr b/texttests/testsuite.gr new file mode 100644 index 0000000000..4ad96d5159 --- /dev/null +++ b/texttests/testsuite.gr @@ -0,0 +1 @@ +default From 8afa425687de516302e769fa711b92c58ebeecc9 Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Tue, 30 Jan 2024 09:26:45 +0100 Subject: [PATCH 10/17] Add python gitignore --- python/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 python/.gitignore diff --git a/python/.gitignore b/python/.gitignore new file mode 100644 index 0000000000..bee8a64b79 --- /dev/null +++ b/python/.gitignore @@ -0,0 +1 @@ +__pycache__ From a01119a802337438c3dc1e9536e1bb2cdace13d2 Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Tue, 30 Jan 2024 09:44:13 +0100 Subject: [PATCH 11/17] Add explicit interpreter --- python/texttest_fixture.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/texttest_fixture.py b/python/texttest_fixture.py index 755a593934..fe1077cb76 100644 --- a/python/texttest_fixture.py +++ b/python/texttest_fixture.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 from trivia import main # Make sure all runs use the same random sequence From 4818fc368706a757bb17d7d04f3f01bc548c2c7b Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Tue, 30 Jan 2024 09:45:09 +0100 Subject: [PATCH 12/17] Extract main() --- python/trivia.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/trivia.py b/python/trivia.py index 7799c643d7..d91df358ab 100755 --- a/python/trivia.py +++ b/python/trivia.py @@ -145,7 +145,7 @@ def _did_player_win(self): from random import randrange -if __name__ == '__main__': +def main(): not_a_winner = False game = Game() @@ -163,3 +163,6 @@ def _did_player_win(self): not_a_winner = game.was_correctly_answered() if not not_a_winner: break + +if __name__ == '__main__': + main() From 325e1166a3cd03bd8966cd5b7ec5c07da8853087 Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Tue, 30 Jan 2024 09:52:32 +0100 Subject: [PATCH 13/17] Replace reference stdout with "broken" instructions Different varaints of the Kata use different PRNGs, meaning that no single reference output for comparison can be provided. --- texttests/default/stdout.gr | 110 +----------------------------------- 1 file changed, 3 insertions(+), 107 deletions(-) diff --git a/texttests/default/stdout.gr b/texttests/default/stdout.gr index bc4c4b62a5..cb291497b4 100644 --- a/texttests/default/stdout.gr +++ b/texttests/default/stdout.gr @@ -1,107 +1,3 @@ -Chet was added -They are player number 1 -Pat was added -They are player number 2 -Sue was added -They are player number 3 -Chet is the current player -They have rolled a 2 -Chet's new location is 2 -The category is Sports -Sports Question 0 -Answer was corrent!!!! -Chet now has 1 Gold Coins. -Pat is the current player -They have rolled a 3 -Pat's new location is 3 -The category is Rock -Rock Question 0 -Answer was corrent!!!! -Pat now has 1 Gold Coins. -Sue is the current player -They have rolled a 4 -Sue's new location is 4 -The category is Pop -Pop Question 0 -Question was incorrectly answered -Sue was sent to the penalty box -Chet is the current player -They have rolled a 4 -Chet's new location is 6 -The category is Sports -Sports Question 1 -Answer was corrent!!!! -Chet now has 2 Gold Coins. -Pat is the current player -They have rolled a 2 -Pat's new location is 5 -The category is Science -Science Question 0 -Answer was corrent!!!! -Pat now has 2 Gold Coins. -Sue is the current player -They have rolled a 4 -Sue is not getting out of the penalty box -Chet is the current player -They have rolled a 4 -Chet's new location is 10 -The category is Sports -Sports Question 2 -Answer was corrent!!!! -Chet now has 3 Gold Coins. -Pat is the current player -They have rolled a 5 -Pat's new location is 10 -The category is Sports -Sports Question 3 -Answer was corrent!!!! -Pat now has 3 Gold Coins. -Sue is the current player -They have rolled a 4 -Sue is not getting out of the penalty box -Chet is the current player -They have rolled a 2 -Chet's new location is 0 -The category is Pop -Pop Question 1 -Answer was corrent!!!! -Chet now has 4 Gold Coins. -Pat is the current player -They have rolled a 3 -Pat's new location is 1 -The category is Science -Science Question 1 -Answer was corrent!!!! -Pat now has 4 Gold Coins. -Sue is the current player -They have rolled a 1 -Sue is getting out of the penalty box -Sue's new location is 5 -The category is Science -Science Question 2 -Answer was correct!!!! -Sue now has 1 Gold Coins. -Chet is the current player -They have rolled a 5 -Chet's new location is 5 -The category is Science -Science Question 3 -Answer was corrent!!!! -Chet now has 5 Gold Coins. -Pat is the current player -They have rolled a 4 -Pat's new location is 5 -The category is Science -Science Question 4 -Answer was corrent!!!! -Pat now has 5 Gold Coins. -Sue is the current player -They have rolled a 4 -Sue is not getting out of the penalty box -Chet is the current player -They have rolled a 5 -Chet's new location is 10 -The category is Sports -Sports Question 4 -Answer was corrent!!!! -Chet now has 6 Gold Coins. +################################################################## +# Replace stdout.gr by approiving the first result from texttest # +################################################################## From 550d4fd82ec97a38c82923542e09eb11125dbf47 Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Tue, 30 Jan 2024 09:57:28 +0100 Subject: [PATCH 14/17] Add texttest config for C --- texttests/config.gr | 3 +++ 1 file changed, 3 insertions(+) diff --git a/texttests/config.gr b/texttests/config.gr index 9f3da99702..59f8de5538 100644 --- a/texttests/config.gr +++ b/texttests/config.gr @@ -11,4 +11,7 @@ interpreter:python3 # Settings for the C++ version #executable:${TEXTTEST_HOME}/C++/build/Trivia +# Settings for the C version +#executable:${TEXTTEST_HOME}/C/build/trivia + filename_convention_scheme:standard From 06335b828c73019d9b095b825dc00bfea82f4a41 Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Tue, 30 Jan 2024 10:04:00 +0100 Subject: [PATCH 15/17] Make C random repeatable --- C/game_runner.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/C/game_runner.c b/C/game_runner.c index a7aba2e98f..43dacf2c96 100644 --- a/C/game_runner.c +++ b/C/game_runner.c @@ -8,13 +8,13 @@ int main () { struct Game *a_game = game_new (); + srand(1); // make RNG repeatable + // srand ((unsigned)time(0)); game_add (a_game, "Chet"); game_add (a_game, "Pat"); game_add (a_game, "Sue"); - srand ((unsigned)time(0)); - do { game_roll (a_game, rand () % 5 + 1); From bce63b84a935fe2e742bcba1dd43387363eeb575 Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Tue, 30 Jan 2024 10:06:40 +0100 Subject: [PATCH 16/17] Make C++ variant random() repeatable --- C++/GameRunner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C++/GameRunner.cpp b/C++/GameRunner.cpp index e57235c924..6f80542f5f 100644 --- a/C++/GameRunner.cpp +++ b/C++/GameRunner.cpp @@ -6,7 +6,7 @@ static bool notAWinner; int main() { Game aGame; - + srand(0); aGame.add("Chet"); aGame.add("Pat"); aGame.add("Sue"); From fea851c8b915da11ec51e5a2a4a5df50684da74d Mon Sep 17 00:00:00 2001 From: Grigory Rechistov Date: Tue, 30 Jan 2024 10:11:26 +0100 Subject: [PATCH 17/17] Make C/C++/Python variants use non-repeatable RNG Let's allow the students to figure out it for themselves. --- C++/GameRunner.cpp | 4 +++- C/game_runner.c | 4 ++-- python/texttest_fixture.py | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/C++/GameRunner.cpp b/C++/GameRunner.cpp index 6f80542f5f..8ad6c9b761 100644 --- a/C++/GameRunner.cpp +++ b/C++/GameRunner.cpp @@ -1,4 +1,5 @@ #include +#include #include "Game.h" static bool notAWinner; @@ -6,7 +7,8 @@ static bool notAWinner; int main() { Game aGame; - srand(0); + srand ((unsigned)time(0)); + // srand(0); aGame.add("Chet"); aGame.add("Pat"); aGame.add("Sue"); diff --git a/C/game_runner.c b/C/game_runner.c index 43dacf2c96..029365eea5 100644 --- a/C/game_runner.c +++ b/C/game_runner.c @@ -8,8 +8,8 @@ int main () { struct Game *a_game = game_new (); - srand(1); // make RNG repeatable - // srand ((unsigned)time(0)); + //srand(1); // make RNG repeatable + srand ((unsigned)time(0)); game_add (a_game, "Chet"); game_add (a_game, "Pat"); diff --git a/python/texttest_fixture.py b/python/texttest_fixture.py index fe1077cb76..537283c573 100644 --- a/python/texttest_fixture.py +++ b/python/texttest_fixture.py @@ -2,8 +2,8 @@ from trivia import main # Make sure all runs use the same random sequence -from random import seed -seed(1) +#from random import seed +#seed(1) if __name__ == "__main__": main()