Yesterday night I found out that, if my player stays in the league for 5 more seasons, I will break the league's field goal record, which is currently 282 held by Turk Turkleton. I will also be able to do it in one season less than what Turkleton played. I also have a good shot at taking second place for most XP's made (496 is a near-impossible number to beat). Though I was very excited that this is a real possibility, Speculadora was quick to remind me that I'm going to have to battle regression. I currently stand at 539 TPE, which is only enough for me to play for 4 more seasons (I don't regress until next offseason), assuming I never update again. According to some quick math, I need 598 TPE by the end of the season to survive regression long enough to get that record.
One thing about this record, though, is that Turkleton made 282 field goals in 12 seasons. I'm estimated to hit 287 in my 11th season, which is when I'll regress to below 150 TPE. If I were to play in 12 seasons, I'd be able to create a good separation between me and Turkleton, all but securing the record (and maybe having a shot at that XP record too!). However, it's only an ESTIMATE. I could have a down year which makes my seasonal average drop, and if it drops enough I might not be able to get the record! Thus, I need to find out how much TPE I need to earn to make it to my 12th season.
As far as I'm concerned, there's no master list that shows how much TPE you need to get to survive regression to a certain season. So to find out how much TPE I need will require some math. But I don't want to do math. Math, especial trial-and-error math like this, requires time. I know many others in this league have spent lots of time thinking about TPE. Players need it to play long and play well. Legend Gimmy Jarroppolo is going to be auto-retired next season because he will fall below the 150 TPE threshold. I won't be auto-retired because I have enough to make me last a couple more years than him.
I doubt it's common knowledge (I know it's not, I've only hinted at it once in an old article of mine), but I am majoring in computer science. Meaning I can code stuff that "works". And to me, this issue seems to have an easy fix. I will make a program that will calculate regression.
There's several reasons why a program would be useful for this. It will be much faster to calculate a wide range of numbers. If I forget the result, I can go back and put in the number again. I won't be able to make a mistake in my math because the computer is doing the math. If I have another question later, I can go and rewrite the code to make it do what I want. I can make an article about it so I can get some more money to buy weekly training's and equipment. I can even make a program that I can share with the rest of the NSFL so that other users can find out how to survive regression.
The potential is unlimited.
To make this program, I will be coding in Java, with BlueJ as my IDE (software that I can code in). Though this isn't a coding tutorial, I will be explaining stuff as I go, with pictures, to help you understand what I'm doing.
This is BlueJ. This is where I'll be making this program. I have named this project "TPEProgram". In the center of the screen, I have created a class called "TPECalculator". This class is where I will be doing all of my coding.
Inside the class is some stock code to help me get started. I will not be using anything given to me in between the green box thingy. Instead, I will be adding my own code.
A crucial part of this program will be showing the user stuff. This can't be done without actually printing results to the screen. To show how this works, I've written two things; a method (methods are chunks of executable code) called main that will indicate the start of the program, and a single print statement that will print my name. Here is what it looks like when I run the program:
My name is great and all, but it doesn't change the fact that I still don't know how much TPE I need to play 12 seasons. To start, I need to declare some important variables.
Here, I've created two integers (meaning whole numbers); tpe, which I've set to my current tpe amount, and year, which is 1 year before the regression begins. As I showed before, I need to use a print command to actually show this info, else when I try to run this program in it's current state, nothing will show up.
This line of code I added looks complex, but I promise I haven't performed any magic tricks on you. The program printed out the phrase "Season ", and then did something called concatenation, where by adding the plus sign after the quotation mark, you can then have the program print out a value, as we did with tpe and year. I also added a special phrase to the code, "\t", but it didn't print out. It just made a bunch of space. That's because the backslash tells the code to do something that otherwise can't be done by just typing it out. In this case, we told the program to press the "tab" key. And as you can see in the output, it has done just that.
Now we need to do three things. We need to change how much tpe we have after regression, we need to change what year it is, and we need to do this until tpe is less than 150.
We have an error. The problem is that we're trying to multiply tpe, an int value, by .8, which converts the number to a double. As I mentioned, ints hold whole numbers only. Which means doubles hold decimal numbers. We cannot store a double in an int, thus why we are getting an error. A simple fix in most cases would be to just change tpe to a double.
Although we can now run the code without any errors, we are now getting a decimal value in our TPE amount. TPE can't be a decimal value. If the math ends up returning a decimal, we need to round down to the nearest whole number. That's because, at least in regression, any decimal value, even if it's .999, is rounded down. To do this, we need to do something called casting. This will force tpe to store the number as an int despite the equated value being a double.
By simply saying "tpe = (int)(tpe * .4);" instead of "tpe = tpe * .4;", we tell the code to save the math done in parentheses as an int, rounded down. We no longer need to save tpe as a double because of this.
The results show that, no, I can't make it to season 11 at my current TPE. I will have to get to 598 TPE (which I verified using this program) to make it to my 11th season. To make it to my 12th, I'll need a whopping 1193 TPE. However, you might notice that I'm not gaining any TPE during regression. The code is only subtracting TPE based on how much there was in the previous season. This is not how the NSFL works. Players still get TPE during regression years. We will have to make several BIG changes to implement adding TPE during the season. But first, I'm going to make some optimizations to the code we have now.
I have done two things that makes the code perform much better. The first was creating a new method called getRegression. This method will be used by our main method (the reason we don't need to call our main method is because "main" is a keyword in Java. "Main" is always the first thing that is run). getRegression is given an int (the year), and gives us a double, the regression percentage. Our switch statement (a more efficient if statement) cycles through the possible years to find and return the correct regression rate, or will force the program to stop should something go horribly wrong. If you've ever coded before but don't know why I didn't put a break in any of the cases (a break stops the switch statement from running any further), it's because returning a value inherently stops the switch from running any further, thus there's no need for the break.
The second thing I did was put all of our print code into a single block called a loop. This specific loop is called a while loop. Since we are printing our season and TPE over and over again, it's more effecient to just tell a loop to do it over and over again, rather than have 50 lines of code dedicated to getting the TPE, changing the year by 1, and then printing everything out over and over again. Now, our while loop checks to make sure year is under 16 (since your player is retired after season 15). Once it's equal to 16, the program will stop.
Note from future me: There are a few logical errors in what I've done here. I promise I will have fixed them by the end of this article. At the time I was more inclined to make something that worked.
Now that the code is optimized, I am going to create a way for the user to enter both their own tpe and current year.
I know it looks like a lot. I couldn't fit all of what I've done into one image. But I promise I'll explain what I've done. First, I've imported a special object called a Scanner. A Scanner allows the user to type in values. Then, I created two Strings (which store values as a "word" rather than a number value) and a boolean (true or false) variable. These were created so that I could implement error traps, which I'll get into in a moment. I then have the user enter their TPE, which is this time stored in a String, getTPE, rather than in the int.
An error trap is a way to prevent the user from doing stupid stuff. You can see in the terminal window that instead of giving the program a number like a good boy, I put in "no". If I put that "no" into an int, the program would give an error and would stop. That's why I made it a string.
I used a second type of loop for this error trap, called a do while loop. The difference between a do while and a while is that the do while will always run once. Thus, all the code inside it will run at least once, or in this case twice. This is because after we verify the user has entered a number, it's still possible for them to enter an invalid number (which I've made under 50, the least amount of TPE anyone can possibly have) and then enter a non-number. There's a lot of logic here, so I recommend taking a look at it to see if you can follow what it's doing.
You may notice that the while loop calls a method called isNumber. This is a second method I added to check if the string is a number. If it is, it will return as true. If not, it will return as false.
We prompt the user for their year (we even consider DSFL rookies!) and utilize another error trap. Finally, we print the unregressed and regressed seasons to give us a fully working user-interactive program!
We have yet to give the user the ability to add TPE as the seasons progress. Implementing that shouldn't require too much editing. We've already built a working error trap, and there are already loops in place which increment by year, so all we need to do is to put in a new user prompt for the value, put it through the error trap, and add it to the existing TPE.
I figured that I could combine the unregressed and regressed loops into one and just check if the given season is a regression season or not. As you can see, implementation went perfectly. The user inputs a number (saved as a string using our getTPE value from earlier), the error trap does its thing, then the new value that stores our added TPE, named addTPE, is added to our total TPE inside tpe. Then we simply changed the season's print statement to show that the TPE has been added.
Note from future me: In between the error trap and year prints is a line of code that adds the added tpe to the current total. This is another logical error. The reason is if we are in a regression season, the TPE you'd otherwise earn for that season is prematurely added to the total and then regressed. Thus, this line of code should be added to both the unregressed and regressed codes, being the first and second lines respectively.
You might've noticed that, despite going under the TPE limit in season 12, the program kept running. Everything after season 12 was code we didn't need to run, so I will add another check to see if the TPE has gone under 150. If it has, the program will end.
A simple if statement is enough to make this check. It checks to see if tpe is under 150. If it is, we will change the year to 16 (above the maximum), which will make the program stop.
Note from future me: There's yet another logical error here. If we regress below 150, we can't just convince HO to let us play another season so that we can get back above the limit. The program should end as soon as tpe is below 150. The if statement must be moved between the regression calculation and the eventual addTPE code. and then the remaining code must be put in an else block so it doesn't keep going after the player is auto-retired. Another thing I will change is the auto-retired print lines. I will show the user what year their player was auto-retired and how much TPE they had.
Finally, I'm going to implement a small menu. While making this, I realized how useful it could be for those poor members of HO who have to calculate regression every season. I don't think they'll want to have to calculate multiple years just to get what they're looking for. This menu will have 3 options: Calculate 1 year, Calculate multiple years (w/o added TPE), and Calculate multiple years (w/ added TPE). I will also provide the user with the option to type the word "Quit" if they ever want to end the program, go back to the main menu, or run the selected program again.
278 lines of code later, we have a working TPE calculator that (as far as my testing goes) is bug-free, efficient, and fast.
Note from future me: Some of the code shown in these images has been revised. What is shown is not the final product. I will provide a link to the final, bug-free version.
To run this program, you will need to download a Java IDE. There are several ones out there, such as Eclipse, NetBeans, but I recommend downloading BlueJ since it's an easy IDE to understand for people unfamiliar with code.
BlueJ Website
Program Code
Simply download BlueJ for whichever system you are using. Once it's downloaded, open BlueJ. You should be met with a screen similar to the first picture. From there, to to the top left, click "Project", "New Project", give it a name and store it somewhere on your computer. Once that's done, click the "New Class button" and name the class "TPECalculator". Press 'OK', and open the class by double clicking it. Remove all the code inside and replace it with the code in the provided in pastebin. Press the "Compile" button near the top right, close the code editor, right click on the class and click "void main(String[] args)". Simply press 'OK', and you can now use the program!
If you have any questions or find a bug/logical error, simply reply and I will help you out!
One thing about this record, though, is that Turkleton made 282 field goals in 12 seasons. I'm estimated to hit 287 in my 11th season, which is when I'll regress to below 150 TPE. If I were to play in 12 seasons, I'd be able to create a good separation between me and Turkleton, all but securing the record (and maybe having a shot at that XP record too!). However, it's only an ESTIMATE. I could have a down year which makes my seasonal average drop, and if it drops enough I might not be able to get the record! Thus, I need to find out how much TPE I need to earn to make it to my 12th season.
As far as I'm concerned, there's no master list that shows how much TPE you need to get to survive regression to a certain season. So to find out how much TPE I need will require some math. But I don't want to do math. Math, especial trial-and-error math like this, requires time. I know many others in this league have spent lots of time thinking about TPE. Players need it to play long and play well. Legend Gimmy Jarroppolo is going to be auto-retired next season because he will fall below the 150 TPE threshold. I won't be auto-retired because I have enough to make me last a couple more years than him.
I doubt it's common knowledge (I know it's not, I've only hinted at it once in an old article of mine), but I am majoring in computer science. Meaning I can code stuff that "works". And to me, this issue seems to have an easy fix. I will make a program that will calculate regression.
There's several reasons why a program would be useful for this. It will be much faster to calculate a wide range of numbers. If I forget the result, I can go back and put in the number again. I won't be able to make a mistake in my math because the computer is doing the math. If I have another question later, I can go and rewrite the code to make it do what I want. I can make an article about it so I can get some more money to buy weekly training's and equipment. I can even make a program that I can share with the rest of the NSFL so that other users can find out how to survive regression.
The potential is unlimited.
To make this program, I will be coding in Java, with BlueJ as my IDE (software that I can code in). Though this isn't a coding tutorial, I will be explaining stuff as I go, with pictures, to help you understand what I'm doing.
This is BlueJ. This is where I'll be making this program. I have named this project "TPEProgram". In the center of the screen, I have created a class called "TPECalculator". This class is where I will be doing all of my coding.
Inside the class is some stock code to help me get started. I will not be using anything given to me in between the green box thingy. Instead, I will be adding my own code.
A crucial part of this program will be showing the user stuff. This can't be done without actually printing results to the screen. To show how this works, I've written two things; a method (methods are chunks of executable code) called main that will indicate the start of the program, and a single print statement that will print my name. Here is what it looks like when I run the program:
My name is great and all, but it doesn't change the fact that I still don't know how much TPE I need to play 12 seasons. To start, I need to declare some important variables.
Here, I've created two integers (meaning whole numbers); tpe, which I've set to my current tpe amount, and year, which is 1 year before the regression begins. As I showed before, I need to use a print command to actually show this info, else when I try to run this program in it's current state, nothing will show up.
This line of code I added looks complex, but I promise I haven't performed any magic tricks on you. The program printed out the phrase "Season ", and then did something called concatenation, where by adding the plus sign after the quotation mark, you can then have the program print out a value, as we did with tpe and year. I also added a special phrase to the code, "\t", but it didn't print out. It just made a bunch of space. That's because the backslash tells the code to do something that otherwise can't be done by just typing it out. In this case, we told the program to press the "tab" key. And as you can see in the output, it has done just that.
Now we need to do three things. We need to change how much tpe we have after regression, we need to change what year it is, and we need to do this until tpe is less than 150.
We have an error. The problem is that we're trying to multiply tpe, an int value, by .8, which converts the number to a double. As I mentioned, ints hold whole numbers only. Which means doubles hold decimal numbers. We cannot store a double in an int, thus why we are getting an error. A simple fix in most cases would be to just change tpe to a double.
Although we can now run the code without any errors, we are now getting a decimal value in our TPE amount. TPE can't be a decimal value. If the math ends up returning a decimal, we need to round down to the nearest whole number. That's because, at least in regression, any decimal value, even if it's .999, is rounded down. To do this, we need to do something called casting. This will force tpe to store the number as an int despite the equated value being a double.
By simply saying "tpe = (int)(tpe * .4);" instead of "tpe = tpe * .4;", we tell the code to save the math done in parentheses as an int, rounded down. We no longer need to save tpe as a double because of this.
The results show that, no, I can't make it to season 11 at my current TPE. I will have to get to 598 TPE (which I verified using this program) to make it to my 11th season. To make it to my 12th, I'll need a whopping 1193 TPE. However, you might notice that I'm not gaining any TPE during regression. The code is only subtracting TPE based on how much there was in the previous season. This is not how the NSFL works. Players still get TPE during regression years. We will have to make several BIG changes to implement adding TPE during the season. But first, I'm going to make some optimizations to the code we have now.
I have done two things that makes the code perform much better. The first was creating a new method called getRegression. This method will be used by our main method (the reason we don't need to call our main method is because "main" is a keyword in Java. "Main" is always the first thing that is run). getRegression is given an int (the year), and gives us a double, the regression percentage. Our switch statement (a more efficient if statement) cycles through the possible years to find and return the correct regression rate, or will force the program to stop should something go horribly wrong. If you've ever coded before but don't know why I didn't put a break in any of the cases (a break stops the switch statement from running any further), it's because returning a value inherently stops the switch from running any further, thus there's no need for the break.
The second thing I did was put all of our print code into a single block called a loop. This specific loop is called a while loop. Since we are printing our season and TPE over and over again, it's more effecient to just tell a loop to do it over and over again, rather than have 50 lines of code dedicated to getting the TPE, changing the year by 1, and then printing everything out over and over again. Now, our while loop checks to make sure year is under 16 (since your player is retired after season 15). Once it's equal to 16, the program will stop.
Note from future me: There are a few logical errors in what I've done here. I promise I will have fixed them by the end of this article. At the time I was more inclined to make something that worked.
Now that the code is optimized, I am going to create a way for the user to enter both their own tpe and current year.
I know it looks like a lot. I couldn't fit all of what I've done into one image. But I promise I'll explain what I've done. First, I've imported a special object called a Scanner. A Scanner allows the user to type in values. Then, I created two Strings (which store values as a "word" rather than a number value) and a boolean (true or false) variable. These were created so that I could implement error traps, which I'll get into in a moment. I then have the user enter their TPE, which is this time stored in a String, getTPE, rather than in the int.
An error trap is a way to prevent the user from doing stupid stuff. You can see in the terminal window that instead of giving the program a number like a good boy, I put in "no". If I put that "no" into an int, the program would give an error and would stop. That's why I made it a string.
I used a second type of loop for this error trap, called a do while loop. The difference between a do while and a while is that the do while will always run once. Thus, all the code inside it will run at least once, or in this case twice. This is because after we verify the user has entered a number, it's still possible for them to enter an invalid number (which I've made under 50, the least amount of TPE anyone can possibly have) and then enter a non-number. There's a lot of logic here, so I recommend taking a look at it to see if you can follow what it's doing.
You may notice that the while loop calls a method called isNumber. This is a second method I added to check if the string is a number. If it is, it will return as true. If not, it will return as false.
We prompt the user for their year (we even consider DSFL rookies!) and utilize another error trap. Finally, we print the unregressed and regressed seasons to give us a fully working user-interactive program!
We have yet to give the user the ability to add TPE as the seasons progress. Implementing that shouldn't require too much editing. We've already built a working error trap, and there are already loops in place which increment by year, so all we need to do is to put in a new user prompt for the value, put it through the error trap, and add it to the existing TPE.
I figured that I could combine the unregressed and regressed loops into one and just check if the given season is a regression season or not. As you can see, implementation went perfectly. The user inputs a number (saved as a string using our getTPE value from earlier), the error trap does its thing, then the new value that stores our added TPE, named addTPE, is added to our total TPE inside tpe. Then we simply changed the season's print statement to show that the TPE has been added.
Note from future me: In between the error trap and year prints is a line of code that adds the added tpe to the current total. This is another logical error. The reason is if we are in a regression season, the TPE you'd otherwise earn for that season is prematurely added to the total and then regressed. Thus, this line of code should be added to both the unregressed and regressed codes, being the first and second lines respectively.
You might've noticed that, despite going under the TPE limit in season 12, the program kept running. Everything after season 12 was code we didn't need to run, so I will add another check to see if the TPE has gone under 150. If it has, the program will end.
A simple if statement is enough to make this check. It checks to see if tpe is under 150. If it is, we will change the year to 16 (above the maximum), which will make the program stop.
Note from future me: There's yet another logical error here. If we regress below 150, we can't just convince HO to let us play another season so that we can get back above the limit. The program should end as soon as tpe is below 150. The if statement must be moved between the regression calculation and the eventual addTPE code. and then the remaining code must be put in an else block so it doesn't keep going after the player is auto-retired. Another thing I will change is the auto-retired print lines. I will show the user what year their player was auto-retired and how much TPE they had.
Finally, I'm going to implement a small menu. While making this, I realized how useful it could be for those poor members of HO who have to calculate regression every season. I don't think they'll want to have to calculate multiple years just to get what they're looking for. This menu will have 3 options: Calculate 1 year, Calculate multiple years (w/o added TPE), and Calculate multiple years (w/ added TPE). I will also provide the user with the option to type the word "Quit" if they ever want to end the program, go back to the main menu, or run the selected program again.
278 lines of code later, we have a working TPE calculator that (as far as my testing goes) is bug-free, efficient, and fast.
Note from future me: Some of the code shown in these images has been revised. What is shown is not the final product. I will provide a link to the final, bug-free version.
To run this program, you will need to download a Java IDE. There are several ones out there, such as Eclipse, NetBeans, but I recommend downloading BlueJ since it's an easy IDE to understand for people unfamiliar with code.
BlueJ Website
Program Code
Simply download BlueJ for whichever system you are using. Once it's downloaded, open BlueJ. You should be met with a screen similar to the first picture. From there, to to the top left, click "Project", "New Project", give it a name and store it somewhere on your computer. Once that's done, click the "New Class button" and name the class "TPECalculator". Press 'OK', and open the class by double clicking it. Remove all the code inside and replace it with the code in the provided in pastebin. Press the "Compile" button near the top right, close the code editor, right click on the class and click "void main(String[] args)". Simply press 'OK', and you can now use the program!
If you have any questions or find a bug/logical error, simply reply and I will help you out!
Alex Dasistwirklichseinnachname || K || Orange County Otters || 382 TPE
http://sim-football.com/wiki/index.php?tit...ichseinnachname
Player Page||Updates
http://sim-football.com/wiki/index.php?tit...ichseinnachname
Player Page||Updates