08-10-2016, 08:52 AM | #151 | |
High School Varsity
Join Date: Jul 2016
|
Quote:
I've found the same thing. Since I started writing sports sims, I've been transferring the new programming skills to my job, writing various data crunching tools. (which has ended up helping career growth) Funny how that works out! |
|
08-19-2016, 04:05 PM | #152 |
College Benchwarmer
Join Date: Oct 2000
Location: calgary, AB
|
Silly noob question:
I'm trying to generate random numbers so I've done Code:
But when I print A, I get the same random number the entire time. I'm kind of confused as to why as I thought if I don't specify a seed I should get a different random number based upon the system clock. Or is it just happening too fast, so the clock is the same? |
08-19-2016, 04:22 PM | #153 | |
College Benchwarmer
Join Date: Oct 2000
Location: calgary, AB
|
Quote:
Apparently _random is different than random, which has fixed my issue! |
|
08-19-2016, 10:27 PM | #154 |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
It is - I actually have no idea what _random is, I know there's a few libraries with the underscores.
Another quick tip - you don't need the (0,8) with range, you can just: Code:
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce |
08-22-2016, 12:50 PM | #155 |
High School Varsity
Join Date: Feb 2007
|
You could also use a list comprehension to skip the step of appending to the created list and just create the list.
Code:
List comprehensions were one of the best things I've learned about. I had one block of about 12 overly complicated lines in an early project get replaced by one list comprehension....and that simplification flowed through everything else. |
12-12-2016, 11:16 PM | #156 |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
Yes, list comprehensions are the bomb once you get a handle on them. I remember reading through one of my first Python books and my eyes just glazed over when covering that topic (similar to what used to happen to me back in school in maths, actually... I wonder if I have dyscalculia...). It was only when I saw a real simple example in someone else's code that was clearly commented that it clicked with me.
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce |
12-13-2016, 12:43 AM | #157 |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
It’s been months, so here’s a quick update:
Life and holidays got in the way for the most part since my last updates, but over the past three weeks I’ve picked this up again and got quite a bit done. One of the big changes I’ve made is just to focus entirely on the code component, and so I’ve sliced the GUI (PySide) right out at the moment. The main advantage to putting the UI aside is that it was really slowing me down, and my plan is to try and get the core functionality coded before looking at a UI again. If I’m happy with what I’ve coded I may just pay someone else to do it. I think PySide is great, but I don’t know that I would ever be able to package it in a way that I’d like, and I also think that if I ever wanted to make money from this at some point, it makes sense to focus on the online/browser based component. This is contrary to how I myself like to play, but hey, I have massive CD and DVD collections too. I'm no design expert or anything, but I liked the overall style I came up with with my PySide GUI, and I'd probably want something very similar no matter which way I go. The code as I've been writing it will make it pretty easy to slot any UI framework over the top, so I can worry about this decision later, once I have a functioning simulator!
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce |
12-13-2016, 05:12 AM | #158 | ||
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
Testing out the 'universe generator' code I setup ages ago to make sure it all still works after cutting my code to pieces. Right now it uses the fictional default league info I've saved into a csv and generates fictional teams for all leagues based on that info, selecting random cities (weighted towards the most populous cities) and nicknames (if enabled). There is a ton of loading of csv files and calculations to make this info, which is what impresses me about Python - it's done in less than a second (excluding players - they take about 1.5 seconds at the moment).
I want to quickly be able to spin up entire random universes with teams/coaches/players/arenas etc. quickly to help with testing down the road. For fun, here's the most recent USA 'NBA': Quote:
Usually it's very Texas heavy as I used a list of the 80ish most populated cities in the USA. And the same for Spain: Quote:
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce |
||
12-14-2016, 05:25 PM | #159 |
High School Varsity
Join Date: Feb 2007
|
Very cool! It's interesting to watch your decision making process as you work through the project! Probably a wise move to put GUI aside, from screenshots it looks like you've done enough to know you can do that if that's the direction you want to go!
If there are ever any tasks you think you could use a hand with let me know...I'm still very much a beginner but I've been working away at building little bits and pieces like name generators and cartoon face generators. Just starting to learn about databases and flask right now. I know that would likely be too complicated to manage and it's also "your baby" - but just wanted to put it out there if there's ever a piece you could use help on. Continuing to watch for your updates! |
12-14-2016, 10:26 PM | #160 |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
Yeah, and as a plus I've learnt a good deal about PySide/PyQt/Qt, and have developed UIs for a bunch of other small projects at home and in the office, and created my first "proper" python module to manage stylesheets for widgets, the creatively named qt_widgetstyler, so it has not been time wasted!
While I do think of this as "my baby" to some extent, I'm more than open to help. By no means feel obligated to tackle this, but one thing I was playing with months and months ago and couldn't get it to work quite right is a round-robin schedule creator. When I get a chance I'll post what I put together, and if you can get the dang thing to work, fantastic! It's harder than it sounds, because it needs to take into account a few factors, such as valid days of the week to schedule games, etc.
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce |
12-15-2016, 02:53 PM | #161 |
High School Varsity
Join Date: Feb 2007
|
I have played with scheduling a bit and I definitely wouldn't go in thinking it's easy! But that would be cool to take a look at it...like you said, if I can't do it, it'll be something you can look at again in the future but I'd be interested in taking a crack at it!
|
12-15-2016, 04:05 PM | #162 |
Pro Starter
Join Date: Jul 2001
Location: Not Delaware - hurray!
|
I don't want to steal sirBlurton's thunder, but I wouldn't mind lending a hand with things, either. I've been programming my own college football sim but it's coming in drips and drabs and wouldn't mind increasing my skill set.
__________________
She loves you, yeah, yeah, yeah, yeah! She loves you, yeah! how do you know? how do you know? |
12-15-2016, 10:15 PM | #163 |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
Hey, the more the merrier as far as I'm concerned
Here's a snippet of what I put together actually nearly 12 months ago, checking the time stamp of the file. I've made a few small changes just now, but I haven't tested anything yet, so there may be typos/errors if you try run the below currently (just working out of notepad at the moment...) The part that was frustrating me was the 'get_valid_game_days' method. There's nothing in the code below for this, but I spent an hour or so playing around on the python command line trying to solve this - basically, need to take a date range, and calculate all the valid game days within this range, grouped by week. The timedate library has some cool functionality that should make this possible, but I'll be darned if I could crack it - this was that "math-level" stuff I mentioned above that I struggle with. For example, if Friday and Saturday were the only valid days, and the date range was for 4 weeks starting this week, the output of this method should be: [[16/12/2016, 17/12/2016], [23/12/2016, 24/12/2016], [30/12/2016, 31/12/2016], [6/1/2017, 7/1/2017]] As a rule I generally work with all dates as ordinal numbers - datetime objects have a .toordinal() method. I just trust it more, especially when writing to databases. Code:
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce Last edited by Groundhog : 12-16-2016 at 08:26 PM. |
12-15-2016, 10:21 PM | #164 |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
dola
The above was written in Python 2 as well, where as I've moved to 3 now. I think the only impact this has on the above is that the 'generate_round_robin_matchups' method will returns a generator object rather than a list of lists, but this is minor. edit: fixed some typos in the above.
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce Last edited by Groundhog : 12-16-2016 at 09:45 PM. |
12-18-2016, 11:39 AM | #165 |
Pro Starter
Join Date: Jul 2001
Location: Not Delaware - hurray!
|
Is the valid_game_day list only for a single week or for all weeks? Meaning, do I want to state that Mondays and Tuesdays are invalid game dates for ALL weeks, or do I just want an potentially long list showing which days are invalid for the entire year?
__________________
She loves you, yeah, yeah, yeah, yeah! She loves you, yeah! how do you know? how do you know? |
12-18-2016, 06:14 PM | #166 |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
For all weeks - so a long list of dates, grouped by weeks, between a start date and end date. What I'm trying to achieve here is a list of all valid game days between two dates. The next step would be assigning all the matchups generated by the 'generate_round_robin_matchups' method to these dates.
Most of the "round robin" leagues around the world have set days that they usually play their games - for European leagues it's generally Sat/Sun (which makes the Euroleague/Eurocup scheduling easier), in Australia it's everyday except Tue/Weds - so that's the behaviour I'm looking for here. The leagues all have the 'valid days' attribute that defines which of these days of the week to schedule games on. This class (will eventually) take that info as a dictionary, generate a list of all the matchups, generate a list of valid game dates, and then assign those matchups to those dates.
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce |
12-19-2016, 10:16 AM | #167 | |
Pro Starter
Join Date: Jul 2001
Location: Not Delaware - hurray!
|
Quote:
Stupid question - and now I see why working in teams can sometimes be hard - when you generate the list of invalid game days (the "falses" in the list) can't you just generate the "trues" as a list for the entire year, keep it in memory and just access it when needed?
__________________
She loves you, yeah, yeah, yeah, yeah! She loves you, yeah! how do you know? how do you know? |
|
12-19-2016, 07:23 PM | #168 |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
No, not a stupid question at all!
Ignore the invalid dates, because we only need those to determine which days are valid, and they will be skipped over. The False/True flags just tell the method that it needs to compile a list of all True days for each week between a range of dates. So if we feed the class a starting date of June 30 2016 up until January 31 2017, the method would first check which days are valid - let's say Saturday and Sunday - and then split up the the period between those dates into units of weeks, and append all the dates of Saturday and Sundays to a list. When we assign the matchups to days, it would be a random.choice() type of operation to randomly assign the individual matchups to these valid dates. This could all be stored in memory, but this calculation will need to be run for all 70ish leagues once per offseason, as they all have their own unique True/False flags for valid game days, and obviously the dates will also change from year to year. The final output of this would be a list of all games in a season, with the date, league id, home team id, and road team id, which would then be written to the database. An instance of this class would be used inside another method somewhere along the lines of (and this is probably full of syntax errors, but just to give you a quick idea): Code:
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce |
12-19-2016, 09:08 PM | #169 |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
dola
Had another thought. Maybe the way to approach it is to just create a dictionary once of every week and day of the week in that date range, and then use that info to build all the schedules.
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce |
12-20-2016, 11:11 AM | #170 | |
Pro Starter
Join Date: Jul 2001
Location: Not Delaware - hurray!
|
Quote:
Yeah - getting back to my question - does that mean the list of true/false flags are ONLY for days of the week, or could you have something like false for all Saturdays and also Christmas day?
__________________
She loves you, yeah, yeah, yeah, yeah! She loves you, yeah! how do you know? how do you know? |
|
12-20-2016, 06:27 PM | #171 | |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
Quote:
Currently, only for days of the week. I did think about things like holidays, but at the same time its a lot of work tracking down holidays/special days for 68 different nations, to have things like no Christmas day games in Australia, or no Sunday games in Israel, etc.
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce |
|
01-31-2017, 05:49 AM | #172 |
Dark Cloud
Join Date: Apr 2001
|
Spam aside, glad you're still at this.
__________________
Current dynasty: OOTP25 Blitz: RTS meets Moneyball | OOTP Mod: GM Excel Competitive Balance Tax/Revenue Sharing Calc | FBCB Mods on Github |
03-05-2017, 06:27 PM | #173 |
High School Varsity
Join Date: Jul 2016
|
Nice to see you're still chugging along!
|
07-07-2017, 11:24 AM | #174 | |
College Benchwarmer
Join Date: Oct 2000
Location: calgary, AB
|
Quote:
What did you use to make these screens? They look great, much better than what I'm capable of in PyQt |
|
07-09-2017, 07:44 AM | #175 | |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
Quote:
Just a combination of the Designer app to layout all the widgets, and then applying different stylesheets to each widget within Python. Most of the "magic" is just labels with rounded corners and partially transparent background colours (rgba with an alpha channel that acts as the transparency %), so the background image shows through.
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce |
|
07-19-2017, 04:15 PM | #176 | |
College Benchwarmer
Join Date: Oct 2000
Location: calgary, AB
|
Quote:
To get the rounded push buttons did you use something like: Code:
I can't seem to get rounded edges this way |
|
07-19-2017, 11:10 PM | #177 |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
Code:
I can't remember if there's a good reason why I used individual corner radius %s vs just a general border-radius setting. Swap out the {} for values and that's straight out of my code. I didn't use the setPalette or .setObjectName methods for any of my widgets - again, can't remember if that was for a reason or if I just never saw those methods. I created this library to let me group widgets and make it easier to manage colour schemes on different team pages, etc. It's super amateur and I'm sure Qt has a way of doing the same thing (possibly .setObjetcName), but it was an easier "python" way for me to handle it.
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce Last edited by Groundhog : 07-19-2017 at 11:14 PM. |
07-20-2017, 10:15 AM | #178 | |
College Benchwarmer
Join Date: Oct 2000
Location: calgary, AB
|
Quote:
Weird, doing each corner separately seems to work. I think that you have to use the palette command if you're using PyQt5. Like how the QMainWindow moved from PyGui to QtWidgets. One thing I'm going to have to work on is the ability to batch import. I've got it set up that I can read in constants from a text file for athlete generation, but I'm not sure how to do it to create a generic style sheet based on the country the player is using. Maybe I'll actually post in my thread to discuss it better. |
|
07-20-2017, 11:02 PM | #179 |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
Happy to show you how I do it, PM me if you want a quick example.
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce |
07-20-2017, 11:21 PM | #180 |
College Starter
Join Date: Aug 2016
Location: Earth, the semi-final frontier.
|
Enjoyed reading through this. I'm at the very beginning of my journey learning languages, starting with a couple of web developer courses through Udemy (nearly everything on the site was $10 around July 4). After that I'm looking at Ruby on Rails, I already bought an intro course on it, and maybe Python after that. This dynasty will definitely help in my sections on Python in the two developer courses.
|
06-25-2019, 07:43 PM | #181 |
Coordinator
Join Date: Dec 2003
Location: Sydney, Australia
|
Just an update on this, because I get the odd PM here and there, especially from folks who find this thread via google. The two questions I get are:
Did I ever finish this? No. Real life, in particular a promotion at work and having a kid, made this begin to feel like work to be completely honest. I was spending 2-3 hours a night coding in bed, and I was beginning to have dreams involving Python functions, which was a bit strange. I decided to take a break from it and never got the urge to pick it up again. I'm sure I will down the line however, and I've still kept up with Python and use it from time-to-time at work. Is it possible to program something like this in Python? Absolutely yes, and probably a lot better than how I was doing it. Even the GUI I think looked OK, but as I touched on a few times in this thread I would ignore this component it if I did this again and look at a web GUI (and probably paying someone to build one rather than learning it myself).
__________________
Politics, n. Strife of interests masquerading as a contest of principles. --Ambrose Bierce |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|