【官方】英超模拟器V1.0.1
GeorgeDeng · · 休闲·娱乐
英超模拟器V1.0.1来啦!
原版(V1.0)
比预计更新还要快。这个版本更新了:
-
随机数能力值。
-
输出净胜球。
-
将非自己球队的比赛的随机数加大,避免出现
0 分的情况。 -
加入未完工的旁观者模式。雏形已经完成,接下来就是细节(因为会死循环)。
代码仍旧由 deepseek 稍加调试后才正式发布的,添加内容由作者写,deepseek 只负责调试。
game code:(c++) 或直接下载exe,密码:gcyr。
如果下载 exe 途中出现任何问题,一直保留即可。
#include <iostream>
#include <cstdio>
#include <ctime>
#include <random>
#include <windows.h>
#include <algorithm>
#include <iomanip> // 用于格式化输出
using namespace std;
int vis[25]; // 全局 vis 数组
struct node {
string name;
int ablity;
int point;
int goal, lose;
int train_remain;
} team[25];
int cli_team = 0;
int oponment;
bool cmp(node a, node b) {
if (a.point != b.point) return a.point > b.point;
if (a.goal - a.lose != b.goal - b.lose) return a.goal - a.lose > b.goal - b.lose;
if (a.goal != b.goal) return a.goal > b.goal;
return a.ablity > b.ablity;
}
void print_board() {
node temp_team[25];
for (int i = 1; i <= 20; i++) {
temp_team[i] = team[i];
}
sort(temp_team + 1, temp_team + 1 + 20, cmp);
// 使用 setw 设置场宽
cout << left << setw(5) << "Rank"
<< setw(20) << "Team"
<< setw(10) << "Points"
<< setw(10) << "Goals"
<< setw(10) << "Lose"
<< setw(10) << "GD" << endl;
for (int i = 1; i <= 20; i++) {
cout << left << setw(5) << i
<< setw(20) << temp_team[i].name
<< setw(10) << temp_team[i].point
<< setw(10) << temp_team[i].goal
<< setw(10) << temp_team[i].lose
<< setw(10) << (temp_team[i].goal - temp_team[i].lose);
if (temp_team[i].name == team[cli_team].name) {
cout << " (My team)";
}
cout << endl;
}
system("pause");
system("cls");
}
void play_game(int round) {
if (round <= 19) {
oponment = rand() % 20 + 1;
while (vis[oponment] == 1 || oponment == cli_team) {
oponment = rand() % 20 + 1;
}
vis[oponment]++;
cout << "Your oponment: " << team[oponment].name << endl;
system("pause");
int result = rand() % (team[cli_team].ablity + team[oponment].ablity);
if (result < team[cli_team].ablity) {
cout << "You win by ";
int my_points = rand() % 10;
while (my_points == 0) my_points = rand() % 10;
int you_points = rand() % 4;
while (you_points >= my_points) {
you_points = rand() % 4;
}
cout << my_points << '-' << you_points << "!" << endl;
team[cli_team].point += 3;
team[cli_team].goal += my_points;
team[cli_team].lose += you_points;
team[oponment].goal += you_points;
team[oponment].lose += my_points;
system("pause");
system("cls");
} else if (result == team[cli_team].ablity) {
cout << "You draw by ";
int my_points = rand() % 10;
cout << my_points << '-' << my_points << "!" << endl;
team[cli_team].point += 1;
team[oponment].point++;
team[cli_team].goal += my_points;
team[cli_team].lose += my_points;
team[oponment].goal += my_points;
team[oponment].lose += my_points;
system("pause");
system("cls");
} else {
cout << "You lose by ";
int my_points = rand() % 10;
while (my_points == 0) my_points = rand() % 10;
int you_points = rand() % 4;
while (you_points >= my_points) {
you_points = rand() % 4;
}
swap(my_points, you_points);
cout << my_points << '-' << you_points << "!" << endl;
team[oponment].point += 3;
team[cli_team].goal += my_points;
team[cli_team].lose += you_points;
team[oponment].goal += you_points;
team[oponment].lose += my_points;
system("pause");
system("cls");
}
} else {
oponment = rand() % 20 + 1;
while (vis[oponment] == 2 || oponment == cli_team) {
oponment = rand() % 20 + 1;
}
vis[oponment]++;
cout << "Your oponment: " << team[oponment].name << endl;
system("pause");
int result = rand() % (team[cli_team].ablity + team[oponment].ablity);
if (result < team[cli_team].ablity) {
cout << "You win by ";
int my_points = rand() % 10;
while (my_points == 0) my_points = rand() % 10;
int you_points = rand() % 4;
while (you_points >= my_points) {
you_points = rand() % 4;
}
cout << my_points << '-' << you_points << "!" << endl;
team[cli_team].point += 3;
team[cli_team].goal += my_points;
team[cli_team].lose += you_points;
team[oponment].goal += you_points;
team[oponment].lose += my_points;
system("pause");
system("cls");
} else if (result == team[cli_team].ablity) {
cout << "You draw by ";
int my_points = rand() % 10;
cout << my_points << '-' << my_points << "!" << endl;
team[cli_team].point += 1;
team[oponment].point++;
team[cli_team].goal += my_points;
team[cli_team].lose += my_points;
team[oponment].goal += my_points;
team[oponment].lose += my_points;
system("pause");
system("cls");
} else {
cout << "You lose by ";
int my_points = rand() % 10;
while (my_points == 0) my_points = rand() % 10;
int you_points = rand() % 4;
while (you_points >= my_points) {
you_points = rand() % 4;
}
swap(my_points, you_points);
cout << my_points << '-' << you_points << "!" << endl;
team[oponment].point += 3;
team[cli_team].goal += my_points;
team[cli_team].lose += you_points;
team[oponment].goal += you_points;
team[oponment].lose += my_points;
system("pause");
system("cls");
}
}
}
void play_others() {
bool local_vis[25] = {false}; // 使用局部 vis 数组
for (int i = 1; i <= 20; i++) {
if (i == cli_team || i == oponment) continue;
if (local_vis[i]) continue;
local_vis[i] = true;
int opn = rand() % 20 + 1;
while (local_vis[opn] || opn == cli_team || opn == oponment) {
opn = rand() % 20 + 1;
}
local_vis[opn] = true;
int local_result = rand()%(team[i].ablity+team[opn].ablity);
if (local_result<team[i].ablity) {
team[i].point += 3;
int add1 = rand() % 10 + 1;
int add2 = rand() % add1;
team[i].goal += add1, team[i].lose += add2;
team[opn].goal += add2, team[opn].lose += add1;
} else if (local_result==team[i].ablity) {
team[i].point += 1;
team[opn].point += 1;
int add1 = rand() % 10 + 1;
int add2 = add1;
team[i].goal += add1, team[i].lose += add2;
team[opn].goal += add2, team[opn].lose += add1;
} else {
team[opn].point += 3;
int add1 = rand() % 10 + 1;
int add2 = rand() % add1;
team[i].goal += add2, team[i].lose += add1;
team[opn].goal += add1, team[opn].lose += add2;
}
}
}
void print_ablity() {
cout << left << setw(20) << "Team_name" << setw(10) << "Team_ablity" << endl;
for (int i = 1; i <= 20; i++) {
cout << left << setw(20) << team[i].name << setw(10) << team[i].ablity << endl;
}
}
void watcher_play_game(int **local_vis2, int round) {
bool local_vis[205];
if (round <= 19) {
for (int i = 1; i <= 20; i++) {
if (local_vis[i]) continue;
local_vis[i] = true;
int opn = rand() % 20 + 1;
while (local_vis[opn] || local_vis2[i][opn] == 1) {
opn = rand() % 20 + 1;
}
local_vis[opn] = true;
local_vis2[i][opn]++, local_vis2[opn][i]++;
cout << team[i].name << " vs. " << team[opn].name << endl;
int local_result = rand() % (team[i].ablity + team[opn].ablity);
if (local_result < team[i].ablity) {
team[i].point += 3;
int add1 = rand() % 10 + 1;
int add2 = rand() % add1;
cout << team[i].name << ' ' << add1 << " - " << add2 << ' ' << team[opn].name << endl;
team[i].goal += add1, team[i].lose += add2;
team[opn].goal += add2, team[opn].lose += add1;
} else if (local_result == team[i].ablity) {
team[i].point += 1;
team[opn].point += 1;
int add1 = rand() % 10 + 1;
int add2 = add1;
cout << team[i].name << ' ' << add1 << " - " << add2 << ' ' << team[opn].name << endl;
team[i].goal += add1, team[i].lose += add2;
team[opn].goal += add2, team[opn].lose += add1;
} else {
team[opn].point += 3;
int add1 = rand() % 10 + 1;
int add2 = rand() % add1;
cout << team[i].name << ' ' << add2 << " - " << add1 << ' ' << team[opn].name << endl;
team[i].goal += add2, team[i].lose += add1;
team[opn].goal += add1, team[opn].lose += add2;
}
}
}
if (round > 19) {
for (int i = 1; i <= 20; i++) {
if (local_vis[i]) continue;
local_vis[i] = true;
int opn = rand() % 20 + 1;
while (local_vis[opn] || local_vis2[i][opn] == 1) {
opn = rand() % 20 + 1;
}
local_vis[opn] = true;
local_vis2[i][opn]++, local_vis2[opn][i]++;
cout << team[i].name << " vs. " << team[opn].name << endl;
int local_result = rand() % (team[i].ablity + team[opn].ablity);
if (local_result < team[i].ablity) {
team[i].point += 3;
int add1 = rand() % 10 + 1;
int add2 = rand() % add1;
cout << team[i].name << ' ' << add1 << " - " << add2 << ' ' << team[opn].name << endl;
team[i].goal += add1, team[i].lose += add2;
team[opn].goal += add2, team[opn].lose += add1;
} else if (local_result == team[i].ablity) {
team[i].point += 1;
team[opn].point += 1;
int add1 = rand() % 10 + 1;
int add2 = add1;
cout << team[i].name << ' ' << add1 << " - " << add2 << ' ' << team[opn].name << endl;
team[i].goal += add1, team[i].lose += add2;
team[opn].goal += add2, team[opn].lose += add1;
} else {
team[opn].point += 3;
int add1 = rand() % 10 + 1;
int add2 = rand() % add1;
cout << team[i].name << ' ' << add2 << " - " << add1 << ' ' << team[opn].name << endl;
team[i].goal += add2, team[i].lose += add1;
team[opn].goal += add1, team[opn].lose += add2;
}
}
}
}
void watcher() {
int **local_vis = new int*[205];
for (int i = 0; i < 205; i++) {
local_vis[i] = new int[205]();
}
for (int i = 1; i <= 19 * 2; i++) {
laodazhouji:
system("cls");
cout << "Round " << i << endl;
Sleep(500);
int op;
cout << "(1) Check all teams' ablity" << endl;
cout << "(2) Check This round's draw & begin this round's match" << endl;
cout << "(3) Check ranking board" << endl;
cout << "(4) exit" << endl;
cin >> op;
if (op == 4) return;
if (op == 3) {
system("cls");
print_board();
goto laodazhouji;
}
if (op == 1) {
system("cls");
print_ablity();
system("pause");
goto laodazhouji;
}
if (op == 2) {
system("cls");
watcher_play_game(local_vis, i);
system("pause");
}
}
for (int i = 0; i < 205; i++) {
delete[] local_vis[i];
}
delete[] local_vis;
}
int main() {
start:
srand(time(NULL));
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cout << "Premier League" << endl;
Sleep(2000);
system("cls");
// 初始化球队
team[1].name = "Liverpool";
team[2].name = "Arsenal";
team[3].name = "Aston Villa";
team[4].name = "Manchester City";
team[5].name = "Manchester United";
team[6].name = "Tottenham Hotspur";
team[7].name = "Newcastle United";
team[8].name = "Chelsea";
team[9].name = "Nottingham Forest";
team[10].name = "Bournemouth";
team[11].name = "Brighton";
team[12].name = "Fulham";
team[13].name = "Brentford";
team[14].name = "Crystal Palace";
team[15].name = "West Ham United";
team[16].name = "Everton";
team[17].name = "Wolverhampton";
team[18].name = "Ipswich";
team[19].name = "Leicester City";
team[20].name = "Southampton";
team[1].ablity = rand() % 101;
team[2].ablity = rand() % 90;
team[3].ablity = rand() % 85;
team[4].ablity = rand() % 70;
team[5].ablity = rand() % 45;
team[6].ablity = rand() % 70;
team[7].ablity = rand() % 65;
team[8].ablity = rand() %68;
team[9].ablity = rand()%68;
team[10].ablity = rand()%62;
team[11].ablity = rand()%60;
team[12].ablity = rand()%60;
team[13].ablity = rand()%60;
team[14].ablity = rand()%57;
team[15].ablity = rand()%60;
team[16].ablity = rand()%57;
team[17].ablity = rand()%57;
team[18].ablity = rand()%55;
team[19].ablity = rand()%52;
team[20].ablity = rand()%50;
for (int i = 1; i <= 20; i++) {
team[i].train_remain = 5; // 初始化训练次数
}
for (int i = 1; i <= 20; i++) {
cout << "(" << i << "):" << team[i].name << endl;
}
cout << "Choose your team:(21 Watch all, but not avliable now)" << endl;
cin >> cli_team;
system("cls");
if (cli_team <= 0 || cli_team > 21) {
cout << "Input Error. Game Over";
system("pause");
return 0;
}
if(cli_team==21){
cout<<"Not avliable now!"<<endl;
system("pause");
system("cls");
goto start;
watcher();
return 0;
}
for (int i = 1; i <= 19 * 2; i++) {
team[cli_team].train_remain = rand() % 6;
laodazhouji:
cout << "Round " << i << ": ";
cout << "Your team: " << team[cli_team].name << endl;
Sleep(500);
cout << "Train remain: " << team[cli_team].train_remain << endl;
Sleep(500);
cout << "Your team ablity: " << team[cli_team].ablity << endl;
Sleep(500);
cout << "Begin Next Game" << endl;
Sleep(500);
cout << "Check the ranking board" << endl;
Sleep(1000);
cout << endl;
cout << "(1): Train" << endl;
cout << "(2): Check the ranking board" << endl;
cout << "(3): Begin next game" << endl;
int op;
cin >> op;
while (op < 1 || op > 3) {
cout << "Input Error, please input it again ";
Sleep(2000);
system("cls");
goto laodazhouji;
}
system("cls");
if (op == 1) {
if (team[cli_team].train_remain == 0) {
cout << "There are no chance to train!" << endl;
Sleep(2000);
system("cls");
goto laodazhouji;
}
team[cli_team].train_remain--;
int win = rand() % 3;
if (win == 1 || win == 2) {
cout << "Train successfully! Team's ability +1!" << endl;
Sleep(2000);
team[cli_team].ablity++;
} else {
cout << "Train unsuccessfully! Team's ability -1!" << endl;
Sleep(2000);
team[cli_team].ablity--;
}
system("cls");
goto laodazhouji;
} else if (op == 2) {
print_board();
goto laodazhouji;
} else if (op == 3) {
play_game(i);
play_others();
}
}
system("cls");
cout << "Season Over" << endl;
Sleep(2000);
cout << "This is the final table:" << endl;
print_board();
return 0;
}
在此声明,@yanziwei88 的文章 三国乱战 是在这篇文章的基础上修改的。请自行辨别