Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old October 19, 2017, 00:33   #31
Mars
Scout
 
Mars's Avatar
 
Join Date: Apr 2007
Location: Netherlands
Posts: 30
Mars is on a distinguished road
Quote:
Originally Posted by Dean Anderson View Post
So, it's two (and a bit) years later. What's the current situation?

[snip]

And that made all the difference in the world. I now have a fully working and fully featured C# version of Cthangband 5.1.0 as well as a C version. There's no remaining un-ported code left.
Wow! Color me impressed !

IMO, things like this are quickly underestimated. Probably why these attempts usually die an early death most of the time.
__________________
Mostly retired Angband player. I just don't have the time .
Mars is offline   Reply With Quote
Old October 19, 2017, 02:10   #32
jupiter999
Scout
 
Join Date: Nov 2012
Posts: 29
jupiter999 is on a distinguished road
I wonder if you still go for Unity or not?
I once worked on my roguelike using Unity, but shortly can't tolerate the fact that the game generated by Unity needs to spend quite some CPU resources even just idle Sorry...
jupiter999 is offline   Reply With Quote
Old October 19, 2017, 15:59   #33
Gwarl
Knight
 
Join Date: Jan 2017
Posts: 599
Gwarl is on a distinguished road
Quote:
Originally Posted by Dean Anderson View Post
Hmm... I'm not quite sure what you mean here.

The current architecture is that it's a Windows desktop application. The main window uses WPF to display its contents.

That's not ideal (I'm not a big fan of WPF) but - at least initially - I wanted something that would work "out of the box" rather than something that relied on third party libraries and complex install sequences.

That left me with three options:

1) Console
2) WinForms
3) WPF

I experimented with making it a pure console application, but the C# console implementation isn't all that quick, and things like wiping the screen and displaying a page full of text are noticeably slow. It's also restricted in colour usage to a pre-defined set of sixteen colours, and that set doesn't match the default Angband colours, so you have to put up with some merging and

So that left me options 2 and 3. Given that WPF takes advantage of hardware acceleration, and WinForms doesn't, I went for that. It has the advantage that you can easily change the font and window size on the fly without needing a re-start, and all the text takes advantage of ClearType font rendering so it looks nice and crisp regardless of resolution.

However, I do say that this is the current front end. I've deliberately abstracted the front end so I can switch to a different technology or library very easily.
There's a cthangband shaped hole at http://angband.live/ - I compile a lot of variants and I can't remember exactly what my guess was as to why I couldn't get cthangband working, but in most cases for Z variants it's related to a bug in Z where gcc wouldn't recognise a 64bit compiler flag and the RNG got a wrong number of bits. The fact it's in active development again motivates me to give it another try, but it needs to run in a terminal and to compile without the aid of microsoft.

Where's the download for the C version of 5.1.0?
Gwarl is offline   Reply With Quote
Old October 19, 2017, 19:06   #34
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 4,994
Donated: $40
Pete Mack is on a distinguished road
@Gwarl--if you're really ambitious, you can install Mono and use the C# port. But it really is ambitious: if the port is pure C#, it won't work with your Term_xxx port, so it'd need some bridge code. MS did a good job with C#. It's a better language than Java. But I don't know how much of the latest language features Mono has implemented (Tasks and LINQ are the big ones.)
Pete Mack is offline   Reply With Quote
Old October 24, 2017, 13:38   #35
Dean Anderson
Adept
 
Join Date: Nov 2009
Posts: 124
Dean Anderson is on a distinguished road
Quote:
Originally Posted by jupiter999 View Post
I wonder if you still go for Unity or not?
I once worked on my roguelike using Unity, but shortly can't tolerate the fact that the game generated by Unity needs to spend quite some CPU resources even just idle Sorry...
I really don't know, to be honest.

I might give it a go, but I want to get the code cleaner and more stable first.
Dean Anderson is offline   Reply With Quote
Old October 24, 2017, 14:04   #36
Dean Anderson
Adept
 
Join Date: Nov 2009
Posts: 124
Dean Anderson is on a distinguished road
Quote:
Originally Posted by Gwarl View Post
There's a cthangband shaped hole at http://angband.live/ - I compile a lot of variants and I can't remember exactly what my guess was as to why I couldn't get cthangband working, but in most cases for Z variants it's related to a bug in Z where gcc wouldn't recognise a 64bit compiler flag and the RNG got a wrong number of bits. The fact it's in active development again motivates me to give it another try, but it needs to run in a terminal and to compile without the aid of microsoft.

Where's the download for the C version of 5.1.0?
There isn't one, at the moment.

To be honest, it might be more effort than it's worth anyway. As part of the 5.1.0 changes, I stripped out much of the non-Windows code in preparation for the C# port.

So although there is a C version of 5.1.0 on my hard drive, it's explicitly coded for Windows; compiling inside VS2017 and incorporating a built-in front end.

To explain the front end: As part of my attempt to drag it kicking and screaming into the twenty first century, I've got rid of the whole thing where you load a character by starting the program with a command line argument and then when you die or save-and-quit the program dumps you back to the desktop. Instead, when you start the game you get to the main menu which includes multiple save slots like most modern games, and a character dying (or you doing a save-and-quit) brings you back to that menu rather than exiting the program.

It makes the game much more user-friendly, but probably means there's very little compatibility with what you're doing. Since it's been nearly 20 years (give it another six months or so) since Cthangband was forked from
Zangband, I figured that trying to maintain any sort of compatibility with other Angband versions was a fool's errand, and I may as well make wholesale changes.

That's in both the C and C# versions, and both of them automatically put your save games in the Windows user folders.

I should put the game online somewhere for people to download, though. I was thinking of waiting till I'd finished the refactoring (because some of it might break save files, which could be frustrating) but if I sort myself out a website for it I can stick it up as a beta.

Last edited by Dean Anderson; October 24, 2017 at 14:10.
Dean Anderson is offline   Reply With Quote
Old February 5, 2018, 18:52   #37
johnretroreload
Rookie
 
Join Date: Feb 2018
Posts: 20
johnretroreload is on a distinguished road
Unreal VR angband?

I always wanted a VR angband style SAO game with 100 floors of a tower like Druaga with portable items between the two games. Past vs future kind of thing.
I did just find this on neverwinter 1
ftp://neverwintervault.org/rolovault...754/index.html
johnretroreload is offline   Reply With Quote
Old February 6, 2018, 09:42   #38
PowerWyrm
Veteran
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,407
PowerWyrm is on a distinguished road
Quote:
Originally Posted by johnretroreload View Post
I always wanted a VR angband style SAO game with 100 floors of a tower like Druaga with portable items between the two games. Past vs future kind of thing.
I did just find this on neverwinter 1
ftp://neverwintervault.org/rolovault...754/index.html
If you can plug your VR device on your PC, try PWMAngband with NotEye in FPP mode
__________________
PWMAngband variant maintainer - check http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old August 14, 2018, 00:32   #39
Dean Anderson
Adept
 
Join Date: Nov 2009
Posts: 124
Dean Anderson is on a distinguished road
So, it's been a few months but I'm back again.

And this time I have a link!

Link

Basically, I finished the intitial pass at re-factoring the code; and although it worked and was a fully functional version of the game, it wasn't very "nice" C#. It had a small number of classes and most of them were thousands and thousands of lines of code. The fifty thousand lines of C# code worked but weren't very well organised.

So since then, I've been alternately playing it and doing more re-factoring to make it nicer and cleaner.

A classic example is the spell code. In the original C, that code consisted of a global array containing the level/cost/failure/xp for each spell for each class (and Cthangband inherited Zangband's spell system, so there are far more spells than there are in Vanilla - as well as many more classes - so that array was *huge*) and another global array containing their names. Then, there are a few global uints that contain bit-flags for which spells are known, forgotten, and have been cast at least once. Finally, the code for casting spells is a huge switch statement with 256 cases for the 256 spells, and the code for displaying spell info is also a huge switch statement with 256 cases for the 256 spells.

While all this works, having the spell data separated in this way is really awkward to maintain. Everything is done by look-ups, offsets, and indices; and cross-referencing a spell to see how much mana it should cost requires going through the tables by hand counting off the spell numbers.

The first re-factoring pass that I did converting this from C to C# basically left the structure unchanged. The spell names and spell numeric info were still global data (although since C# doesn't really have the concept of global data they were technically static members of a "GlobalData" class). The bit flags were still there, albeit now represented by a "FlagSet" class that wrapped the underlying uint with some user-friendly functions (and no longer global - the FlagSet objects for them were properties of the "Player" class). The humongous switch statements were still there too, although one of them was now contained in a function within the "Player" class and the other was now contained in a function within the "CastingHandler" class.

Again, it still worked - and it was C# code rather than C code - but it was still a mess.

So the second re-factoring pass that I've been doing (and which is still ongoing, although this particular part is finished) has cleaned it up.

Now there's a "Spell" class that holds the basic information for a spell, and there is a class for each individual spell that inherits from "Spell" (for example "SorcerySpellZap" and "NatureSpellHerbalHealing"). The data for the name of each spell is held in the class, and when it's initialised it's passed a reference to the player so that it can set its own level/mana/fail/exp values based on the player's character class. The spell info code is no longer in a switch statement but in a function within the "Spell" class (that uses a property that each inherited class overrides), and similarly the code for casting each spell is held in an abstract function within the "Spell" class that each individual spell class overrides. The flag sets are now individual flags belonging to the "Spell" class, so each individual spell inherits them.

When a character is created, there's a function that simply fills their spell book (an array of "Spell" objects - which, thanks to polymorphism, can therefore hold any object derived from "Spell" too) with a copy of each of the relevant spell objects.

So all the info for any individual spell is contained in a nice logical unit. Adjusting a spell or swapping one out for something different can be done trivially, without having to search through huge tables of numbers to find the right values to tweak. Displaying the spell info just requires a simple look through the spell book asking each spell in it to display its own info, and casting a spell just requires a simple call to the spell to cast itself.

So that's the sort of thing that I'm doing now. I'm breaking up the overly large and linear classes that I got in the first pass into more logical and usable smaller classes, and actually developing a proper object model as I go.

I'm in no way finished (although I've done most of the really big ones), but I am far enough through that I'm happy to release a new version to the world, especially since the end of July was Cthangband's 20th birthday (I released the first version - Cthangband 2.1.0 - back in July 1998).

So here it is. The link above is for the installer for Cthangband 6.0. It's fully C#, and should run on any Windows machine running Vista or more recent - although if you're running on Windows Vista to Windows 8 you might not already have the .NET Framework 4.5.2 installed, in which case you can download that directly from Microsoft here).
Dean Anderson is offline   Reply With Quote
Old August 14, 2018, 20:00   #40
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 4,994
Donated: $40
Pete Mack is on a distinguished road
Wait, angband no longer has a giant case statement for spellcasting. It does call by name (m9re ore less) using generated code from a .h file. You must be running off an older codebase.
Pete Mack is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reviving Iso-Angband, an isometric view addon for Angband Hajo Development 111 August 3, 2014 20:44


All times are GMT +1. The time now is 16:55.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.