""" print ( msg ) def get_player_names (): player1_name = None while not player1_name : player1_name = input ( "Please enter a valid name for first player: " ). The first player to get to the FINAL position is the winner. If you lands on the head of a snake, you must slide down to the bottom of the snake.Ĥ. If you lands at the bottom of a ladder, you can move up to the top of the ladder.ģ. Move forward the number of spaces shown on the dice.Ģ. Initally both the players are at starting position i.e. Snakes = player_turn_text = snake_bite = ladder_jump = def welcome_msg (): msg = """ġ. SLEEP_BETWEEN_ACTIONS = 1 MAX_VAL = 100 DICE_FACE = 6 # snake takes you down from 'key' to 'value' add a delay of 1 second before performing any action Import time import random import sys # just of effects. Run the game using command python3 snake_ladder.py. IF and ELSEģ- Until one of the player wins do the following:ģ.2- Move the player forward for the value got on the dice roll.ģ.3- If the player is on snake's head, move down to its tailģ.4- If the player is on ladder's bottom, take it to its topģ.5- else remain there and let the second player roll the dice However, it is a fun thing to do for a beginner in order to learn how to use multiple concepts in your program.įew basic concepts used in this code are: I quickly wrote a python program to play text-based snake and ladder game in the terminal.Īny advance python concept is not used in this code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |