User Tools

Site Tools


haas:fall2011:cprog:projects:farmerriver

Game: Farmer and the River

Here we are going to implement the classic “Fox, Chicken, Corn” game.

Rules

The premise of this game involves a farmer with the above-mentioned items that needs to transport them across a stream in a boat.

The boat, unfortunately, is large enough only for the farmer and one item.

There exists the following relationship with the items:

  • The fox, left alone with the chicken, will eat the chicken.
  • The chicken, left alone with the corn, will eat the corn.

So one needs to craft a careful means of transporting all these items without losing any of them.

Programming Considerations

  • Your program should display the current scene (using textual characters, ASCII)
    • visualize the location of the farmer, fox, chicken, corn, river, and boat
  • At the start of the game, prompt the user for a display of the game rules and instructions
  • At the conclusion of the game:
    • display the total number of turns taken before the game reached its end (successful or otherwise) state
    • prompt the user if they would like to play again
  • Create, populate, and use the following functions:
    • intro(); - a function to display the instructions for the game
    • display(); - a function to display the current playing field
    • chkmove(); - a function called after each turn to determine if the game is over (user chooses poorly), or if the game is still in session
  • There are to be NO global variables used in your program. Pass any needed variables by value or address between functions
  • Of your variables and functions, you are to pass at least one variable by address and manipulate it within the called function (so the changed value is reflected outside the called function as well).
  • Implement your code first in a single .c file- farmer.c
  • Once you have a working single-file version of the game, also split it up into multiple files and verify you can still compile/play it. Have at least 4 files:
    • game.h
    • main.c
    • displayops.c
    • process.c
haas/fall2011/cprog/projects/farmerriver.txt · Last modified: 2011/08/21 15:51 by 127.0.0.1