The Return of Viking Chess (Hnefatafl)

Want to talks about games you like, would like to see developed on the Oric, it's here.
User avatar
barnsey123
Flight Lieutenant
Posts: 379
Joined: Fri Mar 18, 2011 10:04 am
Location: Birmingham

The Return of Viking Chess (Hnefatafl)

Post by barnsey123 »

Hi Guys. Just to let you know I've started work on Viking Chess (I first started writing this back in 1983/4 using EXTENDED BASIC from Severn Software). I'm now starting from scratch again but this time using the excellent OSDK and using C.

Back in the day I was using casette tape to save my programs and months into the project lost all my work after a tape chewed up! Project abandoned. I wrote a version on the Amiga (using Amos Pro) which was much prettier but never got finished. Although, like on the ATMOS I got as far as a decent human vs human game. Got a bit lost on the AI...

I'm learning C from scratch so bear with me... :wink:
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte »

Interesting, Dbug gave me this game many years ago when he visited me in Britain and i have enjoyed it many times with friends.
A really cool game from Scandinavia

However there are some gentlemen rules attached to the game like disuading the attacker from blocking all corners with his pieces so preventing the king any conceivable exit from the game.

Also playing with friends, we have found there are situations when you can conceivably take more than one piece from the board in a single move. In extreme cases even 3 :)

For example...

Code: Select all

ADXDA
Moving A into position X prompts the removal of both D's.

Code: Select all

ADXDA
  D
  A
Moving A into position X prompts the removal of all 3 D's!
User avatar
barnsey123
Flight Lieutenant
Posts: 379
Joined: Fri Mar 18, 2011 10:04 am
Location: Birmingham

Post by barnsey123 »

@Twilighte,
I've always found the game fascinating after finding it in Stratford-on-Avon many years ago. I will be including all the rules I know of - including multiple takes - the AI is challenging as, unlike Chess - the objective is different depending on who you play. Will need to do some reading on game AI...

Have just been admiring your intro screen on PULSOIDS. I haven't seen better graphics on the Atmos outside of demos (but I'm still playing catch-up from 1984). The project after this one is - wait for it .... FRED SPACE (A version of Dead Space for the Oric!) It's doable I swear! I've got to get more proficient in C first though.
I was thinking we could use something like the PULSOIDS logo screen do describe the various Aliens found there (like Top Trumps cards) which will be displayed when Isaac - I mean FRED - logs onto various terminals. How much memory/disk space was used in that screen?
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Hi Barnsey, great to see that you are enthusiastic about writing some Oric games :)

Yes this Scandinavian chess game is cool :)

If you manage to get a working AI in C, but that it happens to be too slow, we can help in converting some of it in assembler, it may give a very significant speed up (I'd says on this type of code up to sixteen faster would not be surprising).

One of the important thing is memory, if you want to do deep search trees, you may need large buffers, if you run out of memory you can consider a number of approaches like using TEXT mode instead of HIRES, and/or using the overlay memory (this gives you 16 more kilobytes but the game would work only on floppy disk systems).

About Fred Space, quite challenging but definitely doable, I guess it depends of the ambition, but something like a "seen from above" like Gauntlet/Alien Breed would work. The best game of the type I know on the Oric is Axayacatl, aka "secret of the tomb".

If you want to do a rich graphical game, you can compress pictures with PictConv, in average you reach 50% compression, and the depacking speed is good enough to achieve near-real time speed (ie: not have to wait for seconds with coloured rasters).

Good luck :)

One last thing, if you want to keep your source game safe, and share with other people - possibly for help/suggestions on optimisations -, I can give you access to the Subversion repository with your own local folder.
User avatar
barnsey123
Flight Lieutenant
Posts: 379
Joined: Fri Mar 18, 2011 10:04 am
Location: Birmingham

Post by barnsey123 »

Hi dbug,

Yes, please give me access to this Subversion thing (appreciated).

Is there a list of oric-specific C functions anywhere? The presence of INK, DRAW, CURSET etc seem to suggest that all the old BASIC commands have be re-implemented in the C library (would this include any DISK related commands?) - will save some time in any future SAVE/LOAD game routines...

The main thing for me is to implement a kinder user interface ,previously I was having to type in co-ordinates to move a piece (e.g X2Y5-X2Y9 which was clumsy)

I'll be out of action for a few days but normal coding will be resumed as soon as possible. Thanks for your interest.
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

No there's no really a comprehensive list of functions, but you can find the header files osdk/include, most of the Oric stuff is in lib.h.

One thing to keep in mind, is that using the ROM functions to do anything will mean that your program will work only on some of the machines. The ROM addresses are different between the Oric Atmos and the Oric 1. Another thing is that while you use the ROM functions you cannot use the top 16k. Also means some juggling with the interrupts and timers, etc...
so generally for practical and performance purpose we tend to reimplement all that ourself, we rarely need the ability to draw elipsoid circles or random-lines with patterns in a game. I guess a chess game is no exception, you really don't need any ROM routine to draw a chess board and pieces :)

