openfootmanager / openfootmanager Goto Github PK
View Code? Open in Web Editor NEWAn open source soccer/football manager game
License: GNU General Public License v3.0
An open source soccer/football manager game
License: GNU General Public License v3.0
Currently the game can only generate databases on-demand for new game sessions. However, I'd like the game to have a default database that it ships with. Something that resembles a real-life soccer database, with slightly modified player names.
This is a huge task to fine tune the teams and players to their accurate representations in real-life, but I'd like to take some time to work on that whenever possible. I guess that more people would appreciate a game with something closer to a real-life database rather than something that is completely random and disconnected from reality. The game would give you the option to use a random database as well, if you wanted to.
In the live game, player stamina is not getting updated. We need to update player Stamina, and factor that into the decision of substituting players.
Club definitions are being automatically generated by web scraping. I can't get team info details from this scraping, so I'm just generating random values for "mu" and "sigma". This can lead to pretty inaccurate details about teams.
We must either manually or randomly tune databases to correspond with actual team performances.
i wonder if you still have passion for this project
im intersted in the live match simulation
i worked on it by myself in my old project , dont you think pygame should be a good choice ?
Create a class to manage the current Game Session. This tracks the current game state and the team that you're currently managing. We can leverage that to create savefiles later on.
Each SimulationEvent must have their own commentaries. For now I'm just using print statements, but I need to use a different approach for Commentaries, so they can be serializable if needed, and displayed in a GUI.
Teams should be able to change formation following some criteria:
Hello,
First, I'm happy to see this new project and hope it will be soon available.
How will you store all the datas of this game (I mean, player's datas, club's datas,...) ? Will you use a database system like Postgresql ?
And will you use maps on this game, for example to locates clubs or stadiums ?
Thanks,
I'm considering using SQLite instead of JSON for in-game database. I'm still deciding over database schema, whether we need to divide data into different .db files, or just use one database with many tables for everything. This is important to create a savefile later on. My ideas for savefiles will go in another issue, but I think if we implement an actual database, we can improve performance to load teams and players.
Another thing I'm considering is to use SQLAlchemy instead of pure SQL. This project uses a lot of dataclasses, so it isn't that bad to convert to SQLAlchemy models.
First thing I need to focus on: get match simulation right.
I've implemented a first attempt at a match sim using what I've learned from eSports Manager, but now I think for soccer I should implement a different approach.
I'm investigating new ways to implement a match sim.
Players are not currently awarded assists. We must implement assistances following the criteria:
As a remediation for teams taking too long to generate and load, I might just add a Loading screen for any time that the game is doing some task that takes a long time to complete. I was thinking about leveraging the Meter widget from ttkbootstrap to use in this loading screen.
Give the user the ability to simulate an entire game without having to click more than once in the Start Match button.
To create a prototype, we must set up a debug mode to test and debug the games components.
The debug mode should be composed of:
These basic functions should be enough to test the game's main components. As we add new components to the prototype, we should add new pages to the debug mode.
There's a bug while updating player data in the tableview. For some reason Tkinter throws an error after the match is done. My suspicion is that there's something to do with the Thread, or with Garbage Collection kicking in before the table is updated. It might not be the case, since we are not deleting the live_game data even after the thread is done.
Another explanation might rely on a bug on the tableview implementation on ttkbootstrap.
This is the error log:
Exception in thread Thread-5 (start_simulation):
Traceback (most recent call last):
File "/usr/lib64/python3.12/threading.py", line 1052, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.12/threading.py", line 989, in run
self._target(*self._args, **self._kwargs)
File "/home/sturdyrobot/dev/openfootmanager/ofm/ui/controllers/debug_match_controller.py", line 73, in start_simulation
self.update_game_data()
File "/home/sturdyrobot/dev/openfootmanager/ofm/ui/controllers/debug_match_controller.py", line 96, in update_game_data
self.update_player_table()
File "/home/sturdyrobot/dev/openfootmanager/ofm/ui/controllers/debug_match_controller.py", line 189, in update_player_table
self.page.update_tables(home_team, away_team, home_reserves, away_reserves)
File "/home/sturdyrobot/dev/openfootmanager/ofm/ui/pages/debug_match/__init__.py", line 120, in update_tables
self.player_details_tab.update_tables(home_team, away_team)
File "/home/sturdyrobot/dev/openfootmanager/ofm/ui/pages/debug_match/player_details_tab.py", line 106, in update_tables
self.home_team_table.load_table_data()
File "/home/sturdyrobot/.local/share/virtualenvs/openfootmanager-ITedqgPF/lib/python3.12/site-packages/ttkbootstrap/tableview.py", line 1041, in load_table_data
self.unload_table_data()
File "/home/sturdyrobot/.local/share/virtualenvs/openfootmanager-ITedqgPF/lib/python3.12/site-packages/ttkbootstrap/tableview.py", line 1023, in unload_table_data
row.hide()
File "/home/sturdyrobot/.local/share/virtualenvs/openfootmanager-ITedqgPF/lib/python3.12/site-packages/ttkbootstrap/tableview.py", line 332, in hide
self.view.detach(self.iid)
File "/usr/lib64/python3.12/tkinter/ttk.py", line 1230, in detach
self.tk.call(self._w, "detach", items)
_tkinter.TclError: Item I0CF not found
It's pretty inconsistent, and might happen once or twice, or even not at all.
SimulationEvents are currently an untested mess. I need to write tests for them, but they're pretty random, so I have to refactor them to get them to a testable state. My idea is to extract all the randomness into functions, and monkeypatch them to always return the same results in pytest. That way we only need to test what the events return, and the logic behind them. After that we can test the integration between SimulationEvents and the SimulationEngine itself.
OpenFoot Manager is exactly what the name implies: a Football (Soccer) Manager game. Based on famous franchises, such as Football Manager and the now deceased Championship Manager. This game was born after looking at the available alternatives in the open source market, and after the Bygfoot game was abandoned.
The idea is to bring the gameplay experience you would find in these legendary manager games, without any of the limitations that the other alternatives present to the player:
Following the standard of manager games, the game mostly relies on the mouse to be played, with screens and buttons to be clicked on, and text output with information about what's happening in the game.
As soon as you start the game, you can choose to start a New Game, Load a previous game, configure game settings or exit the application. When you start a new game, you're given the choice to create your manager and then to choose the team that you want to play. You can also create a new team and drop it in a division that you want to play in. There are no restrictions of team choice. You can only choose one team per game session. You are not allowed to edit the players once you enter the new game session as well.
The game will be able to generate an entirely new database of teams and players from scratch, or even load an existing database, if the player wants to.
Once you start your game session with the team of choice, you should get options see your squad, see news of other teams and what is going on in the world of soccer, and see your calendar of games. There should be options to configure your team's default formation, your playing strategy, and you should be able to interact with the database by searching for players or teams, as well as try to negotiate with players and bring them to your team.
The game should also present you with the option to view and manage your team's finances, and manage your team's staff. The user can hire better staff members to get better input of other player's performances and increase the players' recovery time.
When playing a Match, you should define the team's formation, and it's up to you to choose your team's strategies.
The Match will pop up with info about the current match status and score. That's when Match Live Commentary comes up: every now and then the teams will perform an action, and their actions will show up on the user's screen, just as if there is someone casting this game.
At the end of the match, all data will be updated with the scores, performance ratings, which will affect player's performances and form later on. This means that if you're team is on a winning streak, they're going to get hyped up for next games, and this is going to increase the chances of winning other matches. Going on a losing streak, on the other hand, will demotivate your players and will increase your chances of getting fired.
Hiring new players depends on your financial situation. You can either approach other teams to hire them, or find new talents in the Youth Academy. These prospects will have potential skills that can be explored, and if you practice a lot with them, they might reach their peak.
Sponsors provide ways to get financial and performance boosts. Each season you will get approached by sponsors to sign contracts, depending on the relevance of your team. If your team is very strong, bigger sponsors will offer very significant contracts. Your sponsorship depends on your team's performance, and the financial boost might come with specific requests ("score 5 goals in the next match", "win against your rival", "win 3 games in a row", or so on and so forth). Every so often the sponsor will provide items that might boost players' performances temporarily or permanently. It's up to you to choose what's best for your team at certain points.
Your team has to practice regularly to improve player's forms and boost their morale. You can relegate practice matches to an auto-manager, that will do an okay job at it, but people that want to get the full experience can take control of practice match and do their best to improve the roster the best they can.
Winning a league might qualify your team for major championships, such as Champions League/Libertadores or other International Competitions. Winning these championships will provide a major financial boost and will make your name desirable for other teams.
These are right now the main aspects planned for the 1.0.0 release of the game. Further details are going to be found on a future Game Design Document.
The game is developed using Python 3 (currently 3.8.3), using a Pipenv. You will find all the project's requirements in the Pipfile. You may find specifics in the CONTRIBUTING file as soon as it's ready for Contributing. You will also find every information needed to get this project running on your machine, and the code style used in this project. Please, also follow the Code Of Conduct described there, so any contributor that does not follow our Code of Conduct will be dismissed.
The license is GPLv3. Defined on the License document and on Readme as well.
Trying to add widgets and new tabs to the DebugMatch GUI is starting to get bloated. The code is too long, and we can refactor it into smaller pieces for each tab and function.
It needs a refactor. This is what I want to do:
I've introduced a way to load teams in the Debug Match page here 82abf40. It's perhaps not the best way to do this, but it might be done. However, I suspect that the database is too big, and it might not load things correctly, since it takes too long and uses too much CPU to do so.
I need to find a way to load teams more efficiently, and to make it so it doesn't crash or uses too much CPU.
Stadiums can be separate entities from Clubs. We can organize a separate database only for Stadiums, so that games can be played on neutral grounds as well.
In this point in time, the game uses a database with names of existing teams.
To avoid issues with copyright infringement and potential lawsuits from soccer authorities, we should not distribute the game with real team names and data.
The Team generation should generate a random database of teams, based on a couple of parameters in definition files. Names of the teams should be randomized according to their locations.
Initial implementation is being worked on the rework
branch.
I'm investigating using Pywebview as an alternative way to program the frontend. Pywebview is basically an "Electron" for Python projects.
We can create a Flask server to expose the relevant API to the frontend, and program the frontend in JS frameworks. Now, I'm a terrible frontend developer myself, and I don't really like working with JS, but I know that there are a lot of competent JS developers that can improve that, so that's a good way to get people to contribute to the project.
Personally, I'd love if we could minimize the amount of JS (I'm not too fond of that. The few times I've used it I had so many headaches with the dependency hell created by Node.js, and with the bloated packages generated by it), and I'd love to go for a more HTML-centric approach, using at least HTMX and Tailwindcss. However, I know that React is pretty popular and that a lot of people would prefer working with that, so using React here is really a no-brainer.
I'll do my best to implement the basics with ttkbootstrap to create the prototype, but as soon as I'm done with it, I'll try Pywebview as an alternative UI.
Hi,
Thanks for the project! I've just started to work on Python recently and I want to work on an open source project to improve my skills. Your project really interests me!
I want to know if you're looking for contributors and if yes, have you planned to add in the readme how to run the project?
To generate teams and players for these teams, I had a couple of ideas that I expressed in #13 .
I'm settling in an option to generate the teams definitions according to a definition file that includes the team's name, region, and expected skill lvl.
We have a lot of football regions, teams, leagues and championships, so I'm going to rely on an open source football database called football.db which is part of sport.db. But we might run into copyright issues if we include teams/championships real names.
So here are some things that I'd like to do for these definitions:
The UI is only going to display commentary according to user-defined settings. If the user wants to see all the events, all commentaries will be enabled. If they only want to see important events, only goals and free kicks are going to appear.
The penalty shootouts feature is a special case in match simulation. Probably a sequence of Penalty events, but we need to make a few adjustments:
PlayerAttributes are getting more specific. I recently made a change to potential skill to be only an overall number, and following this change, I want to make PlayerAttributes way more specific to make the simulation more interesting.
PlayerAttributes will have more specific attributes, and the overall calculation will get a little bit more complicated with this change. I will also need to tune the Generator function to generate these properly, so this is a very big change to come.
They will be broken down into a few attributes:
GK
Physical
Defending
Intelligence
Offensive
This means that to calculate a player's overall for a position, these attributes are worth more.
FW: (Gk * 0 + Physical + Defending + Intelligence * 2 + Offensive * 3) / 7
MF: (Gk * 0 + Physical + Defending + Intelligence * 3 + Offensive * 2) / 7
DF: (Gk * 0 + Physical * 2 + Defending * 3 + Intelligence + Offensive * 3) / 7
GK: (GK * 3 + Physical * 2 + Defending + Intelligence * 0 + Offensive * 0)/6
Implement new PlayerAttributes with these subclasses
Implement new PlayerAttributesGenerator to account for these
Change get_best_position
Change how overall is calculated based on the attributes
Change the tests to account for the new PlayerAttributes
I have tried to add some tests using the "hypothesis" library. Hypothesis is a property-based testing tool, to help us generate data for testing.
For projects with a lot of data that is randomly generated, like this one, property-based testing is great for testing the project against more data than we already have.
Before the Match Simulation, each team has to set up the players on the field and the players on the bench. Right now I have the Formation class which is pretty much just a dummy class.
However, setting up a team formation is a pretty important part in football, so we should come up with a method to set them up in the game. Following work items are required:
As I'm implementing the events I realize that TeamStrategy matters a lot to how the teams will play the game. They influence the transition matrix between events, so I decided to kickstart a TeamStrategy implementation.
Teams will have the following strategies:
Hopefully we can see a big variety of play styles from these alone. I'll also implement a way for the user to switch the strategies mid-game, and I will add a combobox to the Debug Match so you can play with the different styles for each team.
Breakdown:
With new PRs coming up, it's hard to keep up with new features and code changes. I need to set up a CI/CD environment to get ready for contributions and make it easier for us to review new code.
@sturdy-robot could you please update the requirements.txt
with the acutally used packages? I installed the project in a fresh virtual environment. I needed to install pyyaml
and ttkbootstrap
manually, because they are missing in the requirements. There is also PySide6 in the requirements, which isn't used at the moment if I'm correct. This is a quite large package. Maybe there are more unused packages, that I didn't see.
Could you please remove the unused packages and add pyyaml
and ttkbootstrap
?
I want to work with a very simple GUI for prototyping the game's features. As much as I want this game to have a core independent from the GUI, and anyone could use the core and develop their own GUI on top, I just think working with a GUI for prototyping and getting ideas out there is a better method.
Initially I wanted to work with Qt, but I'm not too fond of Qt lately. Perhaps in the future I can look forward to working with it.
With eSM, I used PySimpleGUI. It's a simple enough GUI system that can get things done quickly. However, I had to develop a complex system to deal with layouts and controllers, which I don't think can be reusable. Although PySimpleGUI is awesome for prototyping, I was exploring other ideas.
Recently I found Ttkbootstrap, a wrapper around Tkinter, Ttk and PIL, which makes working with Tkinter a little bit less painful, and with gorgeous Bootstrap-inspired Ttk themes. One of my main issues with PySimpleGUI was updating the layout theme in real-time, which doesn't seem to be a problem in Ttkbootstrap.
I'm coming up with simple designs for the prototype.
My idea with this is to deliver a minimum viable product, where the user can interact with the game without using the terminal. It should be simple enough to get started, after so long just staying in the realm of testing with pytest only.
Later on, as the game progresses and develops even further, we can explore new GUI systems, and develop a GUI-independent API to make the core much more reusable and expandable.
I want to create a SQL database out of the game's data. JSON files are fine and can be an option to store and modify data, but I believe that, in the long-term, SQL databases are more suitable options for the game. The Core of OFM could be, at any point in time, used for implementing a web-based application, so I believe using proper databases is the way to go here. Even if my initial goal is to implement only a desktop app, I can see someone wanting to use this for a web-based app, so we can make this easier for anyone to use the game's data.
For that, I think SQLAlchemy is a suitable option to accomplish that goal. It's one of the most robust ORMs in Python, and can be used with basically any database system. My initial goal is to only implement a SQLite database, as described in #35 , but in the long-term, I could use it for any database system.
Adapting the code to conform with SQLAlchemy will take a while, but I think it'll be worth it.
Implement a Substitution system.
Introduce a delay to each event happening in the game, to give the impression of a real-time description. Delays will be user-defined.
Just a small enhancement to add to the Offensive attributes:
These attributes will be used in the ShotEvent to calibrate the player's final probabilities of scoring.
In this point in time, the game uses a database with names of existing players.
To avoid issues with copyright infringement and potential lawsuits from soccer authorities, we should not distribute the game with real player names and data.
The Player generation should generate a random database of players, based on a couple of parameters in definition files. Names of the players should be randomized according to their nationality, and their skill level should also correspond to their nationality.
Initial implementation is being worked on the rework
branch.
This is the roadmap for Openfoot Manager. This roadmap represents the current plans for each version of OFM, and which features should be prioritized in these versions. The roadmap is subject to change without further notice as development goes on.
In this high-level roadmap, discussions about the underlying architecture is irrelevant. The game's architecture is entirely subject to change, and should be discussed with the developers and collaborators of the project.
The strategy of versioning follows Semantic Versioning (SemVer).
First release of the game, where the foundations are laid out. In this release, we work on the essential features for the game. A lot of features that are not considered a priority will be left out of this release.
This can be considered an alpha release, so this is the first step into making a stable game. This release should not represent the final product.
This release must include:
The following items are optional for this release, which might be implemented if we can fit into the initial foundations:
All the other potential features are not considered priority at this point. The initial release will give us the confidence to implement more features.
If any of the optional items of the previous release were not implemented, this release should now include them.
This release is where things are substantially improved. The game should be more robust at this point, and whe should be able to identify the issues that need our attention. Above that, these items must be implemented:
In this release, the player must be able to choose the region and team that they want to play. They must be able to transfer players and deal with the club's financial issues. The championships are now expanded, so you can play more than one cup at the same time.
With the manager approval meter, the player now has to please the demands of the club's board of directors, and try not to get fired from the job. And you can now watch your squad improve as you play the game, with the player progression system.
Following this release should come major improvements to the game's core gameplay mechanics. In this release we can focus on the visual aspects of the game:
Not only that, the game should now have a solid foundation to add more enhancements:
At this point we should start thinking about implementing a 2D match simulation engine.
No plans defined.
From here on now there are no plans. This roadmap will be updated as soon as the development picks up the pace. If we start focusing on deadlines and dates to finish each version, we will also add these dates to the roadmap.
I think it's important if we can make both games kind of compatible with each other. I want to get Bygfoot's definition files and parse them using Team and PlayerGenerators. Bygfoot's definition files are a good source for player names and skill generation, so it should be very interesting to make it also work in OFM.
However, OFM might also need to generate extra information that is not in Bygfoot's code, so it should generate new data not in the XML files.
Work on a Team Selection screen for players to see how they would go about selecting their team to manage in the game.
Some player names are written in different alphabets, like Japanese, Korean, Arabic. To make it less of a hassle to store in databases and read them in other languages, we might need to convert all of these characters to standard romanic languages.
There are a few options to solving this:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.