首页 > 其他分享 >INT2067 Introduction to Programming

INT2067 Introduction to Programming

时间:2024-11-08 17:20:53浏览次数:3  
标签:------------------------ Goose Introduction Programming shore should goose game 

Assignment 1

INT2067 Introduction to Programming and Problem Solving

2024-2025 Semester 1

Due Date: October 30, 2024 (Wednesday)

1 Introduction

In this assignment, you need to implement a text-based game based on the riddle abouta farmer who needs to cross a river with a fox, a goose, and a sack of corn.

2 Riddle

A farmer with a fox, a goose, and a sack of corn needs to cross a river. The farmer has arowboat, but there is room for only the farmer and one of her three items.Unfortunately, both the fox and the goose are hungry. The fox cannot be left alone withthe goose, or the fox will eat the goose. Likewise, the goose cannot be left alone withthe sack of corn, or the goose will eat the corn. How does the farmer get everythingacross the river?

3 Game

In your text-based game, the farmer can move at most one item to the other shore eachtime. You should ask the user to enter a command to determine what item the farmerwants to take at each turn. The game ends when the user quits the game or when theuser has succeeded or failed.

4 Basic Design

You may follow the following basic flow in your program:

 Show item locations.

 Repeat:

  1. Ask for the next command.
  2. Update item locations if necessary.
  3. Show item locations.
  4. Exit the loop if the game has succeeded or failed.

You may need to add other steps and/or flows to fulfill all the requirements. 5 Requirements (70%)Your program should do the following:

 [5%] Print the goal of the game at the start.

 [10%] Ask the user to enter a command at each turn and continue until the userrequests to quit or the goal has succeeded or failed.

 [10%] Show the location of the boat and the three items (fox, goose, corn) clearlyat the start of the game and after each turn. You may follow the output in thesample session.

 Accept the following five one-character strings as valid commands: f, g, c, m orAfter receiving a valid command, the game should:

o f, g or c: move the fox, goose, or corn, if available, to the opposite shorealong with the boat. [10%]o m: move the boat to the opposite shore without any item. [5%]oq: quit the game. [5%] [10%] Check whether 代写INT2067 Introduction to Programming and Problem Solving the requested item is on the same shore as the boat whenthe game receives the command f, g or c. If not, it should prompt an error andallow the user to enter a command again.

 [10%] Check whether the game has succeeded or failed after each turn. Thegame has succeeded if all items have been moved to the far shore. The gamehas failed if the fox has eaten the goose, or the goose has eaten the corn. Whenthe game has succeeded, it should congratulate the user. When the game hasfailed, it should tell the user why.

 [5%] Show an error if the user has entered an unrecognized command character(i.e. a string other than ‘f’, ‘g’, ‘c’, ‘m’ or ‘q’).

6 Program Design and User Interface (30%)

 [10%] You should break down your program into functions with reasonablelength.

 [10%] You should use functions and/or lists to reduce redundancy.

 [10%] The output should be neat, and the required information should be shownclearly. The text in the output should be correct and contain no spellingmistakes. 7 Submission Requirements

 Your Python file should be named as assignment1.py. Submit only the Pythonfile assignment1.py through Moodle. Failure to submit the file properly willresult in a penalty of 5 to 20 marks.

 See Moodle for the exact time of the deadline for submission. Late submission isusually not accepted. You should submit earlier to avoid possibly high traƯ ic

around the deadline.

8 Hints

Please check the discussions forum on Moodle regularly for any hints.

9 Plagiarism PolicyThe assignment should be done only by yourself. Every line of code should be written byyou. Discussions on the assignment should be kept at a high-level only. You arsuggested to refer your classmates to the relevant notes or lab exercises if you want tohelp them.

If cheating is found, both the copier and originator will get zero mark for the

assignment.

Repeat oƯ enders may result in a deduction of the course grade.If you have discussed the assignment with anyone, you should provide anacknowledgment at the end of your program file. Give the names of all classmates thatyou have discussed with. For example, your acknowledgement may look like this at theend of your program file:# Acknowledgement: I have discussed it with Thomas, Gordon, and Emily. 10 Sample Session 1

Welcome.You must bring the fox, the goose, and the corn across theriver.

------------------------

Boat

------------------------

Fox Goose Corn

You are now at the near shore, what do you want to take? g 

Goose

------------------------

Boat

------------------------

Fox Corn

You are now at the far shore, what do you want to take? m 

Goose

------------------------

Boat

------------------------

Fox Corn You are now at the near shore, what do you want to take? f 

Fox Goose

------------------------

Boat

------------------------

Corn

You are now at the far shore, what do you want to take? g 

Fox

------------------------

Boat

------------------------

Goose Corn

You are now at the near shore, what do you want to take? c 

Fox Corn

------------------------

Boat

------------------------

Goose You are now at the far shore, what do you want to take? m 

