Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Football by A.R.P.
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
a random person




PostPosted: Fri Dec 02, 2005 8:42 am   Post subject: Football by A.R.P.

hi there this is a football simulater. the story is the team is down by five late in the game, there is only time for about 10 more plays, they MUST score a TD to win the game.

code:

var receiver, yardsGained, down, yardsLeft, yardsToGo, plays : int
var wrName : string
plays := 0
down := 1
yardsToGo := 10
yardsLeft := 50
loop
    randint (receiver, 1, 4)
    if receiver = 1 then
        wrName := "wide receiver"
    elsif receiver = 2 then
        wrName := "slot receiver"
    elsif receiver = 3 then
        wrName := "tight end"
    elsif receiver = 4 then
        wrName := "halfback"
    end if
    if receiver = 4 then
        randint (yardsGained, -3, 6)
    else
        randint (yardsGained, 3, 10)
    end if
    if yardsGained < 0 then
        put "the qaurterback is sacked for a loss of ", yardsGained
        plays := plays + 1
        down := down + 1
        yardsToGo := yardsToGo - yardsGained
        yardsLeft := yardsLeft - yardsGained
        put "it is ", yardsToGo, " and ", down, " on the opponent's ", yardsLeft
    else
        put "the quarterback passes it to the ", wrName, " for a gain of ", yardsGained
        plays := plays + 1
        down := down + 1
        yardsToGo := yardsToGo - yardsGained
        yardsLeft := yardsLeft - yardsGained
        put "it is ", yardsToGo, " and ", down, " on the opponent's ", yardsLeft
    end if
    if yardsToGo <= 0 then
        yardsToGo := 10
        down := 1
    end if
    if down = 4 then
        put "they punt it away"
    elsif yardsLeft = 0 then
        put "Touchdown"
    elsif plays = 10 then
        put "end of the game"
    end if
    exit when plays = 10 or down = 4 or yardsLeft = 0
end loop

if anyone can condense it, be my guest, i still have to put in interseptions and all that stuff. if you like it, bits will be nice *wink* *wink*. just joking. please give feedback, and if you want to criticize then give a possible inprovment aswell
Sponsor
Sponsor
Sponsor
sponsor
AzureFire




PostPosted: Fri Dec 02, 2005 6:41 pm   Post subject: (No subject)

Tip: add some way of allowing the user to interact. Like add a bunch of different plays. Each one improves chances kind of thing. And.. Add graphics to go along with each of the outcomes.
a random person




PostPosted: Sat Dec 03, 2005 9:53 am   Post subject: (No subject)

thank you AzureFire, I will try that and another thing i'm adding in is feild goals the comp kicks automatically on fourth down, there is no sense punting it a way on the goalline. one problem, it dosent say 1st and 10 it says the down and negitive something, how do i fix that.

can more people give suggestions for inprovement.
a random person




PostPosted: Mon Dec 12, 2005 12:30 pm   Post subject: edit

i have added alot to this game like fatuigue and a luck factor
i have totally revamped the kicking as well, and th QB is less likely to be sacked.

code:

var fatuigue, receiver, yardsGained, down, yardsLeft, yardsToGo, plays, incomplete, luck : int
var wrName : string
fatuigue := 15
plays := 0
down := 1
yardsToGo := 10
yardsLeft := 50
luck := 2
loop
    randint (incomplete, 1, luck)
    randint (receiver, 1, 4)
    if receiver = 1 then
        wrName := "wide receiver"
    elsif receiver = 2 then
        wrName := "slot back"
    elsif receiver = 3 then
        wrName := "tight end"
    elsif receiver = 4 then
        wrName := "halfback"
    end if
    if receiver = 4 then
        randint (yardsGained, -3, fatuigue div 2)
    else
        randint (yardsGained, 3, fatuigue)
    end if
    if yardsGained < 0 then
        put "the qaurterback is sacked for a loss of ", yardsGained
        plays := plays + 1
        down := down + 1
        fatuigue := fatuigue - 1
        yardsToGo := yardsToGo - yardsGained
        yardsLeft := yardsLeft - yardsGained
        luck := luck + 1
        put "it is ", down, " and ", yardsToGo, " on the opponent's ", yardsLeft
    elsif incomplete = 1 then
        put "the ball is is touched by the defender and the pass is incomplete"
        luck := 2
        down := down + 1
        fatuigue := fatuigue - 1
        put "it is ", down, " and ", yardsToGo, " on the opponent's ", yardsLeft
    else
        put "the quarterback passes it to the ", wrName, " for a gain of ", yardsGained
        plays := plays + 1
        down := down + 1
        yardsToGo := yardsToGo - yardsGained
        yardsLeft := yardsLeft - yardsGained
        luck := luck + 1
        put "it is ", down, " and ", yardsToGo, " on the opponent's ", yardsLeft
    end if
    if yardsToGo <= 0 then
        yardsToGo := 10
        down := 1
        put "it is 1 and 10 on the opponent's ", yardsLeft
    end if
    if down = 4 then
        put "they are kicking a feild goal"
        if yardsLeft > 33 then
            put "no good"
        else
            put "it's good"
        end if
    elsif yardsLeft <= 0 then
        put "Touchdown"
    elsif plays = 15 then
        put "end of the game"
    end if
    exit when plays = 15 or down = 4 or yardsLeft <= 0
end loop

please rate both versions to show how much it improved

edit: fixed my speeling.
spelling*
codemage




PostPosted: Mon Dec 12, 2005 1:04 pm   Post subject: (No subject)

Nothing major to point out:

On plays where you get a 1st down, you shouldn't say the old downage first.

IE
it is 3 and -9 on the opponent's 25 %don't say this line
it is 1 and 10 on the opponent's 25

Also, when your next 1st down is a touchdown, it's called down & goal.

IE
it is 2 and 10 on the opponent's 5 %incorrect
it is 2 and goal on the opponent's 5 %correct
Paul




PostPosted: Tue Dec 13, 2005 1:03 am   Post subject: (No subject)

And fix the spelling mistakes Razz
a random person




PostPosted: Wed Dec 14, 2005 6:49 am   Post subject: (No subject)

V3 of this game will come iut shortly, i've noticed the spelling just after i posted. in V3 ther will be user input, they can choose how far you want the players to go out, shorter passes are more likley to suceed. however, longer passes gain more yards. the user will also decide to wether to pass or kick on the 4th down. all other features i'm leaving for the user to figure out.
Paul




PostPosted: Wed Dec 14, 2005 9:03 pm   Post subject: (No subject)

Is it just me, or does no one ever score touchdowns in this game? :S
Sponsor
Sponsor
Sponsor
sponsor
codemage




PostPosted: Thu Dec 15, 2005 1:54 pm   Post subject: (No subject)

I made a visual basic version (in university) of what you're describing - except it has graphics instead of text.

I should post it so so you have something to strive towards (or against). Twisted Evil

Note to self...
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: