Chess request...

Fred_Ftang

Chieftain
Joined
Jan 3, 2007
Messages
10
This might sound like a daft question, but would it be possible to teach Civ4 to play chess?

I wouldn't know where to start creating a mod, but this might inspire someone...
A map with same number of tiles as a chess board with units from two rival civs (one playable, one AI controlled), lined up on opposing sides - two rows each; the units representing the usual chess pieces and bound by the same movement rules.

The game would have the same objective: capture the opposing king.

It might take some fiddling to set up the rules, (only one unit moved per side, per turn in a set pattern, etc) but it would be cool to see if it could be done.

Vincent:king:
 
That would be a very different use of the game. In real life I'm a chess player too (elo 1650), so if possible I really would like to play it but I don't think someone can mod this.
 
Yeah I thought about making this a few times. Its actually pretty easy to do with the new canMoveInto python function in BtS. You can do it just as a python mod.

It would probably only take an evening to make a mod where you can only move the units to legal locations and only move 1 unit per turn. The AI would randomly move its pieces to legal locations.

Going through and teaching the AI to move its pieces strategically, that would be the hard part.
 
Why would you want to do this?

(And yes, of course it can be done. And like Kael's saying, programming a good AI is always the problem. At least if you want acceptable performance.)
 
I just thought it might be interesting to see how the current AI deals with obtaining it's objective (capture the king) within the movement constraints.

Vincent
 
Chess is my favorite game (ELO 1934), CIV only comes second on my list.

but would it be possible to teach Civ4 to play chess?

I thought about this as well and I think it is possible and maybe not even that difficult to implement. First you need a chess engine and Pychess comes to mind right away. By using an existing chess engine you don't have to teach the AI to play a reasonable game of chess. You can just focus on move to GUI translation.I am not sure if you can use the Winboard or UCI protocol, but there must be an easy way to translate EPD/FEN to the GUI of CIV.
 
Well I mess around a little bit while I was relaxing and watching my recorded shows and I managed to put together the beginnings of a chess mod.

I have the six units(king, queen, rook, bishop, knight, and pawn), two civs and two leaders(black and white), and a simple map script that makes an eight by eight tile map with desert as the white tiles and tundra as the black.

I got all the units spawn in the right spots at the start of the game, but I haven't coded the movement restrictions yet. I will see about getting to that sometime this week when I get some free time.
 
I got most of the movement code written. It was pretty easy to get the king, queen, pawn, bishop, and rooks to move right, but the knight is proving a little troublesome. I'm off to bed tonight, but tomorrow I plan to get piece taking and score keeping to work.

As it is, the AI does not seem to handle the new rules very well, but after I get the basic stuff done I will see about incorping some python chess engine.
 
Ok, I managed to get a bit done tonight.

I got combat coded so the attacker always wins.
Got score keeping done.
Fixed the movement code so you can only move a unit once.
Got Conquest victory set up to happen if you kill the king unit.
Score victory goes off if you kill all the units except the king.
Fixed Pawn unit so you can move 1 or 2 tiles on first move.

Havnt got the knight movement working quite right, but am a little closer.

ToDo:
I need to update the Info Screen to show somthing.
Need to pass moves to log so they show in replay.
Maybe add new screen to show move history ingame.
And ofcourse I need to incorp some chess engine.
 
I got lots of good work done tonight.

I perfected the Knight movement, works just like real chess now. This was a little bit of a fight, but once I figured out that you allow unitCannotMoveInto to return False and still stop the unit from moving by having cannotSelectionListMove return True it was a cake walk.
I also fleshed out and cleaned up the movement of the other pieces, like keeping pawns from taking units directly infront of them.

In addition I also have managed to encode the rule that keeps kings from moving into tiles that would put them into check. I have also coded in the rule that only lets you move the king unit if it is in check. Finishing of the king/check stuff, I add a Checkmate victory.
EDIT: Forgot to add code so a unit can't move it that move would put the king in check.

On a side note. My buddy mentioned that it might be cool to have other kinds of maps as backgrounds instead of just the normal board map. So I gave all the pieces the ability to cross any terrain, even impassable terrain, as if it were normal tiles. So you can play on a board that looks like a terra, oasis, or even space map.

Now that I have all the basic functionality of a chess board and pieces in place I am going to begin work incorping a chess engine. I am also going to work on modding the UI to remove the non-chess Civ stuff.

Well I got another hour before bed so I'm off to find a decent engine to run the AI. Google don't fail me now.
 
Wow!
Good work! :D
I never actually expected anyone to take my suggestion seriously. I thought I'd be shot down with cries of "It Can't Be Done!".

I wish I could help, but as I said, zero mod-skill at this end.

Will you be using ready-made unit graphics? If anyone out there feels the urge to knock up some apropriate looking units that would be fantastic.

Vincent
 
Id recommend digging into FfH for appropriate art. Earth elementals as Rooks, Priests as bishops, heros as kings and queens, etc.
 
90 percent of modding is finding something you want to code. Its going to take me a few days to get everything done and polished up, but other then a few of the peticulars of movement restrictions its all pretty simple.

Scavaging from FfH for unit models is a good idea. I was thinking of stealing the castle building model from the default game and making it a unit for the rooks, but I am seriously lacking in female models for the queen so I will definetly see about that. :)

I'm working on moding the main interface and the various screens right now and am thinging of having a beta version released some time this week. No AI, but all the basics need for a MP chess game.
 
Have you already coded all the legal moves (move validation)? Even the difficult stuff like castling and pawn promotion?
 
Castling is about half down, and though I haven't started coding them yet, pawn promotion and en passe will be in the mod.
 
Hahaha we used to joke that Chess is an ancient TBS, that is bugged (Cavalry cant go straight but instead slides sideways, cannons cant bombard...) and that Chess 2 will feature terrain, morale etc. etc. Figures it's all actually doable :p
 
I used to have chess 4, which was 4 player chess. It was played on a board like this.
4player.jpg

I think that would make a good alternative map, and would make for a good 4 civ game once all the code is laid out.
 
Back
Top Bottom