The gambler's ruin problem is a classic example, which illustrates
the application of one-dimensional Random Walks - a Stochastic Process.
Simulation of a gambling game under the gambler's ruin setup concerns to
a gambler starting the game with an initial capital, where the probability
of winning a particular round is 'p'. If the gambler wins the round, then
1 unit of money is added to the gambler's existing capital and if the gambler loses a round,
then 1 unit of money is deducted from the gambler's existing capital.
The game stops when the gambler reaches his desired amount of money or gets
totally bankrupted (ruined), these two points are known as the absorbed states
of the game, or equivalently absorbed states in the one-dimensional random walk.
The function 'grp.gameplay()' simulates the above described game, where the simulation
runs until one of the absorbed states are reached, i.e., simulating the game until the gambler
reaches to 0 money, getting ruined or wins the desired or targeted amount, eventually
winning the game.
User inputs are accepted, which includes the initial amount of money with which the gambler enters
the game, the probability 'p' of winning each round of the game and lastly the amount of money, which
the gambler wishes to earn from this game being played.The function facilitates majorly in visualizing
the game trajectory of the gambler, along with the overall probability of the gambler winning the entire game.