Schedule Remains using Monte Carlo Method [closed]

0

I have little experience in Java and am trying to apply the Monte Carlo Method in Combinatorial Game Theory. I am trying to demonstrate the Method in the Undead Game where it will have to be solved using random steps. For the method to be effective about 10,000 simulations will have to be made, the most effective victories and steps have to be recorded. The Monte Carlo method has already been applied in other games such as Go Computer. The problems I have had and the lack of design, if it is better to have everything separated by classes, how to record the results, and how to organize the program in order to play randomly.

So far I have the basic gameplay, and logic behind the allowed steps.

    
asked by anonymous 13.04.2015 / 03:45

1 answer

10

Define a data structure

At a high level, you basically need to define a suitable data structure to represent the board for the Game.

In the case of Java, it can be a two-dimensional array with the width and height of the board. For example:

int[][] tabuleiro;

Define how the information will be represented

As this array can not be deformed to fit the board, I suggest starting it with the values:

  • -1 (a negative) where it is forbidden to place parts
  • 0 (zero) for missing parts
  • 1 (one) where there is a part

Initialize with the initial state

Create a method that fills the values in any vector, following the rules mentioned above, according to the initial game board.

Implement the rules of the Game

Implement a method to move parts:

mover(origemX, origemY, destinoX, destinoY)

The method should check whether movement is allowed or not. For example;

  • The source position must have a part, that is, the value of the array at position (origemX, origemY) must be equal to 1 .
  • The target position must not contain a part and must be a valid position, ie the value of the array at position (destinoX, destinoY) must be equal to 0 .
  • The difference of positions between source and destination should be two vertical or horizontal boxes.
  • There must be a part between the source and the destination.
  • And so on. The above topics are just a simple summary to make the move.

    After verifying if motion is possible, then the method must apply the changes in the vector to perform the motion:

  • The source position of the array receives 0 .
  • The target position of the array receives 1 .
  • The part that was "skipped" from the array gets 0 .
  • Implement the solution algorithm

    Now that you have the board and the action implemented, you have to implement the solution as well.

    Unfortunately, I do not know how to solve this board using the Monte Carlo method, so I can not give an initial direction at this point.

    However, before you implement anything, you should first resolve the issue. This means that you must have somewhere a specification of the algorithm that resolves.

    Once you have this algorithm, that is, a sequence of steps that solves the problem after a limited number of iterations, then it will be much easier to think of a solution joining everything you have.

    Record of operations

    Logging the steps performed by the solution algorithm is something very simple.

    At each step of the algorithm, prints the "decisions" taken on the console or in a text file.

    Also, in the mover() method mentioned above, also print the movement being performed. For example:

      

    Moving part from (sourceX, sourceY) to (destinationX, destinationY)

    Or in case of an invalid movement:

      

    Invalid motion attempt from (sourceX, sourceY) to (destinationX, destinationY)

    Only with this trace can you rebuild the game step by step on a real board.

        
    13.04.2015 / 17:32