I'm trying to use strategy when playing Monopoly by simulating many moves on the board and seeing which properties are landed on the most. I have read that it is the Orange properties, but I want to test this for myself.
I have started small and tried to code the basic moving around the board for the first 10 moves of the game. I will take into account jail, change & community chest cards later. Note: this simulation is for one player only, so it's just one simulated player rolling, and moving around the board.
Here's what I have so far:
1->J 40->Dim List 1 0->N Lbl 1 N+1->N If N>11 Then Goto 3 Else RanInt#(1,6)->A RanInt#(1,6)->B A+B->C J+C->J If J>40 Then J-40->J Else List 1[J]+1->List 1[J] Goto 1 Lbl 3 List 1(display command triangle symbol is here)
But when I run the program, instead of a list as normally displayed, I get just a single displayed number in the top right, as with normal, non list values.
So what's wrong? I have played around with the code, and when I remove the 'Goto 1' part, i.e it doesn't loop back but instead simulates only one move, it does work, and the list display is shown as normal; how I want.
Now I'll explain what I expected each line to do compared to a real life game of Monopoly:
I used 'J' as a variable to represent which space the player is currently on. There are 40 spaces on the Monopoly board so J is set to whichever of the 40 spaces the player is currently on. The program sets J to 1, the 'Go' space on the board to begin.
I used 'N' to represent what number turn the player is on. This is set to 0.
Then the program sets a 40 length list with each element set to 0. I planned to use this as a tally so that when a new space is landed on, it counts up the numbers, counting how many times that space is landed on.
Lbl 1 is the main loop: Rolling the dice, the RanInt #(1,6) are obviously the throwing of each die.
So N starts counting, and with every new throw, N increases, counting the amount of turns.
The two dice scores are added together and J is summed to this value so that the new J represent the new space. Because the board is a loop, and you return back to 'Go' after landing on 'Mayfair' the next line subtracts 40 from J if J gets larger than 40, thus resetting the value back to the 'Go' space or whichever is the new space on the new cycle.
The next line is supposed to increase the element that represents the new landed on space by one. This therefore is the same value as J and so J is used to change this.
Lbl 3 is jumped to when N exceed a certain limit, in this example '11', after 10 turns. I will change this to larger limits to simulate many more turns. The last part of Lbl 1 is what I believe is the cause to this not working, but I can't see what's wrong.
I hope this made sense, and I hope you are able to help.
Alfie.