New project: renju

Bloody-orc

Senior Member
Ok i have a new project. I plan to build a renju game with picaxe.

have a few questions. should i use an graphical LCD or bunch of LED's?

is picaxe capable of doing such a thing. players are humans and every single move made is saved into an EEPROM chip connected via i2c
 

Bloody-orc

Senior Member
Renju (Japanese:連珠) is the professional variant of Gomoku, a Japanese board game. It is played with black and white stones on a 15x15 intersection Go board. Renju eliminates the "Perfect Win"-situation in Gomoku by adding special conditions for the first player (Black).
en.wikipedia.org/wiki/Renju
 

Jeremy Leach

Senior Member
Hi Bloody
It sounds like you want to play a picaxe 'virtual player' , and you want the picaxe player to calculate it's move by referring to a large 'database' of possible moves, stored in EEPROM. Is this right?

I think the EEPROM database sounds feasible.

I would think it's possible to use a few Bicoloured LED Matrices to provide 15x15 bicolor LEDs. A color for each player or off if no player on square. However I wouldn't underestimate the circuit complexity.

LCD display an option, but your usual alpha-numeric displays won't be much use.

Also, need some sort of keypad input to enter your moves.

Altogether I'd say this is quite a tricky project.
 

BeanieBots

Moderator
Memory and IO will be be your problem, especially if you want to "save all moves" rather than simply keep an up to date representation of the board.
Does the PICAXE need to determine a win situation? If not, then it is simply a question of the PICAXE reading inputs and setting outputs.
With some clever harware and a well thought out way of representing the required data in memory, I'm sure it can be done. I don't think the choice of LCD graphics over LED display will have much affect. The issue is more about how much work whatever driver interface you choose can do.

I did a much simpler game (tic-tac-toe) which was only 3X3. I used bi-colour LEDs fitted into illuminated push buttons. That approach would probably be cost prohibative with such a large array. Even a small grid of 3X3 required 10 inputs and 20 outputs. There are a range of addressable interface chips that can do a lot of the multiplexing work for you. Unfortunately, I don't know any that are I2C which would be the obvious choice for a PICAXE but some have been mentioned on this forum.

Check out the threads in this forum about using IO expansion chips. Alternatively, try to find a graphics display with easy interface controls.
I don't know how to play the game, but I'm sure it would be possible to devise a method of inputting the moves with minimal IO. Also, try to find a way of reducing memory storage by looking for ways of taking into account any symetery within the play area to reduce the maximum number of possible display combinations.
Sorry I could not offer any further practical help.
 

hippy

Ex-Staff (retired)
An interseting idea. How to create a man-machine interface which works could be challenging. My thought is to make a 15x15 board with jack sockets ( or similar ) which can tell whether a black or white 'peg' is inserted at each point. The human inserts their peg, computer determines its move, flashes a LED at a location where its peg should be inserted, waits for that to happen then repeats. That could minimise the I/O quite considerable as LED drive and input sensors would become simple matrices.

RCA phono's may make a good choice for pegs as they already come in multiple colours. Wooden or plastic discs with a plug sunk into their bottoms would allow the game to have a more traditional look and feel.

On the 'computer playing' side a board is quite easy to store; each intersection/square has three states ( empty, white or black ) and that's just 57 bytes ( 15x15x2/8 ) which wouldn't need external memory. Iterating through that to spot wins, looses and rule violations would be reasonably easy but program size could be the limitation there.

Calculating best moves is where most processing time will be spent and a PICAXE may be too slow if it needs to play anything above simple "can I win, must I block, make a random move" algorithm.

Trying to hold all possible board states would be more difficult. There are some 15 million possibilities although that includes states after a game has already been won, mirror images and rotations of other states.

I'd suggest starting with a 3x3 tic-tac-toe / noughts-and-crosses game. Most of the lessons learned will still be valid for a scaled-up game and you'll see what problems are likely to crop up.

