{"id":87,"date":"2025-10-17T13:55:22","date_gmt":"2025-10-17T13:55:22","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/l_rankins\/?p=87"},"modified":"2025-10-17T13:55:22","modified_gmt":"2025-10-17T13:55:22","slug":"blog-12-pig-maddness","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/l_rankins\/2025\/10\/17\/blog-12-pig-maddness\/","title":{"rendered":"BLOG 12: PIG MADDNESS"},"content":{"rendered":"\n<p><strong>Today I made Pig from a Youtube tutorial<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import random\n\n\ndef roll():\n    min_value = 1\n    max_value = 6\n    roll = random.randint(min_value, max_value)\n\n    return roll<\/code><\/pre>\n\n\n\n<p><strong>This shows the max and minimum numbers that the program can choose by using the random function.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>while True:\n    players = input(\"Enter the number of players (2 - 4): \")\n    if players.isdigit():\n        players = int(players)\n        if 2 &lt;= players &lt;= 4:\n            break\n        else:\n            print(\"Must be between 2 - 4 players.\")\n    else:\n        print(\"Invalid, try again.\")\n<\/code><\/pre>\n\n\n\n<p><strong>This one is the Input for the player for the amount of players and if a player puts anything other than 2, 3 or 4 it denies it.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>max_score = 50\nplayer_scores = &#91;0 for _ in range(players)]\n\nwhile max(player_scores) &lt; max_score:\n    for player_idx in range(players):\n        print(\"\\nPlayer number\", player_idx + 1, \"turn has just started!\")\n        print(\"Your total score is:\", player_scores&#91;player_idx], \"\\n\")\n        current_score = 0\n\n        while True:\n            should_roll = input(\"Would you like to roll (y)? \")\n            if should_roll.lower() != \"y\":\n                break\n\n            value = roll()\n            if value == 1:\n                print(\"You rolled a 1! Turn done!\")\n                current_score = 0\n                break\n            else:\n                current_score += value\n                print(\"You rolled a:\", value)\n\n            print(\"Your score is:\", current_score)\n\n        player_scores&#91;player_idx] += current_score\n        print(\"Your total score is:\", player_scores&#91;player_idx])<\/code><\/pre>\n\n\n\n<p><strong>This one adds the score together and if a players get a one it resets the players score back to zero.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>max_score = max(player_scores)\nwinning_idx = player_scores.index(max_score)\nprint(\"Player number\", winning_idx + 1,\n      \"is the winner with a score of:\", max_score)<\/code><\/pre>\n\n\n\n<p><strong>This one prints the winners score and announces the winner.<\/strong><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I made Pig from a Youtube tutorial This shows the max and minimum numbers that the program can choose [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-87","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/posts\/87","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/comments?post=87"}],"version-history":[{"count":1,"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/posts\/87\/revisions"}],"predecessor-version":[{"id":89,"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/posts\/87\/revisions\/89"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/media?parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/categories?post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/tags?post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}