This document defines constants and structures for a poker simulation program. It includes #define statements for constants like game stages and player actions. It defines a player struct to store player details. It also includes function prototypes for reading input files, decoding game data, and analyzing player moves defensively. Global variables track game state like player cards, bets, and hand strengths.
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Kevlin Henney
Presented at code::dive (2016-11-15)
Video available at https://www.youtube.com/watch?v=brfqm9k6qzc
It is all to easy to dismiss problematic codebases on some nebulous idea of bad practice or bad programmers. Poor code, however, is rarely arbitrary and random in its structure or formulation. Systems of code, well or poorly structured, emerge from systems of practice, whether effective or ineffective. To improve code quality, it makes more sense to pick apart the specific practices and see their interplay — the cause — than to simply focus on the code itself — the effect. This talk looks at how a handful of coding habits, design practices and assumptions can systematically balloon code and compound its accidental complexity.
Presented at Foo Café (2019-03-21)
Video at https://www.youtube.com/watch?v=tLSKLLxrZyY
Programmers use coding katas to kick the tyres of their programming languages, paradigms and practices. Typically anchored in a TDD cycle, katas are simple problems that give programmers the opportunity to exercise deliberate practice and explore different approaches, whether programming style, pair programming or test-first programming.
But the simplicity can be deceptive, with many programmers tiring of these katas too soon, missing out on some of the more mind-bending and paradigm-expanding opportunities on offer.
This session will pick on a couple of katas and dig deeper into TDD, lambdas, language(s), (dys)functional programming and Alcubierre drive. It will present code in a variety of languages, highlight the weaknesses of some common mantras, play around with ideas — and blend code, humour and general nerdiness to be both an enjoyable and educational session.
How to add an interactive shell (remote, too) to a C++ application by using my open-source C++14 library:
https://github.com/daniele77/cli
In the slide deck you can learn how to use it, how does it work, and find some thoughts about C++ design and patterns used by the library.
Python là ngôn ngữ lập trình đơn giản và đang càng này càng trở lên phổ biến. Bài giảng này cung cấp cách tiếp cận đơn giản dễ hiểu với python một cách dễ dàng nhất
03 of 03 parts
Get Part 1 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-1
Get Part 2 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-2
C is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, while a static type system prevents unintended operations. C provides constructs that map efficiently to typical machine instructions and has found lasting use in applications previously coded in assembly language. Such applications include operating systems and various application software for computers, from supercomputers to PLCs and embedded system.
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Kevlin Henney
Presented at code::dive (2016-11-15)
Video available at https://www.youtube.com/watch?v=brfqm9k6qzc
It is all to easy to dismiss problematic codebases on some nebulous idea of bad practice or bad programmers. Poor code, however, is rarely arbitrary and random in its structure or formulation. Systems of code, well or poorly structured, emerge from systems of practice, whether effective or ineffective. To improve code quality, it makes more sense to pick apart the specific practices and see their interplay — the cause — than to simply focus on the code itself — the effect. This talk looks at how a handful of coding habits, design practices and assumptions can systematically balloon code and compound its accidental complexity.
Presented at Foo Café (2019-03-21)
Video at https://www.youtube.com/watch?v=tLSKLLxrZyY
Programmers use coding katas to kick the tyres of their programming languages, paradigms and practices. Typically anchored in a TDD cycle, katas are simple problems that give programmers the opportunity to exercise deliberate practice and explore different approaches, whether programming style, pair programming or test-first programming.
But the simplicity can be deceptive, with many programmers tiring of these katas too soon, missing out on some of the more mind-bending and paradigm-expanding opportunities on offer.
This session will pick on a couple of katas and dig deeper into TDD, lambdas, language(s), (dys)functional programming and Alcubierre drive. It will present code in a variety of languages, highlight the weaknesses of some common mantras, play around with ideas — and blend code, humour and general nerdiness to be both an enjoyable and educational session.
How to add an interactive shell (remote, too) to a C++ application by using my open-source C++14 library:
https://github.com/daniele77/cli
In the slide deck you can learn how to use it, how does it work, and find some thoughts about C++ design and patterns used by the library.
Python là ngôn ngữ lập trình đơn giản và đang càng này càng trở lên phổ biến. Bài giảng này cung cấp cách tiếp cận đơn giản dễ hiểu với python một cách dễ dàng nhất
03 of 03 parts
Get Part 1 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-1
Get Part 2 from https://www.slideshare.net/ArunUmrao/notes-for-c-programming-for-bca-mca-b-sc-msc-be-amp-btech-1st-year-2
C is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, while a static type system prevents unintended operations. C provides constructs that map efficiently to typical machine instructions and has found lasting use in applications previously coded in assembly language. Such applications include operating systems and various application software for computers, from supercomputers to PLCs and embedded system.
The following is my code for a connectn program. When I run my code .pdfeyelineoptics
The following is my code for a connectn program. When I run my code in the tester, I failed two
out 10 tests. I was hoping for some help in finding what causes these errors. I have included the
homework prompt and test failed results. Thank you so much!
#include
#include
#include
void read_args(int argc, char *argv[], int* num_rows, int* num_cols, int *num_pieces_to_win);
void create_board(int num_rows, int num_cols, char*** board, int* turn);
void print_board(int num_rows, int num_cols, char** board);
void destroy_board(int num_rows, char*** board);
void play_game(int num_rows, int num_cols, int num_pieces_to_win, int turn, char** board);
void check_move();
void get_play(int num_rows, int num_cols, char** board, int* user_move);
void make_move(int num_rows, char**board, int user_move, char pieces);
bool play_is_valid(int num_cols, int num_rows, char** board, int user_move_num, int
user_move);
bool game_over(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool game_won(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool game_tied(int num_rows, int num_cols, int num_pieces_to_win, char**board);
bool row_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool col_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool diag_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool right_diag_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool left_diag_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
void read_args(int argc, char *argv[], int* num_rows, int* num_cols, int *num_pieces_to_win) {
//reads command input and ensures there are exactly three numbers
if (argc > 4) {
printf(\"Too many arguments entered\ \");
printf(\"Usage connectn.out num_rows num_columns
number_of_pieces_in_a_row_needed_to_win\");
exit(0);
}
else if (argc < 4) {
printf(\"Not enough arguments entered\ \");
printf(\"Usage connectn.out num_rows num_columns
number_of_pieces_in_a_row_needed_to_win\");
exit(0);
}
else { //puts user input into variables
sscanf(argv[1], \"%d\", &*num_rows);
sscanf(argv[2], \"%d\", &*num_cols);
sscanf(argv[3], \"%d\", &*num_pieces_to_win);
}
return;
}
void create_board (int num_rows, int num_cols, char*** board, int* turn) {
//set up the connect-n board
const char BLANK_SPACE = \'*\';
int i, j;
*turn = 0; //player 1 always goes first
*board = (char**)malloc(num_rows * sizeof(char*)); //creates pointers to the rows
for (i = 0; i < num_rows; ++i){ //for each row
(*board)[i] = (char*)malloc(num_cols * sizeof(char)); //create it
for (j = 0; j < num_cols; j++) { //fill in the row with blanks
(*board)[i][j] = BLANK_SPACE;
}
}
}
void print_board (int num_rows, int num_cols, char** board) {
//displays connect-n board
int i, j;
int k = 0;
for(i = 0; i < num_rows; i++){
printf(\"%d \", ((num_rows- i) - 1));
for(j = 0; j < num_cols; ++j){
printf(\"%c \", board[i][j]);
}
printf(\"\ \");
}
printf(\" %d \", k);
for(j = 1; j <.
assign4assign4_part1bonnie.c This is a file system ben.docxfestockton
assign4/assign4_part1/bonnie.c
/*
* This is a file system benchmark which attempts to study bottlenecks -
* it is named 'Bonnie' after Bonnie Raitt, who knows how to use one.
*
* Commentary on Bonnie's operations may be found at
* http://www.textuality.com/bonnie/intro.html
*
* COPYRIGHT NOTICE:
* Copyright (c) Tim Bray, 1990-1996.
*
*/
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#if defined(SysV)
#include <limits.h>
#include <sys/times.h>
#else
#include <sys/resource.h>
#endif
#define IntSize (sizeof(int))
/*
* N.B. in seeker_reports, CPU appears and Start/End time, but not Elapsed,
* so position 1 is re-used; icky data coupling.
*/
#define CPU (0)
#define Elapsed (1)
#define StartTime (1)
#define EndTime (2)
#define Seeks (4000)
#define UpdateSeek (10)
#define SeekProcCount (3)
#define Chunk (16384)
/* labels for the tests, used as an array index */
typedef enum {
Putc, ReWrite, FastWrite, Getc, FastRead, Lseek, TestCount
} tests_t;
static double cpu_so_far();
static void doseek(off_t where, int fd, int update);
static void get_delta_t(tests_t test);
static void io_error(char *message);
static void newfile(char *name, int *fd, FILE * *stream, int create);
static void fill_file_char();
static void fill_file_block();
static void file_read_rewrite_block();
static void file_read_getc();
static void file_read_chunk();
#if defined(SysV)
/* System V wrappers for randomizers */
static long random();
static void srandom(int seed);
#endif
static void report(char *machine, off_t size);
static double time_so_far();
static void timestamp();
static void usage();
/*
* Housekeeping variables to build up timestamps for the tests;
* global to make it easy to keep track of the progress of time.
* all of this could have been done with non-global variables,
* but the code is easier to read this way and I don't anticipate
* much software engineering down the road
*/
static int basetime; /* when we started */
static double delta[(int) TestCount][2]; /* array of DeltaT values */
static double last_cpustamp = 0.0; /* for computing delta-t */
static double last_timestamp = 0.0; /* for computing delta-t */
char name[Chunk];
FILE *stream;
int fd;
off_t words;
off_t size;
int buf[Chunk / IntSize];
int bufindex;
int chars[256];
int next;
/* entry point for LMP1 */
int bonnie_main(int argc, char **argv)
{
int child;
char *dir;
double first_start;
double last_stop;
int lseek_count = 0;
char *machine;
int seek_control[2];
int seek_feedback[2];
char seek_tickets[Seeks + SeekProcCount];
double seeker_report[3];
fd = -1;
basetime = (int) time((time_t *) NULL);
size = 100;
dir = ".";
machine = "";
/* parse the argument sent from the command line */
for (next = 1; next < argc; next++) {
if (strcmp(argv[next], "-s") ...
I have the following code and I need to know why I am receiving the .pdfezzi552
Edwards Manufacturing Company purchases two component parts from three different suppliers.
The suppliers have limited capacity, and no one supplier can meet all the company’s needs. In
addition, the suppliers charge different prices for the components. Component price data (in
price per unit) are as follows:
Each supplier has a limited capacity in terms of the total number of components it can supply.
However, as long as Edwards provides sufficient advance orders, each supplier can devote its
capacity to component 1, component 2, or any combination of the two components, if the total
number of units ordered is within its capacity. Supplier capacities are as follows:
If the Edwards production plan for the next period includes 1000 units of component 1 and 800
units of component 2, what purchases do you recommend? That is, how many units of each
component should be ordered from each supplier? Round your answers to the nearest whole
number.
What is the total purchase cost for the components? Round your answer to the nearest dollar.
$ ????SupplierComponent1231$11$10$132$10$11$11
Solution
For component 1:
supplier 2 have minimum cost and capacity 1050.
So all the component 1 (1000) can be purchased from supplier 2.
So, supplier 2 have 50 more capacity.
Now, supplier 1 have minimum cost for component 2 and have capacity of 650.
so, number of component 2 from supplier1 can be 650.
Now, we need 150 more component 2.
supplier 2 and 3 have same cost for component 2.
supllier have only 50 capacity now and supplier have 850.
So, 150 component 2 can be purchased from supplier 3.
Let y be the number of components fromSupplier123TotalcostComponent
1010000100010000Component 265001508008150Total cost18150.
JavaScript for Unleashed a game about a robbery in London and its pretty long i do not know why you would want it but here have it :P also this is not pro its just for school because i am a loner like that and i have nothing better to do
Program of sorting using shell sort #include stdio.h #de.pdfanujmkt
/* Program of sorting using shell sort */
#include
#define MAX 20
main()
{
int arr[MAX], i,j,k,n,incr;
printf(\"Enter the number of elements : \");
scanf(\"%d\",&n);
for(i=0;i=1)
{
for(j=incr;j= 0 && k < arr[i]; i = i-incr)
arr[i+incr]=arr[i];
arr[i+incr]=k;
}
printf(\"Increment=%d \ \",incr);
for (i = 0; i < n; i++)
printf(\"%d \", arr[i]);
printf(\"\ \");
incr=incr-2; /*Decrease the increment*/
}/*End of while*/
printf(\"Sorted list is :\ \");
for (i = 0; i < n; i++)
printf(\"%d \", arr[i]);
printf(\"\ \");
}/*End of main()*/
redix sort
/*Program of sorting using radix sort*/
# include
# include
struct node
{
int info ;
struct node *link;
}*start=NULL;
main()
{
struct node *tmp,*q;
int i,n,item;
printf(\"Enter the number of elements in the list : \");
scanf(\"%d\", &n);
for(i=0;iinfo=item;
tmp->link=NULL;
if(start==NULL) /* Inserting first element */
start=tmp;
else
{
q=start;
while(q->link!=NULL)
q=q->link;
q->link=tmp;
}
}/*End of for*/
printf(\"Unsorted list is :\ \");
display();
radix_sort();
printf(\"Sorted list is :\ \");
display ();
}/*End of main()*/
display()
{
struct node *p=start;
while( p !=NULL)
{
printf(\"%d \", p->info);
p= p->link;
}
printf(\"\ \");
}/*End of display()*/
radix_sort()
{
int i,k,dig,maxdig,mindig,least_sig,most_sig;
struct node *p, *rear[10], *front[10];
least_sig=1;
most_sig=large_dig(start);
for(k = least_sig; k <= most_sig ; k++)
{
printf(\"PASS %d : Examining %dth digit from right \",k,k);
for(i = 0 ; i <= 9 ; i++)
{
rear[i] = NULL;
front[i] = NULL ;
}
maxdig=0;
mindig=9;
p = start ;
while( p != NULL)
{
/*Find kth digit in the number*/
dig = digit(p->info, k);
if(dig>maxdig)
maxdig=dig;
if(diglink = p ;
rear[dig] = p ;
p=p->link;/*Go to next number in the list*/
}/*End while */
/* maxdig and mindig are the maximum amd minimum
digits of the kth digits of all the numbers*/
printf(\"mindig=%d maxdig=%d\ \",mindig,maxdig);
/*Join all the queues to form the new linked list*/
start=front[mindig];
for(i=mindig;ilink=front[i+1];
else
rear[i+1]=rear[i];
}
rear[maxdig]->link=NULL;
printf(\"New list : \");
display();
}/* End for */
}/*End of radix_sort*/
/* This function finds number of digits in the largest element of the list */
int large_dig()
{
struct node *p=start ;
int large = 0,ndig = 0 ;
while(p != NULL)
{
if(p ->info > large)
large = p->info;
p = p->link ;
}
printf(\"Largest Element is %d , \",large);
while(large != 0)
{
ndig++;
large = large/10 ;
}
printf(\"Number of digits in it are %d\ \",ndig);
return(ndig);
} /*End of large_dig()*/
/*This function returns kth digit of a number*/
int digit(int number, int k)
{
int digit, i ;
for(i = 1 ; i <=k ; i++)
{
digit = number % 10 ;
number = number /10 ;
}
return(digit);
}/*End of digit()*/
Solution
/* Program of sorting using shell sort */
#include
#define MAX 20
main()
{
int arr[MAX], i,j,k,n,incr;
printf(\"Enter the number of elements : \");
scanf(\"%d\",&n);
for(i=0;i=1)
{
for(j=incr;j= 0 && k < arr[i]; i = i-incr)
arr[i+incr]=arr[i];
arr[i+incr]=k;
}
printf(\.
Add a 3rd field help that contains a short help string for each of t.pdfinfo245627
Add a 3rd field help that contains a short help string for each of the commands you were to
implement in assignment #3. Make sure that your array(s) are big enough to handle 5 extra items
beyond your initialization. To save time only include help for exercises 4, 5, 6 and 8 in this
assignment, and use No help for the other entries.
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
void ctrlCHandler(int signum)
{
fprintf(stderr,"Command server terminated using C\n");
exit(1);
}
char * fExport(char *cmd, char *tokensleft[])
{
setenv(tokensleft[0],tokensleft[1],1);
return "Command 'export' was received";
}
char * fChdir(char *cmd,char *tokensleft[])
{
int ch=chdir(tokensleft[0]);
if(ch<0)
perror("chdir change of directory not successful\n");
else
printf("chdir change of directory successful\n");
return "Command 'chdir' was received\n";
}
char * fAccess(char *cmd,char *tokensleft[])
{
int exists =0;
for(int i=0;tokensleft[i]; i++) {
exists =0;
if(access(tokensleft[i],F_OK)==0){
exists = 1;
printf("file %s exists\n",tokensleft[i]);
}else{
printf("file %s does not exists\n",tokensleft[i]);
}
if (exists == 1){
if(access(tokensleft[i],R_OK)==0) {
printf("file %s is readable\n",tokensleft[i]);
}else{printf("file %s is not readable\n",tokensleft[i]);}
if(access(tokensleft[i],W_OK)==0) {
printf("file %s is writeable\n",tokensleft[i]);
}else{
printf("file %s is not writeable\n",tokensleft[i]);
}
if(access(tokensleft[i],X_OK)==0) {
printf("file %s is executeable\n",tokensleft[i]);
}else{
printf("file %s is not executeable\n",tokensleft[i]);
}
}// exists if
} //for
return "Command 'acsess' was received\n";
}
char * fChmod(char *cmd,char *tokensleft[])
{
unsigned int octalPerm;
sscanf(tokensleft[0],"%o",&octalPerm);
for(int i=1;tokensleft[i]; i++) {
if(chmod(tokensleft[i],octalPerm)==0 ){
chmod(tokensleft[i],octalPerm);
}else{
printf("Error: %s \n",strerror(errno));
}
}
return "Command 'chmod' was received";
}
char * fPath(char *cmd,char *tokensleft[])
{
char *pathLink;
char actualPath[PATH_MAX+1];
char *pointer;
char *bName;
char *dName;
for(int i=0;tokensleft[i]; i++) {
pathLink = tokensleft[i];
pointer =realpath(pathLink,actualPath);
bName = basename(actualPath);
dName = dirname(tokensleft[i]);
if (pointer){
printf("The Real path of %s is: %s\n",tokensleft[i],actualPath);
printf("The Dir name path of %s is: %s\n",tokensleft[i],dName);
printf("The Base name of %s is: %s\n",tokensleft[i],bName);
}else{
printf("Error: %s \n",strerror(errno));
}
}
return "Command 'path' was received";
}
char * fTouch(char *cmd,char *tokensleft[])
{
extern int optind,optopt,opterr;
struct FLAG{
bool aFlag;
bool mFlag;
} flags = { false, false };
int t1 = time(NULL), t2 = time(NULL);
int argc = 0;
int flag;
for (int i = 0; tokensleft[i]; i++) {
argc++;
}
while ((flag = getopt(argc, tokensleft, "m.
Start with the inclusion of libraries#include iostream .docxMARRY7
// Start with the inclusion of libraries
#include <iostream> //The library of io functions
#include <fstream> //The library of external stream functions
#include <cstdlib> //The library for external errors
#include <string> //The library for string functions
#include <cmath> //The library of C math functions
#include <iomanip> //Allows setting widths, etc. for I/O
#include <stdlib.h>
#include <stdio.h>
#include<vector>
using namespace std;
// Define all of the prototypes for functions used in the program
// Counts the number of unique letters seen
int countunique(int *array, int size);
// Creates the input file and formats it for use by the cipher section.
void createinput(string ifile, string ofile);
// Creates the encoded input file
void createcipher(int key, string ifile, string ofile);
// Finds and counts the number of digrams
int digram(int *pointer, string ifile);
// Counts the letter frequency in the encoded input file
int lettercount(int*, string ifile, string ofile);
// Finds the highest count in the singlton (or any other) array
int singleton(int*, int size);
// Trims an input file to the right size starting at an offset
void trimfile(string ifile, string ofile, int offset, int size);
// Begin the main function for testing
int main(int argc, char* argv[])
{
int count = 0;
int second = 0;
int singlefreq[26];
int *single = singlefreq;
int delta;
int loop; //The loop counter for arguments
int final = 0;
int totalcnt;
int key = -1; //Sets the key value
int len = 0; //The length to investigate for testing
int off; //Holds the offset into the file
double m; //Holds the metric error value
char loopletter;
float percent;
string ifile1 = "";
string ofile1 = "";
string deflt = "c:\\dissertation\\ShiftandSubcipherC++files\\clean.txt";
string ifile2 = "";
string ofile2 = ""; //Holds selected file path names
string cmdarg; //Holds the command line argument
string stop = "l"; //Gives the stop condition, assumes l
string reportfile = "c:\\dissertation\\test\\report.txt";
ofstream outs; //Declare an output stream for reporting
int digramc[676]; //Set up the digram array
int *two = digramc; //Point to the digram array
int dicount = 0; //Holds the count of the number of digrams
int total = 0; //Counts the total number of letters seen for analysis
for (loop = 1; loop<argc; loop++) //Decide if we have arguments or must use defaults
{
if (!argv[1])
{
// cout << "No argument found.\n";
ifile1 = deflt;
}
else
{
cmdarg = argv[loop];
if (cmdarg == "-k")
{
loop++;
key = atoi(argv[loop]);
cout << "key = " << key << endl;
}
if (cmdarg == "-l")
{
loop++;
len = atoi(argv[loop]);
cout << "Run for " << len << " characters.\n";
}
if (cmdarg == "-m")
{
loop++;
m = atof(argv[loop]);
cout << "Run until and error of " << m << "\n";
}
if (cmdarg == "-off")
{
loop++;
off = atoi(argv[loop]);
cout << ...
Getting the following errorsError 1 error C2436 {ctor} mem.pdfherminaherman
Getting the following errors:
Error 1 error C2436: \'{ctor}\' : member function or nested class in constructor initializer list on
line 565
Error 2 error C2436: \'{ctor}\' : member function or nested class in constructor initializer list on
line 761
I need this code to COMPILE and RUN, but I cannot get rid of this error. Please Help!!
#include
#include
#include
#include
using namespace std;
enum contactGroupType
{// used in extPersonType
FAMILY,
FRIEND,
BUSINESS,
UNFILLED
};
class addressType
{
private:
string st_address;
string city;
string state;
int zip;
public:
void print(string, string, string, int)const;
void setStreet(string);
string getStreet()const;
void setCity(string);
string getCity()const;
void setState(string);
string getState()const;
void setZip(int);
int getZip()const;
void set(string, string, string, int);// set all address fields
string get()const;// get address as one concatenated string
addressType();
// ~addressType();
};
class personType
{
private:
string firstName;
string lastName;
public:
void print()const;
void setName(string first, string last);
string getFirstName()const;
string getLastName()const;
string get()const;// return First Last names concatenated
personType & operator=(const personType &);
personType(string, string);
personType();
};
class dateType
{
private:
int dMonth;
int dDay;
int dYear;
public:
void setDate(int month, int day, int year);
int getDay()const;
int getMonth()const;
int getYear()const;
void print()const;
string get()const;// return string representation as DD/MM/YYYY
dateType & operator=(const dateType & d);
dateType(int, int, int);
dateType();
};
class extPersonType :public personType {
private:
addressType address;// added members
dateType birthday;
contactGroupType group;
string phone;
public:
// methods
void setPhone(string);
string getPhone()const;
void setGroup(contactGroupType);
contactGroupType getGroup()const;
void setBirthday(int, int, int);
dateType getBirthday()const;
void print();
string get()const;// return string representation of ext person type
extPersonType & operator=(const extPersonType & p);
string groupToString(contactGroupType)const;
contactGroupType stringToGroup(string)const;
// constructors
extPersonType();
extPersonType(string first, string last);
};
// because we have no arrayListType, we are using our own
// implementation with a small subset of functions
class arrayListType
{
extPersonType array[500];
int size;
public:
arrayListType();
extPersonType & operator[](int i);
void removeLast();// remove last element
void add(const extPersonType &);// add new element
int getSize()const;// get array size
};
class addressBookType :public arrayListType
{
private:
static const char FS = \'\\t\';// field separator in file (TAB char)
int current;// current position
string fileName;// filename
fstream fileStream;// file as fstream
/* filiters */
contactGroupType fltGroup;
string fltFromLast, fltToLast;
dateType fltFromDate, fltTiDate;
/* flags for effective filters */
bool fl.
RightTriangle/rightTriangle.cppRightTriangle/rightTriangle.cpp// This file includes implementations for functions of the right
// triangle class.
#include<iostream>
#include<cmath>
usingnamespace std;
#include"rightTriangle.h"
// Default constructor
RightTriangle::RightTriangle()
{
base =0;
height =0;
}
// SET functions (for storing data in private data members)
voidRightTriangle::setHeight(double h)
{
height = h;
}
voidRightTriangle::setBase(double b)
{
base = b;
}
// Calculate length of hypotenuse using
// Pythagorean Theorem
doubleRightTriangle::calcHypotenuse()
{
return sqrt (base * base + height * height);
}
__MACOSX/RightTriangle/._rightTriangle.cpp
RightTriangle/rightTriangle.h
// This file defines the specifications for a class to store
// attributes of a right triangle
class RightTriangle
{
private: // PRIVATE data members
double base;
double height;
public: // PUBLIC member functions
RightTriangle(); // Default constructor
void setHeight(double h); // SET functions
void setBase(double b);
// Calculate length of hypotenuse
double calcHypotenuse();
};
__MACOSX/RightTriangle/._rightTriangle.h
RightTriangle/testTriangle.cppRightTriangle/testTriangle.cpp// This program calculates various parameters of a
// right triangle.
#include<iostream>
usingnamespace std;
#include"rightTriangle.h"
int main()
{
// Declaration
double base,height;
RightTriangle aTriangle;
// Input
cout <<"Enter the base of the triangle: ";
cin >> base;
cout <<"Enter the height of the triangle: ";
cin >> height;
// Move data to object
aTriangle.setBase(base);
aTriangle.setHeight(height);
// Calculations and output
cout << endl;
cout <<"Length of hypotenuse: "
<< aTriangle.calcHypotenuse()<< endl;
return0;
}// end main function
__MACOSX/RightTriangle/._testTriangle.cpp
c++practice3a3b/._rightTriangle.cpp
c++practice3a3b/._rightTriangle.h
c++practice3a3b/._testTriangle.cpp
c++practice3a3b/partList.txt
2345 Snoozle 15.4 29.95
1234 Widget 5.4 9.99
3456 Bludger 9.1 15.49
5678 Zeeter 7.7 1.99
6789 Sub_Tweezer 12.3 5.25
4567 Woofle 3.7 49.79
c++practice3a3b/partMgr.cppc++practice3a3b/partMgr.cpp// This program manages a list of parts.
#include<iostream>
#include<iomanip>
#include<fstream>
usingnamespace std;
// Attributes for one part
struct partInfo
{
int number;
char name[30];
double weight;
double price;
};
constint MAX_LIST_SIZE =100;
// Function prototypes
int menu();
void buildPartsList(partInfo partList[],int& listSize);
void searchParts(partInfo partList[],int numParts);
void listParts(partInfo partList[],int& numParts);
void insertPart(partInfo list[],int& numElems);
void deletePart(partInfo list[],int& numElems);
partInfo getPartInfo();
v ...
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
2. short int pot_money[7][5][500]={0}; /* [TEAM
NUMBER][STAGE][ROUND] */
short int players_hand_card_1[7]; /* [TEAM NUMBER] */
short int players_hand_card_2[7]; /* [TEAM NUMBER] */
short int river_cards[5],r_count=0; /* [STAGE] */
short int player_p_values[7][5]; /* [TEAM NUMBER][STAGE] */
short int checkPattern[6][5][4][3][7] ={0}; /*
[PVALUE][ACTION][REACTION][STAGE][TEAMNUMBER] */
int round_number[5]; /* [STAGE] */
int p_ratio[6]; /* [PVALUE] */
int reaction_ratio[5]; /* [REACTION] */
bool players_folded[7]; /* [TEAM NUMBER] */
short int number_of_folds; /* Stores the Number of
Folds */
short int play_mode; /* 1 :: OFFENSIVE | 2 ::
DEFENSIVE | 3 :: ULTRA DEFENSIVE */
short int number_of_deals; /* Stores the Number of
Deals */
player players[7];
int deal_number; /* Represents the
nth deal */
bool is_show_down; /* Tells if its Show
Down or not */
bool stagePlayed[6]={0}; /* Bool of Stages Played */
bool playersEliminated[7]; /* [TEAM NUMBER] */
short int num_players_eliminated = 0;
void printPlayerDetails(player p);
void read_file(char *name,char *data);
int getInt(char *data);
int decode_input_file(char *data);
int decode_dealsMoney(char *data);
void getString(char *str,char *data);
int decode_dealFile(char *data,int *stage,int *main_pot);
void read_showDown_handCards(char *data);
void get_current_state_players(char *data,int stage,int self_teamNumber,int dealer);
void set_play_mode(int self_team_number);
int defensive_play(int stage,int *all_cards,int n_total_cards,int self_team_number,int dealer);
bool is_bluffsMore(short int team_number);
int get_minimum_raise(short int stage,short int team_number,short int dealer);
short int get_rank(int self_team_number);
void set_p_ratio();
void set_reaction_ratio();
void set_player_folded();
bool is_FirstTurn(short int dealer, short int self_team_number);
short int checkPattern_p(int action,int reaction, int stage ,int team,int detail);
short int checkPattern_action(int p_value,int action,int reaction, int stage ,int team,int detail);
int catagorize_move(int p_move);
void analyze_data(int self_teamNumber,int dealer);
int offensive(int stage,int *cards,int total,int teamno,int dealer);
int getMove(int stage,int phand,int *team,int teamno,int dealer);
3. int bluff(int rise, int limit);
int lowraise(int bet);
int compare (const void * a, const void * b);
int pcounter(int *cards,int hand,int total);
int highcard(int *hole,int hand);
int pairs(int *cards,int *allpairs,int total);
int twoofakind(int *allpairs,int paircards,int *hole,int hand);
int twopair(int *allpairs,int paircards,int *hole,int hand);
int threeofakind(int *allpairs,int paircards,int *cards,int total,int *hole , int hand);
int straight(int *cards,int total,int *hole,int hand);
int flush(int *cards,int total,int *hole,int hand);
int fullhouse(int *allpairs,int paircards,int *cards,int total,int *hole , int hand );
int fourofakind(int *allpairs,int paircards,int *hole,int hand);
int striaghtflush(int *cards,int total,int *hole,int hand);
int priver(int*cards,int hand,int total);
int pgrader(int probab , int stage);
int ppreflop(int hand1,int hand2);
int pfuture(int *cards,int total);
int futurestraight(int *cards,int total);
int futureflush(int *cards, int total);
int overallp(int*cards,int total,int stage);
void start_deal(char *data,int self_teamNumber,int *players_left);
int anyoppraisehigh(int stage,int round,int firstplayer,int myteamno,int dealer);
void printPlayerDetails(player p)
{
cout << "n Hand 1 = " << p.handCard1;
cout << "n Hand 2 = " << p.handCard2;
cout << "n Team Number = " << p.team;
cout << "n Current Round Bet = " << p.bet;
}
void read_file(char *name,char *data)
{
FILE *file;
file = fopen(name, "rb");
fread(data,1000,1,file);
fclose(file);
}
char *ptr;
char *ptr_startReading;
int getInt(char *data)
{
int temp=0;
while(*ptr < '0' || *ptr > '9' )
ptr++;
while(*ptr >= '0' && *ptr <= '9')
{
temp = temp*10 + (*ptr - '0');
9. cout << "nStage = " <<stage << " t_round = " << t_round;
round_number[stage]=t_round;
fout_river.close();
//getch();
return ;
}
void set_play_mode(int self_team_number)
{
int money_total=0;
for(int xx=1;xx<=6;xx++)
money_total=money_total+players[xx].money_remaining;
int mean= money_total/(6-num_players_eliminated);
cout << "nMean Money = " << mean << "n2/3rd of Mean = " <<(2*mean)/3 << "nRank = "
<< get_rank(self_team_number);
if(players[self_team_number].money_remaining >=500 && ((get_rank(self_team_number)
<=(2*(6-num_players_eliminated))/3) || num_players_eliminated >=3))
play_mode = OFFENSIVE;
else
play_mode = DEFENSIVE;
cout << "nPlay Mode = "<<play_mode;
//getch();
/* SET BRUTEFORE play_mode - Until Rank is Top 3 or until Money doesnt go below 500 or
800 deals */
// Remove the Comments below to Activate Ultra Defensive modee //
/*
play_mode = ULTRA_DEFENSIVE;
if(get_rank(self_team_number) <=3 || players[self_team_number].money_remaining <=
500 || deal_number >= 800)
play_mode = OFFENSIVE;
*/
}
/*
stage = The current Stage
all_cards = All cards including hand card and river Card. (First two Cards as Hand Cards
n_total_cards = Total Number of Cards = River Cards + 2 Hand Cards
self_team_number = The team number who has to return a Reply
dealer = the dealer for the current deal
*/
int defensive_play(int stage,int *all_cards,int n_total_cards,int self_team_number,int dealer)
{
/* An array that stores all the Cards , including Hand Cards (as 1st 2 cards) & and River Cards
to call "overallp" function */
10. /*static int all_cards[7]; */
/*all_cards[0] = players_hand_card_1[self_team_number]; */
/*all_cards[1] = players_hand_card_2[self_team_number]; */
/*for(int xx = 2;xx < 2+n_river_cards;xx++) */
/* all_cards[xx] = river_cards[xx-2]; */
int p_hand = overallp(all_cards, n_total_cards, stage);
if(!(p_hand == VERY_GOOD || p_hand == GOOD)) /* The Case of Fold */
return -10;/*fold*/
return offensive(stage,all_cards,n_total_cards,self_team_number,dealer);
}
/* Returns true or 1 if the player bluffs atleast twice as more else false oe 0 */
bool is_bluffsMore(short int team_number)
{
int rise_counter=1;
int bluff_counter=1;
for(int xx = 1;xx<=6;xx++)
for(int yy = 1;yy<5;yy++)
for(int zz=1;zz<=round_number[yy];zz++)
{
if(players_data_move[xx][yy][zz] == RISE)
rise_counter++;
if(players_data_move[xx][yy][zz] == BLUFF)
bluff_counter++;
}
if(rise_counter*2 <= bluff_counter)
return true;
else
return false;
}
int get_minimum_raise(short int stage,short int team_number,short int dealer)
{
if(stage == 5)
return 0;
int cur_round=round_number[stage];
int cur_player=team_number-1;
int cur_stage = stage;
cout << "nStart Round = " << cur_round;
while(cur_round >= 0)
{
if(cur_player == 0)cur_player=6;
if(cur_player == dealer)cur_round--;
if(cur_round == 0)
{
cur_stage--;
cur_round=round_number[cur_stage];
}
11. cout << "nCur Player = " << cur_player << " cur_stage = " << cur_stage << "
cur_round = " <<cur_round;
cout << "nPot Money = " << pot_money[cur_player][cur_stage][cur_round];
cout << "nRaise = " << (players_data_bet[cur_player][cur_stage][cur_round]-
pot_money[cur_player][cur_stage][cur_round]);
cout << "nRise Amounts = " <<
players_data_bet[cur_player][cur_stage][cur_round];
if(players_data_move[cur_player][cur_stage][cur_round] == RISE)
{
cout << "nFinally Rise = " <<
players_data_bet[cur_player][cur_stage][cur_round]-
pot_money[cur_player][cur_stage][cur_round];
if(players_data_bet[cur_player][cur_stage][cur_round]-
pot_money[cur_player][cur_stage][cur_round] == 0 ||
players_data_bet[cur_player][cur_stage][cur_round]-pot_money[cur_player][cur_stage][cur_round]
== 5)
return 10;
//getch();
return (players_data_bet[cur_player][cur_stage][cur_round]-
pot_money[cur_player][cur_stage][cur_round]);
}
cur_player--;
}
return 0;
}
/* Returns your rank on calling */
short int get_rank(int self_team_number)
{
short int rank=6;
for(int xx = 1;xx<=6;xx++)
{
if(xx == self_team_number)
continue;
if(players[xx].money_remaining <=players[self_team_number].money_remaining)
rank--;
}
return rank;
}
/* Sets the value of all elements in Array p_ratio as 0 */
void set_p_ratio()
{
for (int xx=0;xx<6; xx++)
p_ratio[xx]=0;
}
/* Sets the value of all elements in Array reaction_ratio as 0 */
void set_reaction_ratio()
12. {
for (int xx=0;xx<=4; xx++)
reaction_ratio[xx]=0;
}
/* Sets the value of all elements in Array players_folded as false */
void set_player_folded()
{
for(int xx=1;xx<=6;xx++)
players_folded[xx] = false;
}
/* Returns 1 or "true" , if our first turn, else returns 0 or "false" */
bool is_FirstTurn(short int dealer, short int self_team_number)
{
int s_pos = dealer+1;
while(s_pos != self_team_number && !(s_pos == 7 && self_team_number == 1))
{
if(s_pos == 7)
s_pos = 1;
if(players_folded[s_pos] == false)
return false;
s_pos++;
}
return true;
}
/* Function Returns the p_value */
/* VERY_GOOD 5 */
/* GOOD 4 */
/* AVG 3 */
/* BAD 2 */
/* VERY_BAD 1 */
short int checkPattern_p(int action,int reaction, int stage ,int team,int detail = LOW)
{
/* Action :: What the other opponent Do */
/* Reaction :: What this team does for the given action */
/* Stage :: Stage for which data is required */
/* Team :: Team number for which the data is required */
/* Detail :: How much deatil to check the Patter */
/* HIGH - Check exact match */
/* LOW - Ignore Stage */
/* Set p_ratio array as 0 */
set_p_ratio();
/* Declare the Array to store CheckPattern */
short int max;
13. /* Read the CheckPattern File and save it in the Array */
FILE *file;
file = fopen(CHECKPATTERN_FILE,"rb");
if(file != NULL)
{
fread(checkPattern,sizeof(int)*6*5*4*3*7,1,file);
fclose(file);
}
if (detail == LOW)
{
max = 0;
for(int xx = 1;xx<=5;xx++) /* For What P Value */
{
p_ratio[xx] = checkPattern[xx][action][reaction][stage][team];
if(checkPattern[max][action][reaction][stage][team] <=
checkPattern[xx][action][reaction][stage][team])
max = xx;
}
return max;
}
else
{
max = 0;
for(int xx=1; xx<=5; xx++) /* For What P-Value */
for(int zz = 0; zz < 4;zz++) /* For Any Stage */
{
p_ratio[xx] = checkPattern[xx][action][reaction][zz][team];
if(checkPattern[max][action][reaction][zz][team] <=
checkPattern[xx][action][reaction][zz][team])
max = xx;
}
return max;
}
}
/* Function Returns an Action */
/* RISE :: 3 */
/* FOLD :: 2 */
/* CALL :: 1 */
/* BLUFF :: 4 */
/* It is based on priority */
short int checkPattern_action(int p_value,int action, int stage ,int team,int detail = LOW)
{
/* p_value :: P_Value for which the reaction is reqd */
/* Action :: What the other opponent Do */
/* Reaction :: What this team does for the given action */
/* Stage :: Stage for which data is required */
/* Team :: Team number for which the data is required */
14. /* Detail :: How much deatil to check the Patter */
/* HIGH - Check exact match */
/* LOW - Ignore Stage */
/* Declare the Array to store CheckPattern */
/* Set p_ratio array as 0 */
set_reaction_ratio();
short int max;
/* Read the CheckPattern File and save it in the Array */
FILE *file;
file = fopen(CHECKPATTERN_FILE,"rb");
if(file!=NULL)
{
fread(checkPattern,sizeof(int)*6*5*4*3*7,1,file);
fclose(file);
}
if (detail == LOW)
{
max = 0;
for(int xx = 0;xx<4;xx++) /* For What Reaction */
{
reaction_ratio[xx] = checkPattern[p_value][action][xx][stage][team];
if(checkPattern[p_value][action][max][stage][team] <=
checkPattern[p_value][action][xx][stage][team])
max = xx;
}
return max;
}
else
{
max = 0;
for(int xx=1; xx<=5; xx++) /* For What Reaction */
for(int zz = 1; zz <= 5;zz++) /* For Any Value of P */
{
reaction_ratio[xx] = checkPattern[p_value][action][xx][zz][team];
if(checkPattern[zz][action][max][stage][team] <=
checkPattern[p_value][action][xx][zz][team])
max = xx;
}
return max;
}
}
int catagorize_move(int p_move)
{
15. /* KEY INDEX */
/* RISE :: 3 */
/* FOLD :: 2 */
/* CALL :: 1 */
/* BLUFF :: 4 */
if(p_move == CALL)
return 1;
if(p_move == FOLD)
return 2;
if(p_move == BLUFF)
return 4;
if(p_move == RISE)
return 3;
return 0; /* For error */
}
void analyze_data(int self_team_number,int dealer)
{
/*cout << "n";
for (int xx = 1;xx<=6;xx++)
{
cout <<xx<<" - " << players_hand_card_1[xx];
cout <<" " << players_hand_card_2[xx];
cout << "n";
}*/
r_count=0;
string file_name = "team" ;
string temp_file;
string t_str;
ifstream fin;
ifstream file1;
ifstream file2;
/* Order for Check Pattern :: PValue - Action - Reaction - Stage -Team Number */
//int cumulative_round_count=0;
int stage =1,max_stage;
int move;
int counter;
number_of_folds=0;
/* Get all the Data from the Help Files into the two arrays declared above */
/* Read the CheckPattern File */
cout << "nCheck Pattern Read Start";
FILE *file;
file = fopen(CHECKPATTERN_FILE,"rb");
if(file != NULL)
16. {
fread(checkPattern,sizeof(int)*6*5*4*3*7,1,file);
fclose(file);
}
//cout << "nCHECKPATTERN = " << checkPattern[2][2][2][2][2];
cout << "n Check Pattern read complete";
/* Read all the river Cards from the Help Files */
fin.open(RIVER_CARDS,ios::in);
fin >> t_str;
cout << "nRiver Card Read Start";
while(!fin.eof())
{
river_cards[r_count++]=atoi(t_str.c_str());
fin >>t_str;
}
fin.close();
cout << "nRiver Card read completenRIVER CARDS :: ";
for(int mm=0;mm<r_count;mm++)
cout << river_cards[mm] << " ";
/* This File contains the number of rounds played at each stage in the current Deal */
fin.open("Round_Counts.txt",ios::in);
/* Set player_folded array to False */
set_player_folded();
number_of_folds=0;
/* Read all the Round Counts to an Array */
fin >> t_str;
//round_number[stage++]=atoi(t_str.c_str());
while (!fin.eof())
{
round_number[stage++]=atoi(t_str.c_str());
fin >>t_str;
}
fin.close();
cout << "n Read Round Numbers complete, stage = " << stage << "n ROUND NUMBERS :: ";
for(int mm=1;mm<stage;mm++)
cout << round_number[mm] << " ";
max_stage = stage;
//cout << "nSTAGE = " << stage;
/* Read all the opponent moves and Bets from Help Files */
/*for(int xx = 1,yy=0;xx<=6;xx++)
{
stage=0;
//cumulative_round_count = 0;
counter = round_number[stage];
temp_file = (char)(xx + 48);
file1.open((string)(file_name + "_move.txt"),ios::in);
file2.open((string)(file_name + "_bet.txt"),ios::in);
17. yy = 0;
while(!file1.eof())
{
file1 >> players_data_move[xx][round_number[stage]-counter][yy];
if(players_data_move[xx][round_number[stage]-counter][yy] == FOLD)
{
players_folded[xx]= true;
number_of_folds++;
}
file2 >> players_data_bet[xx][round_number[stage]-counter][yy];
counter--;
if(counter == 0)
{
yy=0;
//cumulative_round_count = cumulative_round_count + round_number[stage];
stage++;
counter = round_number[stage];
}
yy++;
}
file1.close();
file2 >> players_hand_card_1[xx];
file2 >> players_hand_card_2[xx];
file2.close();
stage++;
}
*/
for(int xx = 1;xx<=6;xx++)
{for(int yy = 1;yy<5;yy++)
{for(int zz=1;zz<=round_number[yy];zz++)
{if(players_data_move[xx][yy][zz] == FOLD)
{
players_folded[xx]=true;
number_of_folds++;
}}}}
cout << "nAnalyze Fold Data Complete";
for(int xx=1;xx<=6;xx++)
cout << xx<<":"<<players_folded[xx] << " ";
players_hand_card_1[self_team_number] = players[self_team_number].handCard1;
players_hand_card_2[self_team_number] = players[self_team_number].handCard2;
//getch();
//cout << "nWILL IT GO THERE ? :O ";
if(is_show_down == false)/* If the Stage is not ShowDown , we dont have to analyze the
Data. Just store them in Arrays */
return ;
stage = 5;
//cout << "nCOMES HERE!!!! :D ";
/* Calculate the P-Values of each player at every round */
// int preflop_river_cards[5];//Can use this array for sending to the p_value Function //
int all_cards[7];
18. for(int yy = 2;yy < 2+r_count;yy++)
all_cards[yy] = river_cards[yy-2];
cout << "nCalculating All P Values Started";
for(int xx = 1; xx<=6 ; xx++)
{
all_cards[0] = players_hand_card_1[xx];
all_cards[1] = players_hand_card_2[xx];
/* Preflop */
//if(max_stage >= 1)
player_p_values[xx][1] = overallp(all_cards,2,1);
//cout << "n Calculated First pValue";
/* Flop */
//if(max_stage >= 2)
if(stagePlayed[2] == true)
player_p_values[xx][2] = overallp(all_cards,5,2);
//cout << "n Calculated Second pValue";
/* Fourth Street */
//if(max_stage >= 3)
if(stagePlayed[3] == true)
player_p_values[xx][3] = overallp(all_cards,6,3);
//cout << "n Calculated Third pValue";
/* Fifth Street */
//if(max_stage >= 4)
if(stagePlayed[4] == true)
player_p_values[xx][4] = overallp(all_cards,7,4);
//cout << "n Calculated Fourth pValue";
}
/* All data has now been stored in the required arrays */
cout << "nAll PValues Calculated";
for(int xx=1;xx<=6;xx++)
{
cout << "nPlayer - " << xx << "n";
for(int yy=1;yy<=4;yy++)
cout << player_p_values[xx][yy] << " ";
}
//getch();
/* Start analyzing from the Dealer */
int current_round = 0;
int number_of_rise = 0;
int number_of_call = 0;
int number_of_fold = 0;
/* Loop to Analyze the Data Stored in all Array */
int loop_counter = 0; /* Counter for position in current Round */
19. int loop_stage = 0; /* Counter for Current Stage */
int loop_start = dealer+3; /* Counter for Player Number */
int loop_pot_money = 10; /* Stores the Money in Pot for the Current Stage */
int player_bet;
int player_move;
bool isBluff; /* 1-Bluff 0-Not Bluff */
int player_action = (int)'A'; /* What other player did, based on priority */
while(loop_stage != 5)
{
if(loop_start >= 7)
loop_start = loop_start-6;
if(loop_start == dealer+1)
loop_counter++;
if(loop_counter == round_number[loop_stage]) /* Stage Over */
{
loop_stage++;
loop_counter=0;
loop_pot_money = 0;
player_action = (int)'A';
}
player_bet = players_data_bet[loop_start][loop_stage][loop_counter] -
loop_pot_money;
pot_money[loop_start][loop_stage][loop_counter] = loop_pot_money;
if(player_bet <=0)
player_bet = 0;
loop_pot_money = loop_pot_money + player_bet;
player_move = players_data_move[loop_start][loop_stage][loop_counter];
if(player_move > player_action && player_action != FOLDED)
player_action = player_move;
if(player_bet != 0 && (player_p_values[loop_start][loop_stage] == BAD ||
player_p_values[loop_start][loop_stage] == VERY_BAD || player_p_values[loop_start][loop_stage]
== AVG))
{
isBluff = true;
player_move = BLUFF;
}
else
isBluff = false;
checkPattern[player_p_values[loop_start][loop_stage]][catagorize_move(player_action)][ca
tagorize_move(player_move)][loop_stage][loop_start]++;
if(player_move == BLUFF)
checkPattern[player_p_values[loop_start][loop_stage]][catagorize_move(player_action)][RI
SE][loop_stage][loop_start]++;
loop_start++;
}
/* Write The CheckPattern back to File */
cout << "nWRITE CHECKPATTERN FILE STARTED!";
file = fopen(CHECKPATTERN_FILE,"wb");
20. fwrite(checkPattern,sizeof(int)*6*5*4*3*7,1,file);
fclose(file);
cout << "nWRITE COMPLETE";
remove("bluff.txt");
//getch();
}
/* this fnctn shud be called when need to play offensive and it will return the amount of bet */
int offensive(int stage,int *cards,int total,int teamno,int dealer)
{
/* initialize random seed: */
/* initialization for rand function */
srand ( time(NULL) );
int phand,rise = get_minimum_raise(stage,teamno,dealer);/* rise = minimum available raise
*/
phand = overallp(cards,total,stage);
cout << "nP Hand = " << phand;
//getch();
int temp = is_FirstTurn(dealer,teamno);/* checking for first turn */
//cout << "n First Turn True/False = " << temp;
if(temp == 0)/* opponent raised or called */
{
/* is p vgud */
if(phand == 5)
{
int check = anyoppraisehigh(stage,round_number[stage],dealer +
1,teamno,dealer);/* check if opp raised high */
if(check == 1)
{
/* check stage */
if(stage == 1)
{
int choice = rand() % 4 + 1;
if((choice == 1)||(choice == 2)||(choice == 3))
return 0;/* call */
else
{
/* high raise fnctn */
int bet = bluff(rise,4);/* 4 for high raise fnctn */
return bet;
}
}
else if(stage == 2)
{
int choice = rand() % 4 + 1;
if((choice == 1)||(choice ==2))
{
21. /* high raise fnctn */
int bet = bluff(rise,4);
return bet;
}
else
return 0;
}
else if(stage == 3)
{
int choice = rand() % 4 + 1;
if(choice ==1)
return 0;
else
{
int bet = bluff(rise,4);/*high raise fnctn*/
return bet;
}
}
else/*last stage */
{
/* high raise fntn */
int bet = bluff(rise,4);
return bet;
}
}
else/* low raise or call */
{
/* stage check */
if(stage == 4)
{
/* high raise fnctn */
int bet = bluff(rise,4);
return bet;
}
else if(round_number[stage] == 1)/*new card opened */
{
int choice = rand() % 2 + 1;
if(choice == 1)
return 0;/* call */
else
{
int bet = bluff(rise,4);
return bet;
}
/* high raise fntn */
}
else/*no new card */
{
FILE *pt;
int bluffcounter = 4;
22. pt = fopen("bluff.txt","rb");
if(pt != NULL)/* prev raise */
{
fscanf(pt,"%d",&bluffcounter);
fclose(pt);
if(bluffcounter <4)
{
int bet = bluff(rise,4);
return bet;
}
}
else
{
int choice = rand() % 2 +1;
if(choice == 1)
return 0;/* call */
else
{
/* high raise fntn */
int bet = bluff(rise,4);
return bet;
}
}
}
}
}
/* p is gud */
if(phand == 4)
{
//cout << "n Case of Pgood";
int value=1;
int check = anyoppraisehigh(stage,round_number[stage],dealer +
1,teamno,dealer);/* check if opp raised high */
//cout << "nDid Any opponent Raise High? " << check;
if(check == 1)
{
int temp = teamno-1;
int cur_round = round_number[stage];
do
{
if(temp == 0)
temp = 6;
if(temp == dealer)
cur_round--;
if(cur_round <=0)
{value = 0;break;}
if(players_data_move[temp][stage][cur_round] == RISE)
{
23. int rise = players_data_bet[temp][stage][cur_round]
- pot_money[temp][stage][cur_round];
if(rise > 50)
{
int faltu;
faltu = is_bluffsMore(temp);
if(faltu==0)
value = faltu;
}
}
temp--;
}while(temp != teamno);
if(value == 0)
{
int pla = 6 - number_of_folds;/* gets no of players playing
on the table */
if(pla <= 3)/* check pattern fntn */
{
int zz=dealer+1;
int ppos=0;
int still_in_play[3]={0};
do
{
if(zz==7)
zz=1;
if(players_folded[zz] == false)
still_in_play[ppos++]=zz;
zz++;
}while(zz != dealer && !(zz==7 && dealer==1));
if(ppos==2)
{still_in_play[ppos++]=0;}
return
getMove(stage,phand,still_in_play,teamno,dealer);
}
else
{
int count = 0;
int temp=teamno-1;
int still_in_play[3]={0};
int zz=0;
int cur_round = round_number[stage];
do
{
int value;
if(temp==0)
temp = 6;
if(temp == dealer)
24. cur_round--;
if(cur_round <=0)
break;
if((players_data_move[temp][stage][cur_round] ==
CALL)&&(players_data_bet[temp][stage][cur_round] - pot_money[temp][stage][cur_round] > 50))
value = is_bluffsMore(temp);
if(value == 0)
{
count++;
still_in_play[zz++]=temp;
}
temp--;
}while(temp!=teamno);
still_in_play[zz++]=teamno;
if(zz==3)
{still_in_play[zz++]=0;}
pla = count; /* no of players who raises high and
doesn;t bluff */
if(pla <= 2)
return
getMove(stage,phand,still_in_play,teamno,dealer);
else /* check pattern */
{
int choice = rand() % 2 + 1;
if(choice == 1)
return 0;
else
return -10;/* fold */
}
}
}
else/* means opponent bluffs a lot */
{
int players = 6 - number_of_folds;/* no of players playing at
the table */
if(players <= 3)
{
int zz=dealer+1;
int ppos=0;
int still_in_play[3]={0};
do
{
if(zz==7)
zz=1;
if(players_folded[zz] == false)
still_in_play[ppos++]=zz;
zz++;
}while(zz != dealer && !(zz==7 && dealer==1));
if(ppos==2)
25. {still_in_play[ppos++]=0;}
return
getMove(stage,phand,still_in_play,teamno,dealer);
/* check pattern */
}
else
{
return 0;/*call*/
}
}
}
else /* low call or call*/
{
int players = 6 - number_of_folds;/* no of players laying at the table
*/
//cout << "nReached the case of chek = 0, players = "<<players;
if(players <= 3) /*-----------editing left-----------*/
{
int zz=dealer+1;
int ppos=0;
int still_in_play[3]={0};
do
{
if(zz==7)
zz=1;
if(players_folded[zz] == false)
still_in_play[ppos++]=zz;
zz++;
}while(zz != dealer && !(zz==7 && dealer==1));
if(ppos==2)
{still_in_play[ppos++]=0;}
return getMove(stage,phand,still_in_play,teamno,dealer);
/* check pattern */
}
else
{
cout << "nPlayers Greater than 3";
int lowcheck=0,count=0;
int temp = teamno-1;
if(temp == 0 )
temp = 6;
int still_in_play[7]={0};
int zz =0;
int cur_round = round_number[stage];
cout << "ncur_round = " << cur_round;
do
{
if(temp == 0)