Jump to content

How do I simulate a game of snakes and ladders on Excel?


Recommended Posts

Unless it is for a school project or something similar, I don't see the point of the request - there are numerous hits on Gooooogle for it.

If it is for a school project, asking here is a cop out :)

Link to post
Share on other sites
Unless it is for a school project or something similar, I don't see the point of the request - there are numerous hits on Gooooogle for it.

If it is for a school project, asking here is a cop out :)

I was just thinking that if it was school work, then schools are definitely not what they used to be! :D

Link to post
Share on other sites

Here's some suggestions, mind it's been years since I was playing Snakes and Ladders and also playing about with macro's. But I've had your problem on my mind all day. It should be a very stimulating exercise for you, These are only suggestions and other people are bound to either correct me or make suggestions for improvements or corrections. I storngly suggest that you build the whole thing up in several small blocks. then you can combine them in stages. This will be my suggestion for a single player - leave it to you to convert it to a multiplayer game.

First draw up an overall Flow diagram, Each stage to be as small blocks - such as:-

Draw up 2 tables, e.g. ladder test and snake test. In each table decide the start and finish positions.

starting at position 1 - beginning. Call this counter position. Throw dice - you've done that now. Add the number to your position, counter position

Now comes the interesting parts - conditional statements IF( ), look up the syntax via the help function.

If the number = any number in ladder table then i.e. =true the take the new number in table, else keep your original number.

If the number = any number in snake table i.e.= true then take new number in table else keep new number.

If number > finish number go back to counter position.

If number = end number go to Win routine.

If number < end number go to throw dice again.

Not very efficient but provided you concentrate on getting the flow diagram sorted then it should be relatively straight forward.

Hope I haven't done too much of your homework for you though but this procedure should work out - I hope. Do test each block thoroughly though.

Link to post
Share on other sites

Forgot to add a most important set of conditions:-

Always check to see if the counter position is valid i.e. no negative number or that it is greater than the max number on the board + 6.

Also do build in a break out or stop test. You don't want to get into an endless loop.

I did that when I was learning programming ( Fortran 2) and our night school was using the County Council Computer (an ICL 1900 type) during night school. No monitors in those days just punched cards. Anyway my program went into an endless loop - it had bypassed my traps and also the built in traps. It spewed out a whole box of Line Printer paper at a great rate of knots. Frightened the life out of me. Visions of Council Payrolls and Council Tax demands in error gave me a bit of a nightmare that night.

Have fun.

Link to post
Share on other sites
I saw a post that you guys where making before, and at that time I knew then the age you guys would be.Over 70's club, right?

Wrong! Some of us are under 70. B)

The common factor which we have is experience, which comes with age. :D

i.e. Why have you reached 200 posts on this forum? .... In search of experience. :lol:

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy