You are not logged in or registered. Please login or register to use the full functionality of this board...
The QB64 Edition
Monopoly, a work in progress... - Printable Version

+- The QB64 Edition (http://www.thejoyfulprogrammer.com/qb64/forum)
+ Thread: Monopoly, a work in progress... (/showthread.php?tid=158)



Monopoly, a work in progress... - Waltersmind - 09-23-2014 03:24 AM

Kobolt,

Here is my answer to your question on the chatroom, about how to spread out the houses on the properties:

Code Snippet: [Select]
Num_Properties = 3
Max_Num_Buildings = 5 * Num_Properties

SCREEN _NEWIMAGE(800, 500, 32)

'--------------------------------------------------------------------------------
'-  Create a chart for the data                                                 -
'--------------------------------------------------------------------------------
LOCATE 2, 1: PRINT "Number of Buildings:";
FOR i = 0 TO Max_Num_Buildings
    n$ = LTRIM$(RTRIM$(STR$(i)))
    n$ = STRING$(2 - LEN(n$), " ") + n$
    PRINT "  "; n$;
NEXT
PRINT
PRINT STRING$(24 + Max_Num_Buildings * 4, "-")

FOR q = 1 TO Num_Properties
    PRINT "Property #"; LTRIM$(RTRIM$(STR$(q))); ":          ";
    FOR b = 0 TO Max_Num_Buildings
        PRINT " "; LTRIM$(RTRIM$(STR$(Num_Buildings(b, Num_Properties, q))));: IF b < Max_Num_Buildings THEN PRINT "  ";
    NEXT
    PRINT
NEXT

end

'********************************************************************************
'*                                                                              *
'*  Total_Buildings (In Group) = 0 to (5 * Total_Properties (In Group))         *
'*  Total_Properties (In Group) = 2 or 3                                        *
'*  Current_Property (In Question) = 1 to Total_Properties (In Group)           *
'*                                                                              *
'********************************************************************************
FUNCTION Num_Buildings (Total_Buildings, Total_Properties, Current_Property)

Num_Buildings = INT((Total_Properties / Current_Property + Total_Buildings) * (1 / Total_Properties) - 0.125)

END FUNCTION


One thing to note, this only works with 2 or 3 properties per group. If you use this algorithm for higher properties, the 0.125 needs to change. Once I got the 2 & 3 properties per group working, I stopped. I did try 4 properties in a group and the algorithm failed. But since this is for Monopoly, which only has 2 & 3 properties per group that can have houses (and hotels), I didn't feel the need to perfect the formula.


HERE IS A SCREEN SHOT:

[attachment=282]




Thanks,
Walter Whitman
The Joyful Programmer