jonesguy14 / footballcoach

Android App for playing/simulating/recruiting as a college football coach
Other
34 stars 8 forks source link

Change OT Rules? #16

Closed jonesguy14 closed 8 years ago

jonesguy14 commented 8 years ago

Some users have requested changing the OT rules to be more like college.

So instead of a full new quarter, some sort of score-then you score type of thing.

destilla commented 8 years ago

Work is looking a little crazy between now and Friday, but I should have some free time randomly between now and the weekend to do some work on this.

I have an idea of how we can add this, and have possession restart for the first team to go on offense in OT (and add a change of possession after halftime).

My thinking on the end result is something like this:


Thoughts? Any end results you would change?

jonesguy14 commented 8 years ago

Yes all those ideas sound good. I actually started to make OT rules last week but stopped midway. I basically did exactly what you talked about here (away team starts with ball, have variable that tracks if it is in top half or bottom half of OT, change code elsewhere so that if a TD is scored in OT, kickOff doesn't happen but the other team may get the ball) but it was buggy and wasn't working how I wanted. If you want I can send you my modified Game.java with my changes, but not sure if that would help or hurt.

destilla commented 8 years ago

Generally speaking I've had good results using your code as a base to create something, so I think it would definitely help. Worst case scenario, I look it over and just start fresh. Best case scenario, I avoid pitfalls you've already discovered or find a cleaner way to do something I had in mind.

jonesguy14 commented 8 years ago

Ok, when I'm back my desktop later tonight I'll post it and explain more about what I tried.

destilla commented 8 years ago

Alright, sounds good. I have dinner plans for tonight and a meeting at work tomorrow from the morning til after lunch probably, but then after that I should have some time to dedicate to this. I'll probably end up checking it in the morning before the meetings.

jonesguy14 commented 8 years ago

Yeah man no worries, don't feel like it's super urgent or anything, just whenever you have time and if you want to.

jonesguy14 commented 8 years ago

Just posted it as Game_OT_rules_test.java, not sure if there was a better way but whatever I'll remove it later.

Basically:

if (gameTime <= 0 && homeScore == awayScore) { playingOT = true; gamePoss = false; gameYardLine = 70; numOT++; gameTime = -1; gameDown = 1; runPlay( awayTeam, homeTeam ); }

So that's what I have for now. Let me know if you have any questions. Again, no rush and its only if you feel like taking on the challenge.

destilla commented 8 years ago

Oh, I definitely want and I think I'm up to the challenge, and in retrospect, I'm not sure why I felt the need to walk through my schedule, lol. I think I mostly wanted to communicate that I am interesting in trying to tackle this but that I'm going to be a bit busy for a day or two.

I'm poking around the code you uploaded and you definitely have some stuff I want to use; especially the way you handled the change to OT in getEventPrefix(), I really liked that.

I did have a few questions:

if (gameTime < 100) homeScore = awayScore;

That line if code is in the while loop for playGame(), right after the lines for the two different runPlay()s. If I understand java correctly (which is a tremendous leap of faith), you basically set that line there to force a game into OT and to test that it works?

If not, what's it do?

In the runPlay() logic I saw that for the top half of OT, the offense kicks a FG on 4th down. How do you feel about having that be stategy dependent?

An example might be: Conservative always kicks the FG No preference will go for it with 3 or less yards to go AND it's goal to go (aka 4th and goal from the 97 or closer), or go for it on 4th and 1.
Aggressive either always goes for it or does something like kick the FG any time it's 5 or more yards to go, or for goal to go situations, kick the FG any time it's more than 7 yards.

I'm not married to any of those specific routes, just spitballing ideas so you see what I mean and to get an opinion.

Finally, I think I understand how resetForOT() works, basically just sets possession, yardline, down, etc and then continues the while loop in playGame, but you had mentioned that you ran into some bugs with the existing code. At a quick glance this looks pretty solid; do you remember anything in particular that you found while doing testing? Just so I can be aware of things to look out.

Thanks for the sample code!

destilla commented 8 years ago

Oh one other question -- Where can I find r.achijones.footballcoach? Or at least how can I add a new menu item (though I realize the second question is probably way more complex) All of the menu items reference get r.id.action_for_menu_thing but I can't find an R, other than the one I think Android Studio is creating, and that's blank.

I was hoping to try something like creating a log with each runPlay that would save them to a string and then check them out in a menu item, similar to what you've got with the news stories, for testing purposes. That way I can look at what is happening with the plays and if it's behaving how I would expect (and also because I found an interesting bug last night that I'll post when I'm not late for a meeting). I tried to do the menu myself but I can't figure out what I'm doing wrong (or not doing at all).

jonesguy14 commented 8 years ago

Yeah the line where it sets the scores equal is just for testing, so you won't have to wait for an OT game to be played organically (as in all games will go to OT).

Yeah attaching strategies to whether a team should go for it on 4th down is definitely something that should be added, but I wouldn't worry about that until the regular OT rules are in place. I like your ideas though.

Not sure exactly what bugs I had, I just know that I was getting impossible scores (like a team would win by 14 even though it went to OT) and so I just ditched it to work on something else for the 1.2 release.

For the R thing, if you are talking about the menu in the top right, you need to look at menu_main.xml to add menu items. That's where all the action_blahblah are defined. But if you are just debugging for the games, I would just add debug stuff to the gameEventLog so you can see what is happening for a particular game.

destilla commented 8 years ago

So, I don't have the play selection logic worked out (or even started) yet, but OT rules are in place and behaving as they should. I verified this by very powerfully failing to create an alert dialog that would let me know if any OT scores were greater than 8, and ran a few seasons.

Then, to be sure my alert dialog worked, I set it to popup any time a game ended with a difference in score of more than 7. Week one had a game settled by a difference of 8 points and the app promptly crashed. But still, the app didn't crash when I was checking to see if games were ending with a bigger difference than 8, so everything seems copasetic at the moment.

How deep do you want the logic for runPlay to be in accounting for OT play calling for the first pass of college overtime rules? The games seem to flow pretty normally with the existing play calling logic: When they're far, they pass it, when they're near, the run it, when it's 4th down, they kick the fg. I can insert an extra line to address having to go for it in the bottom frame of OT if you're down by more than 3 and then the very basic functionality exists.

From there it can be expanded on (and if you're not opposed I would like to go deeper than just playing OT like any other time in the game), but I don't know your level of wanting to just have OT in vs have OT in and deeper logic.

Here's a screenshot of OT in action; I probably 50/50 used your code/new code for this.

image

image

image

destilla commented 8 years ago

Also, funny story:

I originally forgot to update the logic to not endlessly kick fgs in ot (last second fg attempt kicked in because time is always < 30 and I never set !playingOT)

So you ended up with stuff like this:

image

The worst I saw was 16OT. Alabama and Kentucky couldn't get ahead of each other for 16 frames. It was like watching an NHL shootout with high school shooters and professional goalies.

jonesguy14 commented 8 years ago

Looks good! For runPlay, I think you are right that it flows pretty well as-is, but I would want logic for the bottom half team to go for it if they are down by more than 3. From there we can expand it later (and play calling in general) to include logic that comes from what strategy the team is running.

Just released an update yesterday with some UI changes, but maybe early next week we can put the OT rules out! Great work!

destilla commented 8 years ago

Awesome! Just created the pull request for OT!

Re: going for it on 4th down when you need a TD -- You actually already had logic that took care of that. The same logic that has a team go for it with less than 5 minutes to play if they need the TD also applies in OT since OT is always gameTime < 300 (because it's negatives).

Thanks for the praise/feedback! It's funny because a few times I would write something, say "well let me see how jonesguy did it", check your code, and it would be the exact same (sometimes down to the formatting and spacing). So thank you for providing me with a great base.

jonesguy14 commented 8 years ago

Fixed with commit e5cd0300f27fa0d7c6fdabb49204fc32876854c8