当前位置:   article > 正文

基于人工智能算法实现AI足球比赛_ai足球源码

ai足球源码

相关资料:http://t.csdn.cn/1XSne
实现目标:
在这里插入图片描述
在这里插入图片描述

目前进展:
在这里插入图片描述

在这里插入图片描述
主要用到就是射门概率那块,用随机数+能力值来控制

#include <iostream>
#include "footballManager.h"
FootballManager::FootballManager()
{
	this->showMenu();
};
//FootballManager::
void FootballManager::exitSystem()
{
	system("cls");
	cout << "已成功退出,欢迎下次使用" << endl;
	system("pause");
}
void FootballManager::showMenu()
{
	cout << "-----------------------------------------------------" << endl;
	cout << "      英超联赛正在进行中,我是本场解说本泽马        " << endl;
	cout << "**********        1.开始本场比赛           **********" << endl;
	cout << "**********        2.查看英超积分排行榜     **********" << endl;
	cout << "**********        3.清空比赛记录           **********" << endl;
	cout << "**********        0.退出比赛程序           **********" << endl;
	cout << "-----------------------------------------------------" << endl;
	cout << endl;
}
//初始化球员姓名、能力
void FootballManager::initPlayer() {
	this->player.playerName = "Cristiano Ronaldo";
	this->player.finsh = 95;
	this->player.number = 7;
	this->player.pass = 96;
	this->player.speed = 97;
}
//确定阵容
void FootballManager::detmineLineup()
{
	cout << "本次双方阵容" << endl;
	cout << this->player.number << "号" << this->player.playerName << endl;
}
//比赛进行
void FootballManager::getScore()
{
	int time = this->courtLength;
	while(time)
	{
		time -= this->player.speed - 90;
		if (time == this->courtLength - rand() % 30)
		{
			cout << this->player.playerName << " 准备射门了" << endl;
			break;
		}
	}
	this->player.shot();
}
void FootballManager::changeBall()
{
	cout << this->player.playerName << " 中路拿球" << endl;
	cout << this->player.playerName << " 快速带球" << endl;
	cout << this->player.playerName << " 全力冲刺" << endl;
}
//开始比赛
void FootballManager::startGame()
{
	this->initPlayer();
	this->detmineLineup();
	this->changeBall();
	this->getScore();
}
FootballManager::~FootballManager()
{

};
  • 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
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
#pragma once
#include <iostream>
#include "player.h"
using namespace std;
class FootballManager
{
public:
	int courtLength = 105, courtWidth = 68;
	Player player;
	FootballManager();
	//交互界面
	void showMenu();
	//退出
	void exitSystem();
	//球员初始化
	void initPlayer();
	//确定阵容(初始化)
	void detmineLineup();
	//比赛进行
	void getScore();
	//开球
	void startGame();
	//球权
	void changeBall();
	~FootballManager();
};
  • 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
#pragma once
#include <iostream>
using namespace std;
class Player
{
public:
	Player();
	string playerName;
	int number;
	int speed;
	int finsh;
	int pass;
	void shot();
	~Player();
};
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
#include "footballManager.h"
#include <iostream>
using namespace std;

int main()
{
	FootballManager fifa;
	int choice = 0;
	while (true)
	{
		cin >> choice;

		switch (choice)
		{
		case 1:
			fifa.startGame();
			break;
		case 2:
			break;
		case 3:
			break;
		case 0:
			fifa.exitSystem();
			return 0;
			break;
		default:
			system("cls");
			break;

		}
	}
	system("pause");
	return 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
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/340214
推荐阅读
相关标签
  

闽ICP备14008679号