Mobbs
A Large Portion, Yes
- Joined
- Nov 1, 2000
- Posts
- 84,728
- Reaction score
- 102,009
- Location
- www.footypedia.com/qooty
- Other Teams
- Fitzroy FC
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.

import random
import pygame
pygame.init()
ScreenHeight = 400
ScreenWidth = 640
win = pygame.display.set_mode((ScreenWidth, ScreenHeight))
pygame.display.set_caption("PyQooty")
start_bg = pygame.image.load('start.png')
game_bg = pygame.image.load('gamescreen.png')
myfont_main = pygame.font.SysFont("Verdana", 20)
myfont_game = pygame.font.SysFont("Verdana", 28)
clock = pygame.time.Clock()
Bluey_Green = (0, 200, 200)
Light_Green = (100, 255, 100)
Green = (0, 255, 0)
White = (255, 255, 255)
def main_menu():
win.blit(start_bg, (0,0))
mouse
#print(mouse)
#coordinates1 = (90, 275, 110, 25)
#coordinates2 = (90, 300, 140, 25)
#coordinates3 = (90, 325, 110, 25)
#coordinates4 = (90, 350, 130, 25)
if 90 + 110 > mouse[0] > 90 and 275 + 25 > mouse[1] > 275:
menu_text1 = myfont_main.render('Play Footy', 1, Light_Green)
if click[0] == 1:
global main
global playing_match
main = False
playing_match = True
pygame.time.delay(200)
else:
menu_text1 = myfont_main.render('Play Footy', 1, Bluey_Green)
if 90 + 140 > mouse[0] > 90 and 300 + 25 > mouse[1] > 300:
menu_text2 = myfont_main.render('Setup League', 1, Light_Green)
else:
menu_text2 = myfont_main.render('Setup League', 1, Bluey_Green)
if 90 + 110 > mouse[0] > 90 and 325 + 25 > mouse[1] > 325:
menu_text3 = myfont_main.render('Stats Type', 1, Light_Green)
else:
menu_text3 = myfont_main.render('Stats Type', 1, Bluey_Green)
if 90 + 130 > mouse[0] > 90 and 350 + 25 > mouse[1] > 350:
menu_text4 = myfont_main.render('View Results', 1, Light_Green)
else:
menu_text4 = myfont_main.render('View Results', 1, Bluey_Green)
win.blit(menu_text1, (90, 275))
win.blit(menu_text2, (90, 300))
win.blit(menu_text3, (90, 325))
win.blit(menu_text4, (90, 350))
pygame.display.update()
class sim_game(object):
game_minutes = 0
game_seconds = 0
QTR = 1
speed = 4
homeTeam = "Home Sample"
homeTeamShort = "HOM"
home_goals = 0
home_behinds = 0
home_score = 0
awayTeam = "Away Sample"
awayTeamShort = "AWY"
away_goals = 0
away_behinds = 0
away_score = 0
# def __init__(self, game_minutes, game_seconds, QTR, speed, homeTeam, homeTeamShort, home_goals, home_behinds, home_score, awayTeam, awayTeamShort, away_goals, away_behinds, away_score):
# self.game_minutes = game_minutes
# self.game_seconds = game_seconds
# self.QTR = QTR
# self.speed = speed
# self.homeTeam = homeTeam
# self.homeTeamShort = homeTeamShort
# self.home_goals = home_goals
# self.home_behinds = home_behinds
# self.home_score = home_score
# self.awayTeam = awayTeam
# self.awayTeamShort = awayTeamShort
# self.away_goals = away_goals
# self.away_behinds = away_behinds
# self.away_score = away_score
def GamePlay():
if sim_game.QTR <= 4 and sim_game.game_minutes <= 25:
sim_game.game_seconds += sim_game.speed
#bunch of if statements regarding randomised events of the contest
#to roll through here
pygame.time.delay(100)
if sim_game.game_seconds >= 60:
sim_game.game_minutes += 1
sim_game.game_seconds -= 60
if sim_game.game_minutes == 25:
sim_game.QTR += 1
sim_game.game_minutes = 0
sim_game.game_seconds = 0
def match_sim_running():
sim_running = True
while sim_running:
win.blit(game_bg, (0,0))
QTR_display = myfont_game.render(str(sim_game.QTR), 1, Green)
win.blit(QTR_display, (100, 15))
if sim_game.game_seconds < 10:
GameTime_display = myfont_game.render(str(sim_game.game_minutes) + ":0" + str(sim_game.game_seconds), 1, Green)
else:
GameTime_display = myfont_game.render(str(sim_game.game_minutes) + ":" + str(sim_game.game_seconds), 1, Green)
win.blit(GameTime_display, (240, 15))
homeTeam_display = myfont_game.render(sim_game.homeTeamShort, 1, White)
win.blit(homeTeam_display, (110, 70))
awayTeam_display = myfont_game.render(sim_game.awayTeamShort, 1, White)
win.blit(awayTeam_display, (110, 220))
sim_game.GamePlay()
sim_running = False
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
run = True
main = True
playing_match = False
while run:
pygame.event.get()
clock.tick(12)
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
if main:
main_menu()
if playing_match:
sim_game
sim_game.match_sim_running()
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()
def GamePlayTime():
if sim_game.QTR <= 4 and sim_game.game_minutes <= 25:
global match_status
match_status = "In Progress"
sim_game.game_seconds += sim_game.speed
pygame.time.delay(100)
else:
match_status = "Finished"
if sim_game.game_seconds >= 60:
sim_game.game_minutes += 1
sim_game.game_seconds -= 60
if sim_game.game_minutes >= 25:
sim_game.QTR += 1
sim_game.game_minutes = 0
sim_game.game_seconds = 0
sim_game.play_posLine = 0
sim_game.play_posCol = 0
def GamePlayBallPos():
possessionRoll = random.randint(0,1)
if possessionRoll == 0:
possession = "Home"
elif possessionRoll == 1:
possession = "Away"
if possession == "Home":
movementRoll = random.randint(0,1)
if movementRoll == 0:
sim_game.play_posLine += 0
elif movementRoll == 1:
sim_game.play_posLine += 1
elif possession == "Away":
movementRoll = random.randint(0,1)
if movementRoll == 0:
sim_game.play_posLine -= 0
elif movementRoll == 1:
sim_game.play_posLine -= 1
if sim_game.play_posLine == 3:
shotRollHome = random.randint(0,1)
if shotRollHome == 0:
sim_game.home_behinds += 1
sim_game.play_posLine = 2
elif shotRollHome == 1:
sim_game.home_goals += 1
sim_game.play_posLine = 0
sim_game.play_posCol = 0
if sim_game.play_posLine == -3:
shotRollAway = random.randint(0,1)
if shotRollAway == 0:
sim_game.away_behinds += 1
sim_game.play_posLine = -2
elif shotRollAway == 1:
sim_game.away_goals += 1
sim_game.play_posLine = 0
sim_game.play_posCol = 0
sim_game.home_score = sim_game.home_goals * 6 + sim_game.home_behinds
sim_game.away_score = sim_game.away_goals * 6 + sim_game.away_behinds
Log in to remove this Banner Ad
Think my inclination is just to for every loopAnd some more found. Possibly this is the same thing, but converted into a choose your own adventure style of presentation:
View attachment 759030View attachment 759031View attachment 759032View attachment 759033View attachment 759034View attachment 759035
This is pretty much what the Qooty code does.Think my inclination is just to for every loop
Rand - who wins possession of the ball
Rand - location of next contest
Check if location is at either end of the field in which case register a score.
If goal return the ball to centre, if behind oppo gets ball at the B line
All the other stuff can just draw from a list of random labels and count how many times they get invoked
Yes it is possible, immediate priority would be to simply replicate the functionalities of the existing sim thoughI'm not going to pretend to understand coding but I do understand the value of work you've put in Kennedy Parker. It looks fantastic.
Is there room to potentially include boundary interactions in this newer version? ie. Mobbs' rank 0 or 6 was a score, is it possible to run a file [sic terminology] 0 or 4 with the boundary action resulting in a throw in if the ball touches the ground or hand and a randomly generated outcome of a free kick or throw in if the ball is kicked over?
def map_play():
Pos_Coordinates = (sim_game.play_posCol, sim_game.play_posLine)
if Pos_Coordinates == (-1,2) and possession == "Away":
away_rBP_display = pygame.draw.rect(win, Soft_Red, (400, 55, 40, 15), 0)
else:
away_rBP_display = pygame.draw.rect(win, Red, (400, 55, 40, 15), 0)
if Pos_Coordinates == (0, 2) and possession == "Away":
away_FB_display = pygame.draw.rect(win, Soft_Red, (470, 55, 40, 15), 0)
else:
away_FB_display = pygame.draw.rect(win, Red, (470, 55, 40, 15), 0)
if Pos_Coordinates == (1, 2) and possession == "Away":
away_lBP_display = pygame.draw.rect(win, Soft_Red, (540, 55, 40, 15), 0)
else:
away_lBP_display = pygame.draw.rect(win, Red, (540, 55, 40, 15), 0)
if Pos_Coordinates == (-1, 2) and possession == "Home":
home_lFP_display = pygame.draw.rect(win, Soft_Blue, (400, 70, 40, 15), 0)
else:
home_lFP_display = pygame.draw.rect(win, Blue, (400, 70, 40, 15), 0)
if Pos_Coordinates == (0, 2) and possession == "Home":
home_FF_display = pygame.draw.rect(win, Soft_Blue, (470, 70, 40, 15), 0)
else:
home_FF_display = pygame.draw.rect(win, Blue, (470, 70, 40, 15), 0)
if Pos_Coordinates == (1, 2) and possession == "Home":
home_rFP_display = pygame.draw.rect(win, Soft_Blue, (540, 70, 40, 15), 0)
else:
home_rFP_display = pygame.draw.rect(win, Blue, (540, 70, 40, 15), 0)
if Pos_Coordinates == (-1, 1) and possession == "Away":
away_rHBF_display = pygame.draw.rect(win, Soft_Red, (400, 100, 40, 15), 0)
else:
away_rHBF_display = pygame.draw.rect(win, Red, (400, 100, 40, 15), 0)
if Pos_Coordinates == (0, 1) and possession == "Away":
away_CHB_display = pygame.draw.rect(win, Soft_Red, (470, 100, 40, 15), 0)
else:
away_CHB_display = pygame.draw.rect(win, Red, (470, 100, 40, 15), 0)
if Pos_Coordinates == (1, 1) and possession == "Away":
away_lHBF_display = pygame.draw.rect(win, Soft_Red, (540, 100, 40, 15), 0)
else:
away_lHBF_display = pygame.draw.rect(win, Red, (540, 100, 40, 15), 0)
if Pos_Coordinates == (-1, 1) and possession == "Home":
home_lHFF_display = pygame.draw.rect(win, Soft_Blue, (400, 115, 40, 15), 0)
else:
home_lHFF_display = pygame.draw.rect(win, Blue, (400, 115, 40, 15), 0)
if Pos_Coordinates == (0, 1) and possession == "Home":
home_CHF_display = pygame.draw.rect(win, Soft_Blue, (470, 115, 40, 15), 0)
else:
home_CHF_display = pygame.draw.rect(win, Blue, (470, 115, 40, 15), 0)
if Pos_Coordinates == (1, 1) and possession == "Home":
home_rHFF_display = pygame.draw.rect(win, Soft_Blue, (540, 115, 40, 15), 0)
else:
home_rHFF_display = pygame.draw.rect(win, Blue, (540, 115, 40, 15), 0)
if Pos_Coordinates == (-1, 0) and possession == "Away":
away_rW_display = pygame.draw.rect(win, Soft_Red, (400, 170, 40, 15), 0)
else:
away_rW_display = pygame.draw.rect(win, Red, (400, 170, 40, 15), 0)
if Pos_Coordinates == (0, 0) and possession == "Away":
away_C_display = pygame.draw.rect(win, Soft_Red, (470, 170, 40, 15), 0)
else:
away_C_display = pygame.draw.rect(win, Red, (470, 170, 40, 15), 0)
if Pos_Coordinates == (1, 0) and possession == "Away":
away_lW_display = pygame.draw.rect(win, Soft_Red, (540, 170, 40, 15), 0)
else:
away_lW_display = pygame.draw.rect(win, Red, (540, 170, 40, 15), 0)
if Pos_Coordinates == (-1, 0) and possession == "Home":
home_lW_display = pygame.draw.rect(win, Soft_Blue, (400, 185, 40, 15), 0)
else:
home_lW_display = pygame.draw.rect(win, Blue, (400, 185, 40, 15), 0)
if Pos_Coordinates == (0, 0) and possession == "Home":
home_C_display = pygame.draw.rect(win, Soft_Blue, (470, 185, 40, 15), 0)
else:
home_C_display = pygame.draw.rect(win, Blue, (470, 185, 40, 15), 0)
if Pos_Coordinates == (1, 0) and possession == "Home":
home_rW_display = pygame.draw.rect(win, Soft_Blue, (540, 185, 40, 15), 0)
else:
home_rW_display = pygame.draw.rect(win, Blue, (540, 185, 40, 15), 0)
if Pos_Coordinates == (-1, -1) and possession == "Away":
away_rHFF_display = pygame.draw.rect(win, Soft_Red, (400, 240, 40, 15), 0)
else:
away_rHFF_display = pygame.draw.rect(win, Red, (400, 240, 40, 15), 0)
if Pos_Coordinates == (0, -1) and possession == "Away":
away_CHF_display = pygame.draw.rect(win, Soft_Red, (470, 240, 40, 15), 0)
else:
away_CHF_display = pygame.draw.rect(win, Red, (470, 240, 40, 15), 0)
if Pos_Coordinates == (1, -1) and possession == "Away":
away_lHFF_display = pygame.draw.rect(win, Soft_Red, (540, 240, 40, 15), 0)
else:
away_lHFF_display = pygame.draw.rect(win, Red, (540, 240, 40, 15), 0)
if Pos_Coordinates == (-1, -1) and possession == "Home":
home_lHBF_display = pygame.draw.rect(win, Soft_Blue, (400, 255, 40, 15), 0)
else:
home_lHBF_display = pygame.draw.rect(win, Blue, (400, 255, 40, 15), 0)
if Pos_Coordinates == (0, -1) and possession == "Home":
home_CHB_display = pygame.draw.rect(win, Soft_Blue, (470, 255, 40, 15), 0)
else:
home_CHB_display = pygame.draw.rect(win, Blue, (470, 255, 40, 15), 0)
if Pos_Coordinates == (1, -1) and possession == "Home":
home_rHBF_display = pygame.draw.rect(win, Soft_Blue, (540, 255, 40, 15), 0)
else:
home_rHBF_display = pygame.draw.rect(win, Blue, (540, 255, 40, 15), 0)
if Pos_Coordinates == (-1, -2) and possession == "Away":
away_rFP_display = pygame.draw.rect(win, Soft_Red, (400, 285, 40, 15), 0)
else:
away_rFP_display = pygame.draw.rect(win, Red, (400, 285, 40, 15), 0)
if Pos_Coordinates == (0, -2) and possession == "Away":
away_FF_display = pygame.draw.rect(win, Soft_Red, (470, 285, 40, 15), 0)
else:
away_FF_display = pygame.draw.rect(win, Red, (470, 285, 40, 15), 0)
if Pos_Coordinates == (1, -2) and possession == "Away":
away_lFP_display = pygame.draw.rect(win, Soft_Red, (540, 285, 40, 15), 0)
else:
away_lFP_display = pygame.draw.rect(win, Red, (540, 285, 40, 15), 0)
if Pos_Coordinates == (-1, -2) and possession == "Home":
home_lBP_display = pygame.draw.rect(win, Soft_Blue, (400, 300, 40, 15), 0)
else:
home_lBP_display = pygame.draw.rect(win, Blue, (400, 300, 40, 15), 0)
if Pos_Coordinates == (0, -2) and possession == "Home":
home_FB_display = pygame.draw.rect(win, Soft_Blue, (470, 300, 40, 15), 0)
else:
home_FB_display = pygame.draw.rect(win, Blue, (470, 300, 40, 15), 0)
if Pos_Coordinates == (1, -2) and possession == "Home":
home_rBP_display = pygame.draw.rect(win, Soft_Blue, (540, 300, 40, 15), 0)
else:
home_rBP_display = pygame.draw.rect(win, Blue, (540, 300, 40, 15), 0)
away_rBP_display
away_FB_display
away_lBP_display
home_lFP_display
home_FF_display
home_rFP_display
away_rHBF_display
away_CHB_display
away_lHBF_display
home_lHFF_display
home_CHF_display
home_rHFF_display
away_rW_display
away_C_display
away_lW_display
home_lW_display
home_C_display
home_rW_display
away_rHFF_display
away_CHF_display
away_lHFF_display
home_lHBF_display
home_CHB_display
home_rHBF_display
away_rFP_display
away_FF_display
away_lFP_display
home_lBP_display
home_FB_display
home_rBP_display
Next season would be no chance given I still need to create modifiable inputs, and multiple new menu pages + options. 30 might be the optimistic time frame.Looking good, Kennedy Parker
Can you keep me informed on test runs, etc? If it goes well, I will look at introducing it next season or S30
As long as it happens before Mobbs gets old and saggyNext season would be no chance given I still need to create modifiable inputs, and multiple new menu pages + options. 30 might be the optimistic time frame.
Mobbs said:I would love to see someone new and sassy create a new program that superseded Qooty, and would support them entirely. If I was any more compliant I'd be doing naked starjumps in a fast food store.
My internet is so strong that this video stopped to buffer three times during it's whole 4 seconds of play time.
Guess I'm 20 years too late thenAs long as it happens before Mobbs gets old and saggy
It'll take me some work to look at the code and try to understand what I did.Mobbs
I've just added in some basic variations in ball movement i.e. distinctions between long kicks, short kicks, handballs
Curious what was your probability distribution. I found in order to make the game run at a semi-realistic pace I needed to make each transaction a 55% chance of the player "Holding up play" meaning they stay in the same part of the ground with no advancement of the ball.
Speed of the game might be because there's no flow in my current coding every single transaction is randomised at the moment.There was no "holding up play". He either kicked it, handpassed it, or lost possession (through various means but all via the same random dice roll).
This seems to be a reasonably close interpretation of the flow from the point of having possession, on to having disposed of it in some way. It's a bunch of extracts, there's heaps of updatng of stats etc code removed from the following:
DoesHeLoseBall:
IF RND(1) >= .87 THEN ' NOT MUCH CHANCE OF LOSING BALL
(anything from being dipossessed to kicking it out on the full)
DoesHeHaveABounce:
IF RND(1) < .85 THEN StoppedBouncing% = 1: GOTO DoesHeHandball ' CHANCE OF BOUNCING '
bounces happen (advance one rank for every 2nd bounce)
DoesHeHandball:
IF V = 5 AND RND(1) > .25 THEN GOTO DoesHeHaveShotAtGoal ' LESS CHANCE IN FRONT OF GOAL
IF V = 5 AND H = 2 AND NOT FP AND RND(1) > .15 THEN GOTO DoesHeHaveShotAtGoal ' EVEN LESS CHANCE IF FULL FORWARD
IF RND(1) < .5 THEN GOTO DoesHeHaveShotAtGoal ' 5 HANDPASSES PER 5 KICKS
handballs happen
DoesHeHaveShotAtGoal:
IF V = 5 OR (V = 4 AND RND(1) > .75) OR (V = 3 AND RND(1) > .92) THEN
shots on goal happen
' # WHO DOES HE KICK THE BALL TO #
IsItCrossGround:
IF RND(1) > .32 THEN KickedForward% = 1 ELSE KickedForward% = 0 ' increase line 68% of time, 32% is cross-ground kick
then a random target position is chosen
The flow was :
1. The guy gets the ball.
2. The guy has the ball.
3. The guy either uses or loses the ball.
4. goto 1
I actually inserted time delays based on the actual clock, between transactions.Speed of the game might be because there's no flow in my current coding every single transaction is randomised at the moment.
The actual clock should have nothing to do with the amount of transactions because the game 'time' is not based upon a timer at all, it's just a count. Each loop the counter will add the 'speed' value onto the 'time' and concurrently produce one transaction of play. Every time the program passes through the loop it produces another line of play.I actually inserted time delays based on the actual clock, between transactions.
You can't just tweak a FOR ... NEXT time delay because the game is supposed to be portable and different computers will run the process at different speeds.
That's correct for my approach too, but there are two different concepts of time. That's why I had both a Speed and a Game Pace option.The actual clock should have nothing to do with the amount of transactions because the game 'time' is not based upon a timer at all, it's just a count. Each loop the counter will add the 'speed' value onto the 'time' and concurrently produce one transaction of play. Every time the program passes through the loop it produces another line of play.