For the disk functions, unfortunately there's nothing mostly because none of the Oric operating systems work the same, but that being said when you have reached the point when you need to load stuff then you can use the existing code made by Fabrice, Chema, Twilighte, etc... this code is not using the operating system, so it has the appreciable advantage of leaving most of the upper memory free to you :)
(Generally speaking, just try to make all the loadable/savable data fit on multiples of 256, that way it will be trivial to load and save)

For Subversion, please send me a private message with the login and password you wish.
User avatar
coco.oric
Squad Leader
Posts: 720
Joined: Tue Aug 11, 2009 9:50 am
Location: North of France
Contact:

Post by coco.oric »

It's will be a nice project.
Go, Go on development for this new game.

On my way (low speed development), i have also to use hires, the disk memory switch, and reading files on disk (and i've to understand it now).

Good luck.
Didier
coco.oric as DidierV, CEO Member
Historic owner of Oric, Apple II, Atari ST, Amiga
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Didier: That's the main reason why I'm asking for people if they are interested in using the SVN depot, it means that we have public availability of the source code of the most recently released games, so instead of having everybody scratch their head wondering how it was done, and how they could do something similar, they can just get the source code and look at how the program was written :)
User avatar
barnsey123
Flight Lieutenant
Posts: 379
Joined: Fri Mar 18, 2011 10:04 am
Location: Birmingham

C CODERS - HELP REQUIRED (VIKING CHESS)

Post by barnsey123 »

Hi Guys, I admit it...I'm completely stuck. I'm a C newbie and I'm absolutely baffled.
I've managed to get a "working" program that simply draws the game board and allows the player to move a cursor around on the board.

However, I must be doing something fundamentally wrong. ANYTHING else I try to do "breaks" the program (compiles Ok but doesn't run properly). I'm not doing anything exotic (no assembler, nothing complex)

The code is on the subversion account (main.c) it's about 200 lines long including comments. There are three main functions (drawgrid, drawtiles and readkeyb). All take the same arguments (an x,y board offset and a "boxsize"). Any attempt to feed these arguments into "readkeyb" ends in failure (so to get the program to "work" I'm having to hardcode the values which is a crazy situation).

I'm not looking for people to write my code for me, I just need to understand what the hell is going on and what I'm doing wrong. I've wasted so much time on this and I'm getting nowhere :(

I've tried to tidy up the "working" program for public consumption but even that seems to "break" it. I'm going around in circles (or squares in this case!) :)
Please (any help would be much appreciated).
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

I'm going to take a look :)

One first thing is that you should not use 'svn delete' on a file, specially if you add it later, because it breaks the history.

The whole point of a version system is to be able to check the evolution of a file over time, and eventually to go back to an older version.

An example of how you can use that for example is:
- you modify the program to make it "fail"
- you do "svn commit" with a comment that says "broken code"
- you modify the program to make it work again
- you do "svn commit" with a comment that says "working again"

Then you tell us to check the differences between "revision n and revision n+1' of this file to make it easy for anyone to check the exact changes you made that triggers a broken build.
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Ok, apparently there's a major bug in a part of the OSDK, I managed to reproduce the issue, and the "funny" thing is that you were looking at totally the wrong location :) (I saw your commented out "prints" ).

Basically the code does not even have to run to cause the problem, it's apparently an issue with code being offset to some particular position.

I'm digging more, going to report when I find the actual issue :)
User avatar
barnsey123
Flight Lieutenant
Posts: 379
Joined: Fri Mar 18, 2011 10:04 am
Location: Birmingham

Post by barnsey123 »

Thanks dbug!
I need also to read about how to use SVN properly! (I dropped a load of cr*p into it accidentally then had to tidy it up manually...) :(

I've also tried declaring functions so I end up with a structure like:

includes...
function declarations...
main...
function definitions...

All to no effect. I suspect it's some form of memory issue but I just don't know enough. Even adding printf statements to check the values of variables at certain points seems to change the programs whole behaviour. Very odd.

Thanks for your time. :D
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Hi,

to avoid spamming this thread about your game with non related crap, I posted an extensive explanation of my findings so far in the cross-development related forum:

http://forum.defence-force.org/viewtopi ... =6034#6034
User avatar
barnsey123
Flight Lieutenant
Posts: 379
Joined: Fri Mar 18, 2011 10:04 am
Location: Birmingham

update

Post by barnsey123 »

A human vs human version should be ready in a week or three.
The AI version will take a little longer :D
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

As a way to start working on an AI, what you could do is to implement it as a way to help the player:
- First just no hint, let the player select a soldier and select where to move it.
- Second, let the player select only the soldiers that can move.
- Third when the player select a soldier, 'highlight' the possible places where it can play.
- Fourth, have a "help" mode that shows differently the various places where the player can move, from "recommended" to "not a good idea".

To implement that you need to have the various weighting functions ready, but it's a great visual way to check how the AI algorithm is working :) And as a side effect, it can help the player to understand the rules.

A "record and replay" mode would be awesome too.
Post Reply