Due by midnight on Monday Feb 24th
First look at Rails and our web-app. Establish a working rails development environment on your own machine. Create a skeletal rails application on your own machine and test it locally using the mongrel web-server. Consistently defeat
RandomPlayer at Connect Four in the RubyGame web-app.
It is vital for the remainder of the class that you each have access to your own Rails development machine. I use a Windows machine but Ruby and hence Rails too are platform independent so you should be able to use a Mac or Linux if you want to. However, I won't be able to field questions about installation unless on Windows.
It is also vital that we all use the same versions of Ruby and Rails. Currently, the CS department linux machines have Ruby 1.8.7 and Rails 2.2.2 (yes, the Rails framework has version numbers separate from Ruby). I actually develop against Ruby 1.8.6 but when deploying code to a CS host running Ruby 1.8.7 it all seems to work so we will assume that both Ruby 1.8.6 and Ruby 1.8.7 are acceptable to us and fix any compatibility issues if/when they arise. So your development machine MUST have:
- Ruby 1.8.6 or Ruby 1.8.7
- Rails 2.2.2 (no other version will do)
- MySql 5.x. (On windows you get it as part of Instant Rails)
- SqlLite 3. (On windows you get it as part of Instant Rails)
- Windows - use Instant Rails 2.0
- Check out the Instant Rails web site and download the zip file under version 2.0.
- Don't let the zip file extract to the default path. Be sure to change
the path to something short like
C:\ruby. It will take a while to extract so be patient.
- Under your
Instant Railsdirectory copy the file
- This screencast provides installation instructions.
- The versions of gems and rails in instant Rails aren't quite what we need so update them to the necessary versions as follows:
- In the Instant Rails GUI, click the I icon at the top-left corner
Rails Applications - Open Ruby Console Window. IMPORTANT: you must ALWAYS use this command prompt for rails work and NEVER the regular windows one, so DO NOT CLOSE the instant Rails GUI.
- Make sure your internet connection is working before the next two steps, i.e. make sure you are online.
version 1.3.5 of the rubygems zip file and extract it
Instant Railsdirectory. Using the instant rails command prompt you opened in step 1.5.1 change directory to the rubygems folder you just extracted and enter:
- Enter (much patience required):
gem install rails --version 2.2.2
- In the Instant Rails GUI, click the I icon at the top-left corner and select
- Check that the versions are correct using:
gem -v(should be 1.3.5)
rails -v(should be 2.2.2)
ruby -v(should be 1.8.6)
- Rails Tutorial
Do the tutorial in chapters 5-8 of the Agile Web Development with Rails book (AWDwR). Ignore all the stuff about MySql on pages 63-66 and just use the default SqlLite3 for this tutorial. You can do more chapters if you want to get ahead for the next project but chapters 5-8 are enough for now. If you are unfamiliar with the MVC (Model View Controller) design pattern then make sure you read chapter 2 first (it's part of this week's assigned reading anyway).
When you're finished and, more importantly, your
Depotweb-app is running correctly on your localhost, zip up your
Depotdirectory into a file called
depotand submit that in the usual way.
Write a class
Connect4Simpletonthat inherits from
AgentBaseand put it in a file called
c4_simpleton_s14_your_name.rb. (So mine would be in file
c4_simpleton_s14_julian_bishop.rb). In the game of Connect Four, a winning move makes 4-in-a-row and a blocking move prevents the opponent from having a winning move on its next turn.
Connect4Simpletonhas a keen eye but is otherwise rather stupid:
- If the board contains a winning move then
- If the board contains no winning move, but does contain a blocking move then
- If the board contains no winning or blocking move then
You should assume my solution to the
Connect4class when writing your
Connect4Simpletonsince mine is the one used in the web-app.
- If the board contains a winning move then
- RubyGame Web-app First Look
- Open your browser and navigate to http://wrath.cs.utexas.edu:3000/games. You will see a login screen where you should click on "Sign up" to create a user account for the site. Choose your user Login name sensibly as for the time being it will be used to identify your records on the screen and so be visible to other users.
- After signing up you should be redirected to a list of all the games
that have been uploaded to the web-app. Play around with the web-app. Use
the "Upload New Agent" link to upload your
Connect4Simpleton. The "New Agent" form will ask you to give your agent a name. Name it "C4 Simpleton XXX S13" where XXX are your initials and do not include the quotation marks (so mine would be named C4 Simpleton JNB S14). In the Class field enter
Connect4Simpletonand then select your file using the "Browse" button. Don't forget to tell the form that your player can play Connect Four!
- Use the "Play" button on the "All Games" page to play a
game of Connect Four between your
Connect4Simpletonas player1 and
RandomPlayeras player2. Repeat this nine more times for a total of ten results and do not destroy your results (I can tell if you do). Even the results which are not what you want are of interrest to me. If your
Connect4Simpletonis correct you should expect it to win every match although it is not impossible for it to be very unlucky and lose one.
- How was your user experience? Can you recommend any functionality improvements for the web-app? Put your answers in a file called
functionality.txt. I'm not so interested in making it look pretty as I am in making it more functional - you're developers not web-designers. Instead focus on missing or superfluous information and lack of useability or features.
- Finally, you are free to view but not modify all the code in the web-app you have just been using: open a linux terminal window for one of the CS department machines and change directory to
/u/z/users/julian/rails2_apps/rubygameand peruse the code most of which is under the
appfolder. Also check out the database diagram for the app which is implemented using MySql.
- Explore the Rails online documentation
Explore www.rubyonrails.org, especially the documentation pages
Follow the tutorial and zip up and turn in the resulting
Depot web-app to prove you are in a position to do rails development for the remainder of the class. As long as it works when I test it you will get full credit for this part of the project.
Connect4Simpleton should adhere to the specification and win consistently against
RandomPlayer and your code should be as concise and elegant as possible.
Your suggestions in
functionality.txt should be constructive, achievable, and not just window-dressing for the existing funtionality. A short bullet-pointed list is enough to get full credit for this part of the project.