I'd also start by simulating the program on a PC which will give a zero-cost method of getting a feel for how complex a solution may be. Using JavaScript you could create a web-based version.
 

Bloody-orc

Senior Member
well i dont need so suffisticated program as you think. the picaxe must not play. its job is to store the moves for further analyzing on PC on another software. i'll look for those IO multiplyers (or what ever they are called) to get more IO's. 1 need 3 15*15 matrixes (omg) and this is going to eat a lot of I/O's. I store every move on 24LC64 EEPROM on I2C somehow (dont know how to select banks jet on those word EEPROMS). I have made a tic tack toe so i know what i'm facing with here. i know it is a challage and this is one thing i chose this project (i was getting bored). also this is good project to practice soldering (over 2000 solderjoints must be made).

anyway thanks for the help guys!

PS sry if some words are written wrong. i'm not comfortable with that keyboard i have jet
 

andrewpro

New Member
For the IO's I would suggest an MCP23017. You could use a MAX7300 for more IO per chip (not by much) but the MCP23017 is alot easier to use, in my opinion.

Switching them back and forth to be both Inputs AND outputs could be a challenge, though, so for the input I would use something like multiple MM74C922 keypad encoder chips. Tha'ts a Fairchild part number (the ones I usually use) but any major logic maker should have them. Using diode mixing, you can have just a few IO's (relatively) to control a massive amount of inputs. Youd have to come up with some kind of code to prevent "fat fingering" the keys triggering more than one proper input sequence at a time, and with diode mixing, if your not careful, you can fry a picaxe pin.

Just my thoughts.

--Andy P
 

Bloody-orc

Senior Member
i would just love to use such chips but as i live in Estonia there is no shop that sells them. also i wouldn't like to spend 20$ for inpur expander...

but thanks for help. i hink i use counters or something like that (4017).

Edited by - bloody-orc on 1/3/2006 6:05:50 AM
 

Bloody-orc

Senior Member
does any1 have any good idea how to make a LED matrix? 225 leds (15*15). for outputs i use counters (as mentioned before [mc14017bcp]).
 

BeanieBots

Moderator
You actually need 15*30 = 450 outputs.
Each cell can have THREE states, white/black or empty. The 4017 only has 10 outputs so if that is the route you wish to take, you will need to build it up in banks of 10 lines or less.
It might be possible to cut down on the size of the matrix wiring by using bi-colour LEDs that determine colour depending on polarity. I've never tried it myself but I would guess that you would have to be able to drive the matrix lines in both directions.(ie sink and source current) and also be able to tri-state them for LED off. If using 4017 counters, this would mean buffering with something like a 74??144 octal-tristate-buffer or similar.
 

Bloody-orc

Senior Member
could someone give me an example on how to wire lets say 9 leds in a matrix form. so i need 6 outputs instead of 9.

and i dont use bicolour leds couse they cost me too much. i'm allready spending 30$ on LED's and with bicoloured ones i would have to spend like 60$ (no thanks).
 

Jeremy Leach

Senior Member
I'm not suggesting this idea would be that easy with 225 squares but ...

I've read a little about Quantum Tunneling Compound (QTC) (Maplin sell it, amoungst others). Basically it's a cheap material that varies it's resistance with applied pressure. I know it's been mentioned on this forum before. I've also read that the black foam that ICs come in has a similar behaviour.

Anyway, I was thinking - to get a pleasant user interface, could have board squares made of this stuff and the black and white pieces have different weights, resulting in different resistances.

Ok, could be impractical, and might need big pieces to give sufficient weight - oh, ok, you could also change a pieces 'colour' by pressing on it!

Anyway, despite all these issues (!) might still work. Not entirely sure how to read the resistance values effectively - maybe use MOS analogue swith/selector ICs to select/scan QTC squares. The selector would connect the currently selected QTC square to a single comparator op-amp to determine the presence of a player's piece.

I'm itching to try out this QTC stuff ...
 

Jeremy Leach

