(41CX) Master Logic - Mastermind - Code-breaking Game with letters combination
|
08-13-2024, 12:01 AM
(This post was last modified: 08-13-2024 12:05 AM by Nihotte(lma).)
Post: #2
|
|||
|
|||
RE: (41CX) Master Logic - Mastermind - Code-breaking Game with letters combination
Little reflection by myself about this program. It dates back to 2004. Of course, this program could be improve. From several axes, I think. In fact, it makes the job in good conditions. But some details make it is not longer exactly in line with my ideal finish, today. If you see at the start of the programm, you find a "natural" instruction CLRG : it makes clean the environment before using it. This way was usual in a program to run on the HP11C; or the HP34C, probably. These calculators had a restrictive memory space and it was really more easy to free this work space with a single instruction. Now, I rarely use an instruction with such radical effects. I'm more carreful when using a program that must coexist with several others. This is all the more important as the memory space is shared and certain registers may contain constants which must be preserved. Well, in the context of this program, it's actually quite simple: just replace the CLRG instruction with two others: CLX followed by STO 23. Because, this is indeed the only interest of the CLRG here. The random number generator used to generate the code to be found is not exceptional. I now commonly use a dedicated number generator by calling a specialized routine (XEQ RAN#, for example) and I keep a root in a dedicated register (STO 00, often). In this program, register 00 is assigned to two uses. I would try to separate them. Another reality is the strange distribution of memory usage by the program. The characters chosen to form the code are stored in memories 01 to 05 (for a 5-letter code). In this case, the following 5 memories are necessary to confirm whether a letter has been matched to the last combination proposed by the player who must solve the code. Or registers 06 to 10. But then, that gives a lot of unused registers from 11 to 19. I think that today, I would avoid having such a large amplitude of registers used. The advantage would then be to reduce the minimum SIZE required for using the application (here SIZE 027). Thus, starting on the basis of a code of maximum size of 6 letters (size imposed by the use of CLΣ which concerns 6 registers only), this would give a reservation of registers from 01 to 06, then 07 to 13 for storing the code and the workspace for checking the proposed combinations and requisitioning registers 14 to 20 for the counters (loops and operation). Now, Concerning, precisely, the use of ΣREG: it can be avoided but this requires the use of a CLRGX instruction which is more demanding in execution time and in program space. On yet another aspect, it is possible to be even more economical with storage registers by using an assignment table on a single memory register. It's then sufficient to position a number 1 by the power of 10 in adequation with the character number of the code which has just been assigned (such as black or white). So, if all five characters of the code are affected we will find a check number at 111110, for example. It will be more economical, but also more demanding in program space. You have certainly understood that each character of the proposition is studied through each character of the code to be guessed. A first time in exact correspondence (to know if we are in the presence of a character with BLACK potential), then possibly, a second time with respect to each character of the code which has not yet been assigned (potential presence of a WHITE character among the characters not already declared BLACK in the proposition). Precisely, the program can be criticized for not checking until late whether the character of the code was indeed free. In fact, it is only after observing the exact correspondence that the program ensures whether the reference character of the code has not already been assigned. If we want to avoid this, from the start of the subroutine (LBL 08-LBL b), we must check the availability of the code character. Be careful in this case, because the subroutine receive the context of the control, directly as a parameter in the stack. That's why, you can also read a double X≠0? in the LBL b subroutine : the role of this instruction is also to perpetuate the presence of the parameters in the stack! Otherwise, an additional register would need to be assigned to the Indirect Results Management (IND) role. The strong point of this program is to allow the use of characters (letters or other special characters, for that matter) in the creation of codes to break. The all-rotation technique implemented (XTOA followed by the possible ATOX) to preserve a character in the event of a association failure allowed me to never again resort to the ALPHA register for the code to be discovered at the end of its creation. But this led me to distribute the various characters of this code over registers 01 to 05, for example. However, the use of an ASTO 25 to recover the residual of the user's combination at the end of a control cycle limits the size of the codes to 6 characters. Nothing prevents us from directly managing the characters to be matched using XTOA instructions in parallel (original code versus user code). Perhaps it would be enough to use synthetic instructions that directly affect the M register (and to do an XTOA on each of the two codes) to avoid slowing down the program too much. In summary, this program is already very interesting as it is, but it is even more so because of the progress and openings it offers us. Through this Mastermind program, we see that to get it to work properly, you need a code to break (of a size of 4 to 5 characters, usually) and an assignment table which allows you to know if one of the characters of the code to find is already supported (reserved) in one way or another (black or white) by the code proposed by the user. From then on, the creation of a good program, one which will return the correct result, is assured. Keep you safe Laurent |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(41CX) Master Logic - Mastermind - Code-breaking Game with letters combination - Nihotte(lma) - 08-09-2024, 03:21 PM
RE: (41CX) Master Logic - Mastermind - Code-breaking Game with letters combination - Nihotte(lma) - 08-13-2024 12:01 AM
RE: (41CX) Master Logic - Mastermind - Code-breaking Game with letters combination - Nihotte(lma) - 08-15-2024, 09:38 PM
RE: (41CX) Master Logic - Mastermind - Code-breaking Game with letters combination - Nihotte(lma) - 08-18-2024, 12:08 AM
|
User(s) browsing this thread: 1 Guest(s)