Author SHA1 Message Date
Kai Philipp 29259f1f29 bugfix 2020-01-25 17:23:44 +01:00
Kai Philipp 1ff513e09a bugfix 2020-01-25 17:17:41 +01:00
Kai Philipp b03d39d141 bugfix 2020-01-25 17:16:54 +01:00
Kai Philipp 99de54cdf5 string output optimized 2020-01-25 17:16:09 +01:00
Kai Philipp d2849449ce bugfix 2020-01-25 17:14:13 +01:00
Kai Philipp f31127e695 bugfix 2020-01-25 17:12:08 +01:00
Kai Philipp 03602cd37f pro missing linked boost_random 2020-01-25 17:10:09 +01:00
Kai Philipp a5c8aefeb2 pro missing linked boost 2020-01-25 17:05:33 +01:00
Kai Philipp 4e888e2cfe pro file adaption 2020-01-25 16:59:22 +01:00
Kai Philipp c96955e719 pro file adaptions 2020-01-25 16:58:08 +01:00
Kai Philipp ef1ccfdbd7 bugfix 2020-01-25 16:55:54 +01:00
Kai Philipp cedf5f7218 bugfix 2020-01-25 16:53:13 +01:00
Kai Philipp ad80896fae dealer_random_test added 2020-01-25 16:50:06 +01:00
2 changed files with 201 additions and 0 deletions
+86
View File
@@ -0,0 +1,86 @@
# QMake pro-file for the PokerTH dedicated server
isEmpty( PREFIX ){
PREFIX =/usr
}
TEMPLATE = app
CODECFORSRC = UTF-8
CONFIG += thread console embed_manifest_exe exceptions rtti stl warn_on
UI_DIR = uics
TARGET = bin/dealer_random_test
MOC_DIR = mocs
OBJECTS_DIR = obj
DEFINES += PREFIX=\"$${PREFIX}\"
QT -= core gui
#PRECOMPILED_HEADER = src/pch_lib.h
INCLUDEPATH += . \
src
DEPENDPATH += . \
src
# Input
SOURCES += \
src/dealer_random_test.cpp
unix : !mac {
##### My release static build options
#QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
#QMAKE_LFLAGS += -Wl,--gc-sections
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
INCLUDEPATH += $${PREFIX}/include
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
BOOST_SYS = boost_system boost_system-mt
#
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
# to override the default '/usr' pass PREFIX
# variable to qmake.
#
for(dir, LIB_DIRS){
exists($$dir){
for(lib, BOOST_PROGRAM_OPTIONS):exists($${dir}/lib$${lib}.so*) {
message("Found $$lib")
BOOST_PROGRAM_OPTIONS = -l$$lib
}
for(lib, BOOST_PROGRAM_OPTIONS):exists($${dir}/lib$${lib}.a) {
message("Found $$lib")
BOOST_PROGRAM_OPTIONS = -l$$lib
}
for(lib, BOOST_SYS):exists($${dir}/lib$${lib}.so*) {
message("Found $$lib")
BOOST_SYS = -l$$lib
}
for(lib, BOOST_SYS):exists($${dir}/lib$${lib}.a) {
message("Found $$lib")
BOOST_SYS = -l$$lib
}
}
}
BOOST_LIBS = $$BOOST_PROGRAM_OPTIONS $$BOOST_SYS
!count(BOOST_LIBS, 2){
error("Unable to find boost libraries in PREFIX=$${PREFIX}")
}
UNAME = $$system(uname -s)
BSD = $$find(UNAME, "BSD")
kFreeBSD = $$find(UNAME, "kFreeBSD")
LIBS += $$BOOST_LIBS
LIBS += -lprotobuf -lgsasl -lgcrypt -lidn -lboost_thread -lboost_system -lboost_random
#### INSTALL ####
binary.path += $${PREFIX}/bin/
binary.files += dealer_random_test
INSTALLS += binary
}
+115
View File
@@ -0,0 +1,115 @@
/*****************************************************************************
* PokerTH - The open source texas holdem engine *
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* *
* Additional permission under GNU AGPL version 3 section 7 *
* *
* If you modify this program, or any covered work, by linking or *
* combining it with the OpenSSL project's OpenSSL library (or a *
* modified version of that library), containing parts covered by the *
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
* permission to convey the resulting work. *
* Corresponding Source for a non-source form of such a combination *
* shall include the source code for the parts of OpenSSL used as well *
* as that of the covered work. *
*****************************************************************************/
// Connectivity test program for PokerTH
#include <iostream>
#include <boost/program_options.hpp>
#include <boost/thread.hpp>
#include <boost/nondet_random.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/variate_generator.hpp>
using namespace std;
namespace po = boost::program_options;
boost::thread_specific_ptr<boost::random_device> g_rand_state;
struct nondet_rng : std::unary_function<unsigned, unsigned> {
boost::random_device &_state;
unsigned operator()(unsigned i)
{
boost::uniform_int<> rng(0, i - 1);
return rng(_state);
}
nondet_rng(boost::random_device &state) : _state(state) {}
};
int
main(int argc, char *argv[])
{
try {
// Check command line options.
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message")
("num,n", po::value<int>(), "set num of deals")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help")) {
cout << desc << endl;
return 1;
}
if (!vm.count("num")) {
cout << "Missing option!" << endl << desc << endl;
return 1;
}
int num = vm["num"].as<int>();
const int NumCards = 52;
for(int i=0; i<num;i++){
// shuffle cards
int cardsArray[NumCards] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51
};
if (!g_rand_state.get()) {
g_rand_state.reset(new boost::random_device);
}
nondet_rng rand(*g_rand_state);
random_shuffle(&cardsArray[0], &cardsArray[NumCards], rand);
ostringstream oss("");
for (int temp = 0; temp < NumCards; temp++){
if(temp > 0) cout << ",";
cout << cardsArray[temp];
}
cout << endl;
}
} catch (...) {
cout << "Exception caught" << endl;
return 1;
}
return 0;
}