Senior Member
Another idea .... I wonder if there's some way of interfacing a cheap black-and-white, PCB-camera module to a picaxe system?

I've been looking into these modules because I want to put one in a bird-box, but I wonder if there's a really low res version with a digital output?? Could carefully mount the camera above the game board, capture an image of the board each move, and translate the pixels into a 15x15 array of values.

I know it sounds a bit extreme - but the cost of camera modules is coming down...
 

Bloody-orc

Senior Member
ok thanks for the info but i actually dont need the input part of the system. i need more the putput part. i need to control all those leds vrom one port (8 pins, 1 byte). i'm willing to use counters to do the job (like 14017, 74138 etc).
 

BeanieBots

Moderator
To put it quite simply, you can't. (at least not directly)
Your board is 15X15 and needs to display 3 states in each cell. That's 450 independant controls that are required. An 8-bit output port is only capable of 256 distinct states.
No matter how hard you try to split up the port, it simply does not have enough unique values to do what you want. If you want to use a single port, you will have to employ some sort of latching mechanism with its own "intelligence" that can read in commands. For example, send an address low byte followed by address high byte followed by data. You could use 2 bits from each byte to indicate if it is high, low or data. A 28X controlling an IO expander could then convert it into the desired output grid, but then you might as well control the expander directly from the master anyway.
You might be able to do something clever with latching/addressable counters but I can't think how with just a single byte control.
 

BeanieBots

Moderator
Yes, but lots of brain-ache and software to do it. That's what I meant by "If you want to use a single port, you will have to employ some sort of latching mechanism with its own intelligence". and "You might be able to do something clever with latching/addressable counters "

Lets say you were to use a single 8-bit port and a 4017 counter.
1 bit is required to clock the counter, leaving 7 to drive the LEDS. That would give a display of just 70 LEDs.
To get the required 450 outputs, you would need to cascade 7 4017's. (and I don't know how you would inhibit the outputs other than wiring up 10 diodes for EACH of the 7 counters.)
You would then need to toggle just one bit of your output to increment the counter. At the same time, place the required bit pattern for the first bank of 7 LEDs on the other seven bits. Then incremant the counter again etc. etc.
You also need to get all 70 (assumes 490 outputs, nearest to 450) bit patterns out with their counter increments and do what ever other processing is required quick enough to prevent the display from flickering.
There may well be a better way by some crafty method of using a seperate external clock to present data that has been pre-loaded into a latch but not something I would like to undertake when there are custom chips available to do it all with just two IO lines required.

Don't get me wrong, I'm trying to put you off from taking on such a mammoth task if you really do want to do it the hard way, but I think you should fully get to grips with a much smaller multiplexed array first. After all, even the PICAXE itself is not much more than a few hardwired shift registers, latches and flip-flops all of which can be made from descrete gates which in turn can be made from descrete transistors. Turin did it with cogs.
 

andrewpro

New Member
Hmmm...how about a latching shift register? Load up all the bits through jsut two pins on the picaxe, and ten blip the latch pin and it should go through. Youll probably need drivers as well. Youll still need alot of external hardware, and it'll still be a mess...but it may work ok.

There are also devices such as the MAX6955. It's I2C addressed, and youll need...oh...4 to 6 of them at least. And they're not the cheapest thing under the sun. But they take most of the load off of you, and do the multiplexing and processing onboard. They even have keypad encoders/debouncers onboard as well. And being all I2C, it's faster than you could bit bang, and only requires two pins.

I honestly dont see how your going to pull off a good, clean control scheme for all of these LED's for less than $20. Especially with what you want to do. You may have to bite the bullet and shell out.

--Andy P
 

Bloody-orc

Senior Member
ok i dont use PICAXE anymore. (sorry)

Im using a AVR microcontroller with 80 I/O pins so i dont have to use any external stuff (exept transistors). Those thins are faster also so the speed is not a problem also. (16 MIPs still...)

ok thanks for your help and i'll see what i can do...
 
Top