Basic Idea of the Marlowe contract
The contract begins with each of the players sequentially depositing a fixed amount of ADA into the contract, this was done using deposit actions written in series of When contracts. The players would have to make the deposit within 10 slots after the contract begins, if not the contract closes and the all the money is refunded accordingly. The state of each person's win is stored using the Let contract with suitable identifiers. For eg. "player-1" -> 0 if not won, and 1 if won. At the beginning of the contract all the player's win state is initialized to 0. After the deposits have been made, there is a "savings period" of 80 slots during which all the deposits are locked up. On the 91 slot and on wards, each player depending on whether he/she has won has a chance to claim all the ADA locked up in the contract, this is facilitated by the user choice action. Depending on who was the first to make a choice (a number between 1 -> 5) within slot 100, wins the lottery!. This whole process is repeated with the exception that that player who claimed the previous lottery will now not be able to make a choice. This is facilitated by the If contract checking the state of the win state of each player. The slots will also be offset accordingly for the next round.