+ Reply to Thread
Results 1 to 6 of 6

Simulating a tennis game

  1. #1
    Registered User
    Join Date
    03-18-2014
    Location
    Florida, US
    MS-Off Ver
    Excel 2011 (for Mac)
    Posts
    4

    Simulating a tennis game

    i'm new to vba. i've done all the prelims, but now i'm stuck.

    having trouble creating a function which does the following:

    1. acknowledges the current server as a parameter (which has been randomly chosen by code i've already written)

    2. generates the winner of a particular point according to pre-designated statistics
    (pre designated stats are:
    (a) prob of first serve being in
    (b) prob of winning point on first serve
    (c) prob of second serve being in
    (d) prob of winning point on second serve
    (if first and second serve are both out then the other player wins the pt)

    3. simulates a whole game of tennis (player x serving throughout the game) and returns a winner (player x or player y)

    4. then simulates a whole set

    5. then simulates a match (first to 3 sets)

    would appreciate your help, ty.

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Simulating a tennis game

    I think you need a Markov Chain Monte Carlo Simulation (https://www.google.ca/search?q=marko...te+carlo+excel)
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    03-18-2014
    Location
    Florida, US
    MS-Off Ver
    Excel 2011 (for Mac)
    Posts
    4

    Re: Simulating a tennis game

    like i said i'm very new to vba, so specific help would be greatly appreciated

  4. #4
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Simulating a tennis game

    Markov Chain Monte Carlo Simulations are not simple to write in vba, but fortunately they are already freely available online. The link I gave you are examples of MCMC including videos and tutorials. You need to spend some time first understanding MCMC and then you can find solutions on how to implement it with your data.

  5. #5
    Registered User
    Join Date
    03-18-2014
    Location
    Florida, US
    MS-Off Ver
    Excel 2011 (for Mac)
    Posts
    4

    Re: Simulating a tennis game

    i don't want to use any complicated code, just basic functions (functions, subs, ifs, loops, by, msgbox, inputbox etc.)

  6. #6
    Registered User
    Join Date
    03-18-2014
    Location
    Florida, US
    MS-Off Ver
    Excel 2011 (for Mac)
    Posts
    4

    Re: Simulating a tennis game

    Also, the following code is only coming up with a msgbox saying, "the first server is " - i.e. the Name variable does not seem to save/appear?






    Sub TennisSimulator()
    Dim FirstServer As String
    Dim playerA As String
    Dim playerB As String


    Randomize
    DecideFirstServer = Rnd()
    If DecideFirstServer < 0.5 Then
    Name = Sheets("trace").Cells(6, 15).Value
    MsgBox "The first server is " & Name

    Else
    Name = playerB = Sheets("trace").Cells(6, 16).Value
    MsgBox "The first server is " & Name
    End If

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Simulating a game of Boules
    By Darkpagey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-17-2013, 12:55 PM
  2. [SOLVED] Simulating multithreading in vba
    By abousetta in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-23-2012, 01:27 PM
  3. Tennis Ranking
    By clundeen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-12-2011, 10:47 AM
  4. Tennis set combinations
    By Raigmore in forum Excel General
    Replies: 15
    Last Post: 01-04-2006, 10:15 AM
  5. Game score without game being played
    By Sheila in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 05-17-2005, 07:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1