Fox Corn

------------------------

Boat

------------------------

Goose

You are now at the near shore, what do you want to take? g 

Fox Goose Corn

------------------------

Boat

------------------------

Congratulations!

You have brought all the items across the river.

11 Sample Session 2

Welcome.

You must bring the fox, the goose, and the corn across the

river.

------------------------

Boat

------------------------

Fox Goose Corn You are now at the near shore, what do you want to take?

goose

You have entered an invalid command.

------------------------

Boat

------------------------

Fox Goose Corn

You are now at the near shore, what do you want to take? f 

Fox

------------------------

Boat

------------------------

Goose CornYou have failed.The goose has eaten the corn.

标签:------------------------,Goose,Introduction,Programming,shore,should,goose,game,
From: https://www.cnblogs.com/comp9321/p/18534008

相关文章

  • The 2022 ICPC Asia Hangzhou Regional Programming Contest C
    C.NoBugNoGame\(很简单的一个dp\)\(在枚举到当前为i的时候假设当前容量为j对其进行转移\)点击查看代码#include<bits/stdc++.h>#defineintlonglong#defineall(x)x.begin(),x.end()#definerall(x)x.rbegin(),x.rend()#definepbpush_back#definepiipair<......
  • 一、Introduction to R. 走进R语言(一):R & 心理学
    目录R的适用范围为什么要学习R语言?如何学习R语言?R&Rstudio下载R&RstudioR的适用范围R isa programminglanguage for statisticalcomputing and datavisualization.从维基百科对R的介绍可以得知,R主要是用来做统计的计算和数据可视化的。简言之,一篇文......
  • The 2022 ICPC Asia Hangzhou Regional Programming Contest
    A.ModuloRuinstheLegend\(题目即求(sum+n*s+(n+1)*n/2*d)\equiv\modm的最小值\)\(由裴蜀定理可得n*s+(n+1)*n/2*d=gcd(n,(n+1)*n/2)\)\(令p=gcd(n,n*(n+1)/2)\)\(可以表示为(sum+k*p+t*m)\equiv\modm\)\(令g=gcd(p,m)\)\((sum+g*z)%m\)\(sum+g*z>=m时存在最小值\)\(......
  • Introduction_Optimization Models_Giuseppe C. Calafiore, Laurent El Ghaoui
    Balabala我想读完GiuseppeC.Calafiore,LaurentElGhaoui版本的《OptimizationModels》。1.Introduction作者列举了若干个例子,并阐述了优化问题的一般形式,最主要的洞见有:一些具有特定性质的问题是tractable的:Thefocusofthisbookisontractablemodels,andak......
  • MU5IN160 – Parallel Programming
    SorbonneUniversité–SESIM2——–MU5IN160–ParallelProgrammingHands-onSession6–DataflowforMotionApplicationVeryimportant,aboutthesubmissionofyourworkAttheendofthissessionyouwillhavetouploadthefollowingfilesonMoodle:1......
  • COMP2404 Introduction to Software Engineering
    COMP2404-“IntroductiontoSoftwareEngineering”Assignment31SubmissionInstructionsSubmittoBrightspaceonorbeforetheduedateacompressedfile(.taror.zip)thatincludesHeaderandsourcefilesforallclassesinstructedbelow.AworkingM......
  • DATA 2100 Major Python Programming
    DATA2100MajorHomeworkPythonProgramming100pointsPurposeInthisassignment,studentswillapplytheir(Python)programmingskillstodevelopadataentryapplicationthatvalidatesentriesagainstadatabaseandthenrecordsvalidentriestothesamed......
  • TOYOTA SYSTEMS Programming Contest 2024(AtCoder Beginner Contest 377) 补题记录(A-E
    AtCoderBeginnerContest377A-RearrangingABC字符串有ABC三个字母即可。#include<bits/stdc++.h>usingnamespacestd;#defineintlonglongsignedmain(){ strings; cin>>s; map<char,int>mp; for(autot:s){ mp[t]=1; } if(mp[......
  • SI 100B Programming
    SI100BProgrammingAssignment2SI100BTATeamOctober23,20241NoticeThishomeworkisdue10:00AMOctober30,Wednesday,pleasestartearly.Theproblemsshouldbesolvedindividually.Youshouldsubmitsolutionsforallproblemstotheonlinejudg......
  • 2024.10.4 2018-2019 ACM-ICPC Southeastern European Regional Programming Contest
    比赛链接Solved:7/11Penalty:914Rank:1/74Rank(vp):63/1k+Dirt:22%G答案是4*纯色块数+5。考虑怎么维护这个纯色块数。这道题的修改保证了一个块纯色当且仅当其行列都纯色。因此对行列分别维护一棵线段树,维护每一层分别有多少个纯色节点,按层乘起来相加就行。K1操作的增加量......