}

Three aligned

1989/07/01 Arrojeria, Eustakio - Elhuyar Zientziaren Komunikazioa | Lizaso, Pili - Informatika SailaElhuyar Fundazioa Iturria: Elhuyar aldizkaria

We come again with the intention of offering a new program in this section in which we are. However, as we believe that in all things a small break is good, we have entered summer and wanted to take advantage of the holiday atmosphere to get out of the line that we have worked throughout the year.

While most programs so far have been related little or more to subjects (either physics, mathematics, etc. ), it seems more appropriate to include a game in this number.

The game of three alignments will surely be known to all, but just in case here go the rules.

  1. Each player has three chips, each player's chips being different.
  2. The game consists of aligning three equal chips.
  3. The first player must place the first tile in the center and it will never move from there. Each move will move a tile.

The possible solutions that each player can obtain are:

Although the explanation of the program and the program itself are longer than on other occasions, don't panic because it will be very easy to use. So cheer and play quietly.

Parts of the program:

  • 10-50: Program initialization. It defines the possible results or solutions of each player (50).
  • 60-90: Represent the table.
  • 100-210: Choose whether they will be 1 or 2 players and present each. If you are a single player, you will play with the computer;
    the player must choose who starts the game.
  • 220: The first tile of the first player will be automatically placed in the center and cannot be moved around.
  • 230-420: Locating the chips for the first time on the
    table.If the player who has to move the chips is a computer, the call will be made to a subroutine (250,340). In it (690) it will analyze the place
    in which it is convenient to place the tab. If the player is not a computer, the player himself will be asked where he wants to place the chip, being the only condition that must meet his answer: Being between 1 and 9, not having 5 (the medium) and not having occupied that position. If the chosen position is free, the
    chip corresponding to the player who is playing (310, of player 1, 400, 2) will be placed in the same position and that position will be marked by a representative sign. If the chosen position is already occupied, a message will be
    sent informing the problem. As soon as a player has placed the third tile and after each subsequent play a line must be checked. (330,410).
  • 430-620: Once the three tiles are placed in the table, each player must continue to move in turns until one of them completes the line. If the player is not the computer, he will
    be asked where he wants to move the tile and if the requested game is logical, that is, if the two given positions are from 1 to 9, except the 5 (since it can not be played after the initial occupation of this position), if in the place you want to free there was a tile of 600 (490), if the space was empty. After each play you will have to see if the one who has played at that time has managed to complete the line (610).
  • 630-680: When the program detects that a line has been formed, it will indicate who has been the winner. The main program we have seen
    so far would be somehow, but as is often the case, the subroutines are as important as the main program. Earlier we mentioned one that checks if the line has been completed (920-1020). In addition, there are three other subroutines that define the points that the computer takes into account when playing and, in some way, their “behavior”. Let's go on to analyze more closely each of these subsections.
  • 920-1030: Check action: The main program will indicate the player who has played the last move. This subroutine will take into account the positions that occupy the chips of each player, creating two different chains; one for each player (BAT$, BI$). The function of this subroutine will
    be to check if the sub-task that corresponds to the player is among its possible results (KAT$1, KAT$2), as well as the winner.
  • 690-910: Define action: The game that the computer must play is defined, calculating where the chip should move. To define where the tab should move, it will take up to 3 steps:
    1. If he can complete the line
      to define

    2. if the other line
      is
    3. define the first available space
      in noratzatambaldinambaldi

    In the first two cases the call to action is made in which the Line can be completed. To define where to move, the call will move to action.

  • 1040-1190: Action that can form the line Analyzes the chances of winning a player, comparing the situation of the player with its possible solutions. To define NORA, the two positions of the situation must match the two positions of a possible result and the third position that composes the result must be free. NORA will be that third position.
  • 1200-1360: Where to move the
    action We must differentiate two possible cases:
    1. If you do not yet have any tiles to locate, you should not define FROM.
    2. When the three tiles are already placed in the table:
    • If he has seen that he can complete the line, he must leave the two tiles that match the result, moving the other.
    • If he cannot get it, he must prevent the other player. To do this, you must analyze the possibilities of the other person and take into account the possible conditions that the movement of each of their chips can have.
(Note: To see the image go to pdf).

Gai honi buruzko eduki gehiago

Elhuyarrek garatutako teknologia