(41cx) Mancala Board Game (42s, 35s)
|
05-05-2016, 04:14 AM
(This post was last modified: 05-10-2016 10:45 PM by brianddk.)
Post: #1
|
|||
|
|||
(41cx) Mancala Board Game (42s, 35s)
Update Successfully ported to HP-41cx and 35s. See post #26 for more detail.
Download v0.2 Release for 41cx, 42s, and 35s. Preamble: Although I wrote this on a 42s, It is completely compatible with a 41-CX. The main difference will be that you would have to swap (X<>Y) to see the Player2 display. This is a mancala program I wrote for the hp42s (Free42). For those not familiar with mancala, its a very achient game that has become repopularized over the last few years in the US. You can now get a mancala board at most stores that sell board games. This particular 'flavor' of mancala kahla(6,4), but it seemed to be the one that is most available in my area. This is a fun game to play, but most mathmatical analysis of possible permutations make this game signifigantly harder for Player 2. Whoever goes first is likely to win. Download mancala.raw HP 35s Portable I had originally planned on writting this for the hp35s. I still intend to port it, so I wrote this, basically, in hp35s syntax. The primary listing is in an '.asm' file that I put through a very gentle pre-processor. This is done to keep all the `LBL`, `XEQ`, `GTO` statements synced up since the 35s and 42s handle them different. I also prefer verbose label names, but that has a tendency of poluting your program catalog with all your 'subroutines'. The pre-processor will take marked-up verbose labels and convert them to 42s local-labels or 35s line-labels. Neither of which will pollute the catalog. I have also choosen to use no named variables for similar reasons. Since I plan to port this to the 35s, I choose to only access registers indirectly. This is the only way that the 35s can access un-named registers, so enforcing this makes the porting a breeze. References to `I`, `(I)`, `J`, and `(J)`, are all 35s notation. Build Process The build command does the pre-processing with `sed`. Once this is done, it feeds the result through txt2raw.pl (by Vini Matangrano). This will both check for syntax errors and produce an hp42s raw-file. My only hp42s is the one simulated through Free42, so no promesses, though I'm not really doing anything special here to cause concern. Registers Since a real mancala board uses a counter-clockwise rotation in play, I have configured the phisical registers in a similar fashion. This does make gameplay more natural for Player 1 than Player 2. Code:
Flags The flags used are fairly self explanitory. Originally, in the 35s design, I had intended on using the flag indicator as the way for Player 1 and Player 2 to know who's turn it was. Since the 42s doesn't have a flag indicator, I had to use `GRAD` and `RAD` to make that distinction. Code:
Game Display The game display will show a number between 1-million and 2-million, for both Player 1 and Player 2. The fractional part is the player's score (0.10 = 10 points). The number in the million'th place is purely for alignment and should be ignored, the other numbers represent your 6 'pits'. The 'pit' to the far left is 'pit 1' the pit to the far right is 'pit 6'. To move, you specify a pit number to move. Note: 41-C users will need to swap (X<>Y) to see the P2 score and pit display. Code:
Gameplay To start the game, simply `XEQ` the `MANCA` program. The game will show the initial board and set the indicator for Player 1 to take his turn. Player 1 can then study the board and pick a pit to move. Thier pick is given by placing the pick in the level 1 (x) on the stack then hit `run` (aka `R/S`). The game will then move the beans according to the rules and redisplay the board. It is now time for the next move. The `GRAD` / `RAD` indicator will light to instruct the players as to whos turn it is. Keep in mind, earning extra turns is a key strategy of the game. Bugs
Listings Here are the listings, but do recall that you will likely need to understand that pre-processors are the key here. mancala.asm Code:
build.sh Code:
mancala.txt Code:
Download mancala.raw Official site: http://brianddk.github.io/2016/05/hp-42s-mancala/ Update: Fixed broken links MyCalcs: Physical: {hp48gx, hp50g, hp35s} Emu: {hp42s(Free42), hp41c(v41)} Blog: https://brianddk.github.io/ |
|||
05-05-2016, 11:23 PM
(This post was last modified: 05-06-2016 10:49 PM by brianddk.)
Post: #2
|
|||
|
|||
RE: (42s) Mancala Board Game
Got my 'compiler' to produce compliant hp-35s listings now. I just need to go through the process of keying them in. So 'untested' on the 35s at this point.
Obviously, you don't key in the ;LBL statements. I left them in to ease reading. Download Update: Fixed broken link MyCalcs: Physical: {hp48gx, hp50g, hp35s} Emu: {hp42s(Free42), hp41c(v41)} Blog: https://brianddk.github.io/ |
|||
05-06-2016, 09:51 PM
Post: #3
|
|||
|
|||
RE: (42s) Mancala Board Game
(05-05-2016 11:23 PM)brianddk Wrote: Got my 'compiler' to produce compliant hp-35s listings now. I just need to go through the process of keying them in. So 'untested' on the 35s at this point. In both cases (first and second link posted): 404 – Page not found BTW, what about an .ep file for the 35s emulator ?-) Dieter |
|||
05-06-2016, 10:45 PM
Post: #4
|
|||
|
|||
RE: (42s) Mancala Board Game
(05-06-2016 09:51 PM)Dieter Wrote: In both cases (first and second link posted): 404 – Page not found Opps... I moved some files around and now I realize the link was not static. Try this instead, it's static and will never 404. I will warn you that I found some bugs so that 35s listing is 'tainted' until I can finish my revisions. Here is a current copy link, but the current-copy-link isn't static, and may 404 in the future. (05-06-2016 09:51 PM)Dieter Wrote: BTW, what about an .ep file for the 35s emulator ?-) Emulator?!?! Do tell me more... While your at it, anyone have an hp-41c compiler? I found some 41c emulators, but I haven't found one yet that will consume a text file and import it into the 41c VM's program memory. MyCalcs: Physical: {hp48gx, hp50g, hp35s} Emu: {hp42s(Free42), hp41c(v41)} Blog: https://brianddk.github.io/ |
|||
05-07-2016, 07:37 AM
(This post was last modified: 05-07-2016 09:15 AM by Dieter.)
Post: #5
|
|||
|
|||
RE: (42s) Mancala Board Game
(05-06-2016 10:45 PM)brianddk Wrote: Try this instead, it's static and will never 404. I will warn you that I found some bugs so that 35s listing is 'tainted' until I can finish my revisions. Here is a current copy link, but the current-copy-link isn't static, and may 404 in the future. OK, thank you. After a short look at the code I wonder why some integer constants carry trailing zeroes (e.g. 4.0, 0.0, 6.0 ...). And what about an optimized more effective (shorter and faster) version ?-) BTW, I am missing the rules of the game and an example of a session. What's the highest possible score a player can achieve? (05-06-2016 10:45 PM)brianddk Wrote: Emulator?!?! Do tell me more... There is a "HP35s virtual calculator" by HP. AFAIK it comes with the real thing on CD. Since I already bought my 35s in 2007 (with the printed manual, but without a CD) I downloaded the emulator some years ago from the HP website. Edit: I didn't find it on the HP website. Did they change their policy? However, I am quite sure it is still available somewhere. Try Google. And finally: (05-06-2016 10:45 PM)brianddk Wrote: While your at it, anyone have an hp-41c compiler? I found some 41c emulators, but I haven't found one yet that will consume a text file and import it into the 41c VM's program memory. I am not sure what exactly you are looking for. You know hp41uc, don't you? It's here (and possibly a newer version somewhere else). I use it here and there with the V41 emulator to generate program listings, but it can do much more. Dieter |
|||
05-07-2016, 07:26 PM
Post: #6
|
|||
|
|||
RE: (42s) Mancala Board Game
(05-07-2016 07:37 AM)Dieter Wrote: After a short look at the code I wonder why some integer constants carry trailing zeroes (e.g. 4.0, 0.0, 6.0 ...). And what about an optimized more effective (shorter and faster) version ?-) Apologies, brainwashing of a former python programmer. It also helped to fool the parsers. txt2raw.pl, as well as build.sh will sometimes treat the first number on a line as "special". I eventually added auto generated sequence numbers removing the need for this parser hack. Other than making the numbers shorter, I would appreciate any suggestions on changing how I loop to reduce bloat. Of course I could make every variable named and dispense with the indirect access charade, but that would make porting to 35s more error prone. That's why I left that particular piece of bloat in, though it is confusing. (05-07-2016 07:37 AM)Dieter Wrote: BTW, I am missing the rules of the game and an example of a session. What's the highest possible score a player can achieve? Others do a much better job of explaining the game than I do. This is Mancala(US) so that generally means Khala(6,4) in other parts of the world. The board has four edges, North, South, East, West. Player 1 and Player 2 face each other with the board in the middle. P1 to the south, P2 to the north. Movements are counter clockwise (player moves pieces to the right). The board is laid out with 6 pits on the north, 6 on the south, and a capture pit on the east for P1, and on the west for P2. The game starts with 4 beans in each pit (north and south), and P1 moves first. To move, take all the beans from a pit on your side and "sow" them into the pits to the right. One in each pit wrapping around the board as needed. You are allowed to place a pit in your capture as you wrap around, but are also allowed to skip your opponents capture pit if you have a move that large. You capture beans by wrapping around your pit, and by capturing your opponents. To capture your opponents beans, you need to complete a move where the final pit you move into ends with exactly one seed. The you capture all beans opposite of that pit. First player to 24 wins, though some versions force you to keep playing. Its unlikely to ever win if your opponent reaches 24. Much better explanations here. https://en.wikipedia.org/wiki/Mancala The Kalah page mentiones a mathmatical study of the game my Mark Rawlings that would likely be of more interest, though I can't find where the study was published. https://en.wikipedia.org/wiki/Kalah (05-07-2016 07:37 AM)Dieter Wrote: There is a "HP35s virtual calculator" by HP. AFAIK it comes with the real thing on CD. Since I already bought my 35s in 2007 (with the printed manual, but without a CD) I downloaded the emulator some years ago from the HP website. OK... so I checked the CD that came with it last month... Nothing but PDFs. Turns out reading a CD is harder than I thought. Don't have one in any of my primary machines anymore. Found an old Vista laptop for the task eventually. I found another article mentioning that the SW is available with proof-of-purchase, but didn't find where to get it. Contacted support and they agreed, but hung up before they could send me the link. I did eventually find an "Educators" page where you can request teaching material (including emulators), but I don't know that I qualify. I sent my syllabus / lesson-plan for the computer class I teach, but it's not really in the same realm as Calculus III. Might be interesting to add a section on low-level programming. The RPN 'language' has some similarities to assembler and microcode that would be fun to present. (05-07-2016 07:37 AM)Dieter Wrote: I am not sure what exactly you are looking for. You know hp41uc, don't you? It's here (and possibly a newer version somewhere else). I use it here and there with the V41 emulator to generate program listings, but it can do much more. I'm looking for something that will convert: Code: LBL "HHGTTG" Looks like hp41uc.exe does TXT to RAW and looks like V41R8.exe can import and execute RAW files. So these two should work for me. Didn't find them earlier, so thanks for the suggestions. MyCalcs: Physical: {hp48gx, hp50g, hp35s} Emu: {hp42s(Free42), hp41c(v41)} Blog: https://brianddk.github.io/ |
|||
05-07-2016, 07:42 PM
Post: #7
|
|||
|
|||
RE: (42s) Mancala Board Game
(05-07-2016 07:37 AM)Dieter Wrote:(05-07-2016 07:26 PM)brianddk Wrote: Emulator?!?! Do tell me more...There is a "HP35s virtual calculator" by HP. AFAIK it comes with the real thing on CD. Since I already bought my 35s in 2007 (with the printed manual, but without a CD) I downloaded the emulator some years ago from the HP website. You can find a collection of hp emulators here. |
|||
05-07-2016, 08:50 PM
Post: #8
|
|||
|
|||
RE: (42s) Mancala Board Game
(05-07-2016 07:42 PM)Didier Lachieze Wrote: You can find a collection of hp emulators here. I did find a few third-party sites, torrents, and megaupload links, but was a bit hesitant to install an usigned binary from a source I couldn't vet. I know HP used to sign some of there binaries with a Authenticode certificate a few years back, but it was eventually revoked. I'll see if I can dig it up and put the bins to the test. Is that your site? Do you know the staff? Thx MyCalcs: Physical: {hp48gx, hp50g, hp35s} Emu: {hp42s(Free42), hp41c(v41)} Blog: https://brianddk.github.io/ |
|||
05-07-2016, 09:15 PM
Post: #9
|
|||
|
|||
RE: (42s) Mancala Board Game | |||
05-08-2016, 05:44 AM
Post: #10
|
|||
|
|||
RE: (42s) Mancala Board Game
(05-07-2016 09:15 PM)Didier Lachieze Wrote: It's not my site, it's the site of the French distributor for the HP calculators.Looks legit. The EXE in the ZIP is signed by one of the valid (not revoked) HP certificates. The MSI inside the EXE (inside the zip) is not. But certainly better than nothing. I took the leap... Thx for the links. Wish I could import a text file, but keyboard is still better than nothing. MyCalcs: Physical: {hp48gx, hp50g, hp35s} Emu: {hp42s(Free42), hp41c(v41)} Blog: https://brianddk.github.io/ |
|||
05-09-2016, 07:07 AM
Post: #11
|
|||
|
|||
RE: (42s) Mancala Board Game
FWIW, I've made the needed changes for an HP41-compatible version of this game - see attached.
I've also included this and the GALAXIS program in a new games module I'm sort of putting together, more to follow. Cheers, ÁM "To live or die by your own sword one must first learn to wield it aptly." |
|||
05-09-2016, 08:11 AM
Post: #12
|
|||
|
|||
RE: (42s) Mancala Board Game
(05-09-2016 07:07 AM)Ángel Martin Wrote: FWIW, I've made the needed changes for an HP41-compatible version of this game - see attached. I do not see any attachment. #-) (05-09-2016 07:07 AM)Ángel Martin Wrote: I've also included this and the GALAXIS program in a new games module I'm sort of putting together, more to follow. What about the Kalah / Wari version in the Games Solutions Book? The rules are slightly different, but this version offers the option that the user plays against the machine. Dieter |
|||
05-09-2016, 10:34 AM
Post: #13
|
|||
|
|||
RE: (42s) Mancala Board Game
(05-09-2016 08:11 AM)Dieter Wrote:(05-09-2016 07:07 AM)Ángel Martin Wrote: FWIW, I've made the needed changes for an HP41-compatible version of this game - see attached. Having issues with the attachments, will do this afternoon. That game is already included in the FUNSTUFF module, available at TOS. "To live or die by your own sword one must first learn to wield it aptly." |
|||
05-09-2016, 11:12 AM
Post: #14
|
|||
|
|||
RE: (42s) Mancala Board Game
(05-09-2016 07:07 AM)Ángel Martin Wrote: FWIW, I've made the needed changes for an HP41-compatible version of this game Wow, thanks... This is still a pretty rough. I'm planning on adding HP-41 to my 'sed' list based on the hp41uc syntax rules. When I'm done, I will hopefully have mancala-hp41c.raw, mancala-hp42s.raw, and mancala-hp35s.ep all building from the same source (well maybe not the EP file). If anyone knows of a way to produce a hp35s.raw file, or a way to build an EP file from 'source', I'd love to know. I'll post updates to github and this thread as I make them... but this is still a Sunday afternoon project, so updates might be slow. (05-09-2016 08:11 AM)Dieter Wrote: What about the Kalah / Wari version in the Games Solutions Book? The rules are slightly different, but this version offers the option that the user plays against the machine. LOL... I genuinely had no idea this had already been written. Seemed like an obvious choice for a calculator game though. The Kalah game is likely the same game. (05-09-2016 10:34 AM)Ángel Martin Wrote: That game is already included in the FUNSTUFF module, available at TOS. For the newbies here... what or where is TOS? MyCalcs: Physical: {hp48gx, hp50g, hp35s} Emu: {hp42s(Free42), hp41c(v41)} Blog: https://brianddk.github.io/ |
|||
05-09-2016, 12:31 PM
Post: #15
|
|||
|
|||
RE: (42s) Mancala Board Game
(05-09-2016 11:12 AM)brianddk Wrote: For the newbies here... what or where is TOS? Just one of many threads about this. Greetings, Massimo -+×÷ ↔ left is right and right is wrong |
|||
05-09-2016, 01:38 PM
Post: #16
|
|||
|
|||
RE: (42s) Mancala Board Game
(05-09-2016 08:11 AM)Dieter Wrote: What about the Kalah / Wari version in the Games Solutions Book? The rules are slightly different, but this version offers the option that the user plays against the machine. OK.. did some reading, and the mancala variant in the Game Solution Book titled "Wari" is traditionally refereed to as "Oware". The mancala variant that I call "mancala" is traditionally referred to "Kalah(6,4)". Both Mancala, variants, with one popular in West Africa and the Caribbean, and the other popular in the US and Europe. MyCalcs: Physical: {hp48gx, hp50g, hp35s} Emu: {hp42s(Free42), hp41c(v41)} Blog: https://brianddk.github.io/ |
|||
05-09-2016, 02:38 PM
(This post was last modified: 09-08-2016 12:49 PM by Ángel Martin.)
Post: #17
|
|||
|
|||
RE: (42s) Mancala Board Game
(05-09-2016 01:38 PM)brianddk Wrote:(05-09-2016 08:11 AM)Dieter Wrote: What about the Kalah / Wari version in the Games Solutions Book? The rules are slightly different, but this version offers the option that the user plays against the machine. Thanks, that helps keep tabs with all the versions. I'll post the 41-based raw file this evening CET. Edited:- RAW file is now posted. I used the HP-42 version as source, so this may be a bit iffy - pls. report on errors if you find some. This version should be 100% compatible with V41, no other modules required. Cheers, ÁM "To live or die by your own sword one must first learn to wield it aptly." |
|||
05-10-2016, 06:14 AM
(This post was last modified: 05-10-2016 10:48 PM by brianddk.)
Post: #18
|
|||
|
|||
RE: (41cx) Mancala Board Game (42s, 35s)
Update Successfully ported to HP-41cx and 35s. See post #26 for more detail.
Download v0.2 Release for 41cx, 42s, and 35s. OK... I made my first successful run at a 41cx compilation. I had to use dosbox, but I suppose that is the prescribed method for hp41uc. If there are other 'compilers' anyone wants me to try let me know. Light Testing Light testing using hp41uc (through dosbox) and v41r8.exe as the emulator. Honestly, my impressions are that is likely too slow to realistically play through the simulator. Real HW might be faster. Especially modern HW like DM41L, but I'll have to hear more to know for sure. Testing was very light. Let me know what you find. Please read the ASM source file as most the 'Readme' contents are there. Bugs:
MyCalcs: Physical: {hp48gx, hp50g, hp35s} Emu: {hp42s(Free42), hp41c(v41)} Blog: https://brianddk.github.io/ |
|||
05-10-2016, 08:03 AM
Post: #19
|
|||
|
|||
RE: (41cx) Mancala Board Game
(05-10-2016 06:14 AM)brianddk Wrote: Light testing using hp41uc (through dosbox) and v41r8.exe as the emulator. Honestly, my impressions are that is likely too slow to realistically play through the simulator. Real HW might be faster. Especially modern HW like DM41L, but I'll have to hear more to know for sure. What speed did you set in V41 (Options / More Settings...)? Greetings, Massimo -+×÷ ↔ left is right and right is wrong |
|||
05-10-2016, 01:27 PM
Post: #20
|
|||
|
|||
RE: (41cx) Mancala Board Game
(05-10-2016 08:03 AM)Massimo Gnerucci Wrote: What speed did you set in V41 (Options / More Settings...)?Cranked up full, yes, that helped alot, but couldn't figure out how to use 'Turbo'-tab. MyCalcs: Physical: {hp48gx, hp50g, hp35s} Emu: {hp42s(Free42), hp41c(v41)} Blog: https://brianddk.github.io/ |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)