Where to start.

Just asking the c++ gurus out there if my idea will work. My goal is to create a system to compare football players. I am a coach and would like to make a program that I can create arrays for 44 players. My goal is to be able to see mismatches by comparing my teams 22 players vs their 22 players.
What is an efficient way of doing this. I am just looking for ideas.
I would like to just start out with 4 players and compare corners vs receivers.
The array would look something like this.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

#define WIDTH 4
#define HEIGHT 22

using namespace std;

int corner1 [HEIGHT] [WIDTH];
int receiver1 [HEIGHT] [WIDTH];
int result [HEIGHT] [WIDTH];
int main()
{
    
}



Now I want to assign array 0 to be speed, 1 to be acceleration, 3 to be size, 4 to be stamina. Then I want to subtract the arrays and put the values in results.
IF corner1 = 5 7 10 4
if receiver1 = 6 5 7 8
then
result = -1 2 3 -4

I just don't know how to subtract the values in the arrays and put them in result.
Last edited on
how about using a structure instead?

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
#define TEAMSIZE 22

//Define a player
structure player
{
    int speed;
    int acceleration;
    int size;
    int stamina;
};

//This function will return the difference in the players attributes.
player ComparePlayers(player a, player b)
{
    player result;
    result.speed = a.speed - b.speed;
    result.acceleration = a.acceleration - b.acceleration;
    result.size = a.size - b.size;
    result.stamina = a.stamina - b.stamina;

    return result;
}

int main()
{
    //Create 2 teams:
    player Team1[TEAMSIZE];
    player Team2[TEAMSIZE];

    //Now compare them like this: 
    player difference = ComparePlayers(Team1[0] , Team2[0]);


}
Last edited on
I have created the positions and am wondering how do I assign values to each player for both teams.


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
#include <iostream>
#define TEAMSIZE 22

using namespace std;

struct player
{
    int speed;
    int acceleration;
    int size;
    int stamina;
    
    
} qb,olt,ort,oe,rb,te,wr1,wr2,rb,c,wr3,Dt,Ilb,olbr,olbl,fs,ss,cr,cl,dt2 de,de2;

player ComparePlayers(player a, player b)
{
    player result;
    result.speed = a.speed - b.speed;
    result.acceleration = a.acceleration - b.acceleration;
    result.size = a.size - b.size;
    result.stamina = a.stamina - b.stamina;

    return result;
}


int main()
{
    //Create 2 teams:
    player Team1[TEAMSIZE];
    player Team2[TEAMSIZE];

    //Now compare them like this:
    player difference = ComparePlayers(Team1[0] , Team2[0]);
    
    Cout << "This is how the players stack up" << player difference <<;
    


}


Would it be easier to create two structures struct myplayers and struct oposeplayers. I am confused as to how I assign values to the players on one team only. I am pretty noob to c++. I have only made it to arrays in the tutorial. I got bored so I am really trying to create something I can use. Any assistance would be appreciated.
I was also wondering if I am limited to only having 22 players or can I create more without errors. These position names only work with a team that has a 4 man front. If they have a 5 man front I would like to compare the c vs the ng. Not pretend that the ilb is the ng.
Last edited on
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
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{
	double team[4][22];
	double opTeam[4][22];
	double dif[4][22]
	string stat[4] = {"speed", "acceleration", "size", "stamina"};
	string pos[22];
	ifstream position;
	ofstream difference;

	position.open("positions.txt");
	for(int fill = 0; fill < 22; fill++)
	{
		getline(position, pos[fill];
	}
	position.close();

	for(int fill = 0; fill < 22; fill++)
	{
		for(int statistic = 0; statistic < 4; statistic++)
		{
			cout << "Enter your " << pos[fill] << " " << stat[statistic] << ":  ";
			cin >> team[statistic][fill];
		}
	}
	
	for(int fill= 0; fill < 22; fill++)
	{
		for(int statistic = 0; statistic < 4; statistic++)
		{
			cout << "Enter op team " << pos[fill] << " " << stat[statistic] << ":  ";
			cin >> opTeam[statistic][fill];
		}
	}

	for(int fill = 0; fill < 22; fill++)
	{
		for(int statistic = 0; statistic < 4; statistic++)
		{
			dif[statistic][fill] = opTeam[statistic][fill] - team[statistic][fill];
		}
	}	

	difference.open("difference.txt");
	for(int fill = 0; fill < 22; fill++)
	{
		difference = pos[fill];
		for(int statistic = 0; statistic < 4; statistic++)
		{
			difference << endl;
			difference << stat[statistic] << ":  " << dif[statistic][fill];
		}
		difference << endl;
	}
	difference.close();

return 0;
}


Your "position.txt" file should have the position and an enter.
Ex:
qb
olt
ort
etc.

I haven't compiled this, but it should work. To make "position.txt" just use notepad and put your positions in and save it. Calling it "position.txt" makes it a text file. Don't use quotes.

NOTE: When this program runs, it doesn't stop, so give yourself the time you'll need to run it. Positive numbers in difference.txt are the op team advantages and negative are disadvantages. Reverse opTeam and team in line 46 to negate this.
Last edited on
If you are comparing ints, then you can change the double to an int at will.
Topic archived. No new replies allowed.