Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by hugobpontes · Sep 28, 2020 at 10:52 AM · listsclassesfootball

Random Fixture Generation

Hello. I want to create a Sports simulator, in this case a football simulator. I have a PremierLeague list of 6 teams , which each team being an instance of a custom class, Team At start I add the 6 teams to the list :

  PremierLeague.Add(new Team { TeamName = "Liverpool", Attack = 90, Midfield = 85, Defence = 89, Points = 8, GamesPlayed = 0, GoalDifference = 0 });
         PremierLeague.Add(new Team { TeamName = "Manchester Utd", Attack = 81, Midfield = 80, Defence = 74, Points = 7, GamesPlayed = 0, GoalDifference = 0 });
         PremierLeague.Add(new Team { TeamName = "Tottenham", Attack = 85, Midfield = 80, Defence = 80, Points = 10, GamesPlayed = 0, GoalDifference = 0 });
         PremierLeague.Add(new Team { TeamName = "Leicester City", Attack = 81, Midfield = 78, Defence = 76, Points = 2, GamesPlayed = 0, GoalDifference = 1 });
         PremierLeague.Add(new Team { TeamName = "West Ham", Attack = 76, Midfield = 74, Defence = 72, Points = 2, GamesPlayed = 0, GoalDifference = 2 });
         PremierLeague.Add(new Team { TeamName = "Aston Villa", Attack = 70, Midfield = 71, Defence = 70, Points = 2, GamesPlayed = 0, GoalDifference = -1 });

I have already created a function to sort them by points.

After that, I created a new class, Match that has 4 parameters: 1 home Team 1 away team and their respective int scores:

 public class Match
 {
     public Team HomeTeam;
     public Team AwayTeam;
     public int HomeGoals;
     public int AwayGoals;
 
 }

I have created a function that assigns scores result based on the team stats.

This all works as expected, but what I need is for the game to generate Matchups between all teams in the league. I thought I should create another Matchweek class:

 public class Matchweek //length = n. of teams / 2
 {
     public Match Match1;
     public Match Match2;
     public Match Match3;
 
 }

that would consist of 3 (6/2) matches. What I can't figure out how to do is how to assign 3 matches to 10 (2*(6-1)) Matchweeks so that a new list of Matchweeks would feature 10 matchweeks containing all possible matchups between the teams in the league and a reverse fixture (inverting who is away and who is playing at home)

I've thought about this quite a bit and can't think of a solution but maybe my programming skills are too limited to achieve this as of yet so I wanted to know if anybody has some suggestions to achieve this? Thanks in advance

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

135 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Trouble with Add-ing and Retrieving from a List of Custom Class 1 Answer

UNITYSCRIPT - Class's and Instances - Functions/Methods - Correct Usage 0 Answers

How to search a certain variable in a list of a created class (C#) 1 Answer

Trying to make a simple quest system, but i stuck how to do 0 Answers

Save an array with custom classes 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges